Get host details in containers and VMs?

Winck

Renowned Member
Nov 30, 2016
6
2
68
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.