Query vCenter: How to suppress template VMs?

I am monitoring a vCenter host. It returns ~50 nodes, some of which are VMs and some are Hypervisors.

But some of the VMs are templates as indicated in the vCenter GUI. When I look at the agent output of the vCenter and in particular at the piggyback data for the nodes, this flag is also transfered:

...
<<<<some-template-vm-d81fa30>>>>
<<<esx_vsphere_vm>>>
...
config.template true
...

but apparently not considered. I’d like to filter out those templates. Is there any way besides manipulating the special agent to that effect? These templates are basically useless in checkmk because the are just there and never become operative.

I’m using cee 1.6.0p17.

Hi,
you can ignore placeholder VMs in the vCenter rule. If this not work, disable the service by name, e.g. .*TEMP .
Cheers,
Christian

Thank you Christian. checkmk identifies placeholder VMs by them not having VirtualDisks. At least in my case this is different from those marked with config.template true.

I checked the agent_vsphere to learn how it skips placeholder VMs. Then I copied the agent to the local directory and applied the following patch:

--- share/check_mk/agents/special/agent_vsphere	2020-08-31 02:48:42.000000000 +0200
+++ local/share/check_mk/agents/special/agent_vsphere	2020-10-09 09:16:23.785341064 +0200
@@ -1553,6 +1553,9 @@
         if opt_skip_placeholder_vm and is_placeholder_vm(vm_data.get("config.hardware.device")):
             continue
 
+        if 'true' == vm_data.get("config.template"):
+            continue
+
         if "runtime.host" in vm_data:
             vm_data["runtime.host"] = hostsystems.get(vm_data["runtime.host"],
                                                       vm_data["runtime.host"])

Okay, there is room for improvement (like configurability), but this works.

For me it is important that the agent doesn’t output the templates at all because I combine it with the DCD and don’t want to create hosts in checkmk for the templates. So it’s not only about removing them from the list of services of the vCenter but also about suppressing the piggyback data for them.

But maybe someone has a better idea?

4 Likes

+1 from my side for @Dirk’s suggestion to make a flag configurable to ignore template VMs.

3 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.