VMware Cloud Community
Chris8313
Contributor
Contributor
Jump to solution

Export All Alarms and definitions from VCenter.

I found the following article which helps but its not exactly what I am looking for. Script to export Alarms from VCenter to analyze. I am looking to export all alarms and definitions to csv, not just the alarms with just actions set. 

pastedImage_6.png

From the screen shot above, if possible I am looking to export the Name\Description\Trigger Events.


Any help is much appreciated.

Thanks,

Chris

26 Replies
LucD
Leadership
Leadership
Jump to solution

You are sure that you don't have multiple connections to the vSphere Server open?

What is in $global:defaultviservers?

Do you see the same alarm multiple times in the Web Client?


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

Reply
0 Kudos
sanjaygpt171
Enthusiast
Enthusiast
Jump to solution

I am trying to reply on thread but getting error "Portlet is temporarily unavailable." After multiple attempts , i got to post my comments.

Hi LuCD,
I executed the command "$global:defaultviservers" in my powercli and it's listing only single vcenter against which i am executing the script.

Even, i checked in my web client and i am seeing alarm defined only once . I tried to run on different vcenter but was getting same multiple duplicate rows 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try changing the last line to

} | Sort-Object -Property Alarm,Entity -Unique |

Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

Reply
0 Kudos
sanjaygpt171
Enthusiast
Enthusiast
Jump to solution

Hi Lucd,

Duplicate alarms are filtered out but in my vcenter i can see 206 alarms but in report only 72 is exported. I am not sure , why i am seeing such huge difference

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I just realised why you see duplicates (without the Sort-Object), there is an entry per Alarm for each status change: green->yellow, yellow->red, red->yellow, yellow->green
That was the original request in this thread


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

Reply
0 Kudos
sanjaygpt171
Enthusiast
Enthusiast
Jump to solution

I have removed the below line from the script but it's exporting less number of alarms . I can see 221 alarms in my vcenter but script is pulling only 72 alarms. I am not sure why i am seeing such huge difference. I have checked the vcenter alarms and there are no duplicates alarms. My biggest concern is about less number of alarms.

@{N='Expression';E={

                ($alarm.ExtensionData.Info.Expression.Expression |

                ForEach-Object -Process {"{0} ({1}) - {2} - {3}" -f $_.EventType,

                                                                    $_.EventTypeId,

                                                                    $_.ObjectType,

                                                                    ([VMware.Vim.ManagedEntityStatus]$_.Status.value__)}) -join '|'

            }},

            @{N='Trigger';E={

                "{0}:{1}->{2} (Repeat={3})" -f $action.ActionType,

                                               $_.StartStatus,

                                               $_.EndStatus,

                                               $_.Repeat

            }}#>

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is not enough.
The script also looks at the alarm trigger(s).

If there are none, the alarm will not appear in the output.

See your other thread for a basic version of reporting on alarms.


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

Reply
0 Kudos