Hi,
I was looking for a way to add this feature to vSphere. I currenlty have powercli scripts that do this through the send-mailmessage function. We have a monitoring team and it would be great if they were auotmagically able to get this every time someone puts a host into maintenace mode or takes a host out of maintnace mode. I was looking for an alarm and to do this as an alarm action however maintence mode is not an alarm 😞
I am sure I am missing something obvious.
Thanks for the assistnace.
Afaik, there is an extended event that is triggered when a host enters maintenance mode.
With my Event-O-Matic you can find this, and even generate some sample code.
With my script in Alarm expressions – Part 2 : Event alarms, you can define an alarm using an extended event.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the starting point. I have read both articles to try and figure out why my script with the minor adjustments is not working.
I changed Expression 1 $expression1.eventTypeID = "VMware.Vim.EnteringMaintenaceModeEvent" and Expression 2 $expression2.eventTypeID = "VMware.Vim.ExitMaintenceModeEvent"
I also adjusted the $alarm.Name = "Host Maintenace Mode"
I then ran the script and was returned
Type Value
Alarm alarm-401
So I thought it was successfull, however when I go into the GUI and check I do not see any new alarms. Furthurmore when I run Get-AlarmDedinition I get a return of all of the enabled Alarms but this is not listed.
What did I miss?
Many thanks for all your help.
Also is there any way to reference the host that was being affected going into maintenace mode? I am trying to think of how to get VMHost from the event.
Again your help is greatly apreicated.
The Alarm passes a lot of info in parameters to the script that you specify to be executed when the alarm is triggered.
In this, you would probably want to look at the VMWARE_ALARM_TARGET variable, it should hold the VMHost.
All this is explained in a great document called More Fun with vSphere Alarms.
It contains great info, and some great pointers to other posts
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference