Get host details in containers and VMs?

Winck

Active Member
Nov 30, 2016
6
2
43
50
Is it possible, in some way, from inside a container and a vm, to determine, which host it's running on?

I'm using Zabbix as a monitoring tool and it would be nice to be able to quickly identify on which host one should look, directly in the alerts from Zabbix.

I'm currently using a terrible, terrible hack, which only works inside a Debian/Ubuntu-based container, where I parse a value from "/proc/asound/oss/sndstat" with the locally installed zabbix-agent . (system.run[sed -n '2p' /proc/asound/oss/sndstat| awk '{print $3}']).

This returns the hosts hostname, which is used to populate an inventory field in Zabbix.

This is not nice and doesn't work in VM.

I'm currently using PVE4 (due for upgrade), PVE5 and a test PVE6, planning on consolidating on PVE6 some time soon.

Any suggestions?

Regards
 
In my monitoring, I have a custom field for each host with the manually populated VMID. With this ID, you can get the host via the PVE API.

Why do you want to know where the VM is running? I never needed that information.
 
Currently, my setup is not clustered and it's a bit of a mess, with 3 diff. versions running. It's a homelab, so it's not critical, but it's convenient to know which host I need to look at, when I get an alert.

Off course, when I get it all clustered up and consolidated, the need will lessen, as I then can just use the Proxmox web interface on any host.

But it could still be handy at times.

Regards
 
Currently, my setup is not clustered and it's a bit of a mess, with 3 diff. versions running.

Oh yeah, that is different indeed.

In a clustered environment, everything is much easier including finding out on which node a vm is running. You can normally just query the API for that.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!