Hi drheim,
You are probably not going to like this but this is what I did to resolve a similar issue where we need to disable alarms for periods of time. In our case it was for our SQL servers during backups so we did the following:
1. Created a VM folder and put the VMs in here
2. Created an alarm definition for this folder with the appropriate Triggers and Actions
3. Create scheduled task to run a PowerShell script called "ManageAlertsDefinitions" at set times to ENABLE and DISABLE the alarm
The script I used is pretty basic and rough however here is it:
Start-Transcript -Path c:\scripts\ManageAlertsDefinitions.log -Append
$Alarms = "Virtual Machine CPU usage for SQL"
$EnableHour = "06"
$DisableHour = "22"
$vcServer = "myvcenter"
Function Test-AlarmState {
Param( $alarm )
$AlarmState = Get-AlarmDefinition -Name $alarm | Select-Object Enabled
return $AlarmState.Enabled
}
Connect-VIServer -Server $vcServer
Switch ( (Get-Date -UFormat %H) ) {
"$EnableHour" {
Foreach ($alarm in $Alarms) {
If ( !(Test-AlarmState($alarm)) ) {
Set-AlarmDefinition -AlarmDefinition "$alarm" -Enabled:$True
}
}
}
"$DisableHour" {
Foreach ($alarm in $Alarms) {
If ( Test-AlarmState($alarm) ) {
Set-AlarmDefinition -AlarmDefinition "$alarm" -Enabled:$False
}
}
}
}
Disconnect-VIServer -Confirm:$False
Stop-Transcript
There are a couple of variables to update:
- $Alarms vairable with the name of your alarm definition
- $EnableHour and $DisableHour variables
- $vcServer variable with the name of the vCenter server
The script should be parameterized, so if you find it useful then we could modify.
Kind regards.