Using tags from vsphere

i created a issue on github a while ago about using tags assigned in Vsphere to VM’s to be able to exclude certain vm’s from being monitored:

it seems that only the custom attributed are being stored in the DB.
currently we are importing only running vm’s to be monitored in icinga:

SELECT o.object_name,
vc.guest_ip_address, vc.hardware_numcpu, vc.hardware_memorymb FROM object
AS o
INNER JOIN virtual_machine AS vc ON o.uuid = vc.uuid
WHERE IS_IPV4(vc.guest_ip_address) and vc.guest_state LIKE 'running'

we also want to exclude certain running vm’s from being monitored. we are already using tags for assigning backup policy’s etc so we want to use the same system to exclude VM’s from the monitoring.

does anybody know of a way to do this?
Can someone let me know if the tags are stored in the DB somewhere or if this feature can be added?

using the vspheredb module version 1.1.0

Tags are not captured (yet) by vspheredb but custom attributes are. I use this SQL to capture VM details:

SELECT vm.instance_uuid, o.object_name,, vc.product_line, vm.custom_values, vm.guest_ip_address, vm.guest_id
FROM object as o 
LEFT JOIN vcenter AS vc ON o.vcenter_uuid = vc.instance_uuid 
LEFT JOIN virtual_machine AS vm ON o.uuid = vm.uuid
WHERE o.object_type = 'VirtualMachine'
ORDER BY o.object_name 

I prefer to get all the results and then filter later. I have rather a lot of vCentres and ESXi hosts to grab data from, so I use instance_uuid as the hostname for VMs to guarantee uniqueness.

I create a custom attribute called Monitoring and fill it with a string I am interested in for the site or whatever.

custom_values comes in as a JSON array that can be modified with “Decode a JSON string” into another column - I call mine cv. Then you can extract the field cv.Monitoring into another column - I add a modifier called cv.Monitoring and use the uppercase modifier on it to ensure it is in the right format. I then Combine multiple properties to set display_name to ${Monitoring}-${object_name} .

With this lot I get a host in Icing named after the UUID with a display_name of the site and the hostname combined.

Sadly this only works on vCentres. I’m still thinking about how to deal with individual esxis without vCentres, which don’t get custom_attributes. lol

(I know this is an old post but it may help someone)