In this article I’ll try to explain how you can use the ESXi host state or vCenter Custom Attributes to automate the vRealize Operations object maintenance mode.
When working in a vSphere environment, you often have to patch or upgrade systems. If this environment is monitored by vRealize Operations, you want to avoid false positive alerts.
Putting a host in maintenance manually can be done from the Administration menu by choosing Inventory and browse through the object types looking for Hosts Systems. After selecting the correct host, you can put the host in maintenance mode.
Selecting objects in the Inventory explorer is not always very user friendly. If you don’t see any object because of multiple selections, “Deselect All” is often the only way to get your full list back.
So, let’s take a look at how to automate these tasks. In the first scenario we will use the maintenance state of a host in vCenter. This state can be used as a membership criterion in a custom group. This custom group can be configured with a maintenance policy that’s tight to a schedule.
The first step we need to take is create a schedule. In the following example, I’ve created a schedule with the name “Always”. This schedule is configured with a date in the past and a date in the far future. This is much easier to configure in a policy compared to blocking all the alerts individually.

So now let’s create a Maintenance Policy. In the “Analysis Settings” I’ve selected “Always” as the Maintenance Schedule. This policy will be used by the Custom Group.

The Custom Group’s membership is based on the Property “Runtime|Maintenace State” with the value “inMaintenance”. You also need to select the option “Keep group membership up to date”.

Once the Schedule, the Policy and the Custom Group have been configured we can switch to vCenter and put two of the ESXi hosts in maintenance mode.

After putting the two hosts in Maintenance, we can go back to the vRealize Operations Inventory explorer and check the Collection State of both hosts.

We can see that sa-esxi-01 and sa-esxi-08 have entered the “In Maintenance” State. There’s also a virtual machine in this list. Typically, there’s no option available in vCenter that allows you to put a virtual machine in maintenance mode.
In the next section we will look at putting other vCenter inventory items like datastores or switches in maintenance mode by using the vCenter Custom Attributes.

In this example we will look at how to put the app-01 virtual machine in maintenance. The first thing you need to do is create a Custom Attribute named Maintenance second, we have to assign “yes” as a value.

The next step is the creation of a new policy or edit the exiting Maintenance policy and include the “vCenter Adaptor - Virtual Machine” Object type.
Now we have to create a new Custom Group with a membership rule that checks the “Summary|Custom Tag:Maintenance” property value. When this value is “yes” the virtual machine will automatically become a member.

In the Inventory we can see the Virtual Machine app-01 has stopped collecting metrics. The collection Sate is showing 3 grey icons. The attribute-based maintenance detection is not limited to virtual machines only, it’s also possible with other vCenter inventory objects and also works on an ESXi host.