VMware Cloud Community
sbaeckstrand
Contributor
Contributor

Get current alarms from vSphere with PowerCli or REST API

I want to extract the data associated with the currently triggered alarms in vSphere, and I want to do it in an automated fashion with APIs or via PowerCLI. So far, I've only found cmdlets and functions to get the defintions and settings for alarms, but can't figure out how to get the actual alarms and their status and so on.

I want to use it to extract data to my external dashboard for automated monitoring of the platform.

Can someone help? We are using the REST APIs as well as the PowerCLI cmdlets, so anything like that works.

Thanks!

4 Replies
sbaeckstrand
Contributor
Contributor

I later contacted VMWare Support about this, but they continously referred me back here. Unfortunately, this thread have no answers.

Is there anyone who has some ideas on how to solve this?

0 Kudos
sbaeckstrand
Contributor
Contributor

Ok, so I hacked this together. However, I cannot find how to get the information about if the alarm has been acknowledged or not..

Add-PSSnapin VMWare.VimAutomation.Core

Connect-VIServer "vcenter01"

$outputPath = "C:\data"

Get-VIEvent -Start (Get-Date).AddDays(-7) -MaxSamples ([int]::MaxValue) |

Where {$_ -is [VMware.Vim.AlarmStatusChangedEvent] -and ($_.To -eq "Yellow" -or $_.To -eq "Red") -and $_.To -ne "Gray"} |

Select CreatedTime,FullFormattedMessage,@{N="Entity";E={$_.Entity.Name}},@{N="Host";E={$_.Host.Name}},@{N="Vm";E={$_.Vm.Name}},@{N="Datacenter";E={$_.Datacenter.Name}} |

Export-Csv "$outputPath\alarms.csv" -noTypeInformation -Delimiter ";"

0 Kudos
benbjamin24
Enthusiast
Enthusiast

I was looking for the same thing and found this post.

http://wannemacher.us/?p=457

It pointed me into the right direction.

B

Ben VCP
david_sjostrand
Enthusiast
Enthusiast

I know this is an old post, but I just had this same question and came up with this:

(get-datacenter).extensiondata.triggeredalarmstate

This gives you all triggered alarms in your datacenters.

/David Sjöstrand