Hi James,
Here is the new version, find the attached below.
One thing to note is the script looks for only the alarms with Action set, i.e. SNMP, SendEmail...etc
$output = foreach ($alarm in (Get-AlarmDefinition | Sort Name | Get-AlarmAction))
{
$threshold = foreach ($expression in ($alarm | %{$_.AlarmDefinition.ExtensionData.Info.Expression.Expression}))
{
if ($expression.EventTypeId -or ($expression | %{$_.Expression}))
{
if ($expression.Status) { switch ($expression.Status) { "red" {$status = "Alert"} "yellow" {$status = "Warning"} "green" {$status = "Normal"}}; "" + $status + ": " + $expression.EventTypeId } else { $expression.EventTypeId }
}
elseif ($expression.EventType)
{
$expression.EventType
}
if ($expression.Yellow -and $expression.Red)
{
if (!$expression.Yellow) { $warning = "Warning: " + $expression.Operator } else { $warning = "Warning: " + $expression.Operator + " to " + $expression.Yellow };
if (!$expression.Red) { $alert = "Alert: " + $expression.Operator } else { $alert = "Alert: " + $expression.Operator + " to " + $expression.Red };
$warning + " " + $alert
}
}
$alarm | Select-Object @{N="Alarm";E={$alarm | %{$_.AlarmDefinition.Name}}},
@{N="Description";E={$alarm | %{$_.AlarmDefinition.Description}}},
@{N="Threshold";E={[string]::Join(" // ", ($threshold))}},
@{N="Action";E={if ($alarm.ActionType -match "SendEmail") { "" + $alarm.ActionType + " to " + $alarm.To } else { "" + $alarm.ActionType }}}
}
$output | Export-Csv alarm.csv -UseCulture -NoTypeInformation
Sample Output:
Alarm | Description | Threshold | Action |
Cannot connect to storage | Default alarm to monitor host connectivity to storage device | vprob.storage.connectivity.lost // vprob.storage.redundancy.lost // vprob.storage.redundancy.degraded // esx.problem.vmfs.nfs.server.disconnect | SendSNMP |
Exit standby error | Default alarm to monitor if a host cannot exit standby mode | ExitStandbyModeFailedEvent // DrsExitStandbyModeFailedEvent | SendSNMP |
Health status changed alarm | Default alarm to monitor changes to service and extension health status | HealthStatusChangedEvent | SendSNMP |
Virtual Machine with Snapshots | Testing alarm to notify if someone creates a snapshot on a certain virtual machine. | Warning: isAbove to 1048576 Alert: isAbove to 2097152 | SendEmail to alarms@test-lab.com |
Hope this helps,
Steven.