VMware Cloud Community
Sankavaraj
Contributor
Contributor

Script for Getting the Active alarm list in the VC

Hi All,

can i get Script for Getting the Active alarm list in the vcenter ?

Thanks,

Sankar R

0 Kudos
7 Replies
LucD
Leadership
Leadership

Do you mean the "enabled" alarms or the alarms that were fired (triggered)?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Sankavaraj
Contributor
Contributor

when i run the script, i should be able fetch the current alarm in the VC

0 Kudos
LucD
Leadership
Leadership

That doesn't really answer my question, all enabled alarms or all triggered alarms?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Sankavaraj
Contributor
Contributor

I am looking for what are the Alarm recently generated and which is not turn to healthy. not sure that comes under triggered or enabled alarm.

Please assist me here

Thanks

Sankar

0 Kudos
LucD
Leadership
Leadership

Ok, it seems you mean the triggered alarms.

One way of doing that is like this

$si = Get-View ServiceInstance

$alarmMgr = Get-View -Id $si.Content.AlarmManager

Get-Inventory | %{

    $alarmMgr.GetAlarmState($_.ExtensionData.MoRef) |

    where{[VMware.Vim.ManagedEntityStatus]::yellow,[VMware.Vim.ManagedEntityStatus]::red -contains $_.OverallStatus} |

    Select @{N='Alarm';E={(Get-View -Id $_.Alarm).Info.Name}},

        OverallStatus,

        Time,

        @{N='Entity';E={(Get-View -Id $_.Entity).Name}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
taipq
Contributor
Contributor

Hi,
If I just want to get alarm of vcenter in last 24 hours. Do you have any idea ?
Thanks

0 Kudos
LucD
Leadership
Leadership

Then you would need to use Get-VIEvent and look at all  AlarmStatusChangedEvent events.
Hence my original question if the requestor wanted to see the triggered alarms


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos