Automation

 View Only
Expand all | Collapse all

Export All Alarms and definitions from VCenter.

Chris8313

Chris8313Nov 15, 2018 07:26 PM

  • 1.  Export All Alarms and definitions from VCenter.

    Posted Nov 14, 2018 11:34 PM

    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. 

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


    Any help is much appreciated.

    Thanks,

    Chris



  • 2.  RE: Export All Alarms and definitions from VCenter.

    Posted Nov 14, 2018 11:39 PM

    What is the purpose of the exported Alarms?

    If it is just to export/import, you could have a look at Angel's functions in Re: Script to export/import Alarms between VC or synchronize alarms between 2 Virtual Centers



  • 3.  RE: Export All Alarms and definitions from VCenter.

    Posted Nov 15, 2018 02:19 PM

    We are using the VEEAM Management pack for SCOM to monitor the environment.  We had a meeting yesterday with our VMware Rep and SE to go through vmware alarms.  My takeaway from that meeting was to export all of the Alarms and definitions to an excel spreadsheet so the we could review all of the alarms and definitions easily.  The SE thought I could just copy and paste out of vcenter but that didn't work so I started searching the web.  I don't need to import anything when done, just need to export a list of all alarms, their definitions and triggers if possible.

    Thanks,

    Chris



  • 4.  RE: Export All Alarms and definitions from VCenter.
    Best Answer

    Posted Nov 15, 2018 03:05 PM

    Try something like the following.

    Note that an alarm might appear on multiple rows, once for each trigger.

    The expression(s) are in 1 column, but separated with a '|'.

    Hope this helps

    Get-AlarmDefinition -PipelineVariable alarm |

    ForEach-Object -Process {

        Get-AlarmAction -AlarmDefinition $_ -PipelineVariable action |

        ForEach-Object -Process {

            Get-AlarmActionTrigger -AlarmAction $_ |

            select @{N='Alarm';E={$alarm.Name}},

                @{N='Description';E={$alarm.Description}},

                @{N='Enabled';E={$alarm.Enabled}},

                @{N='Last Modified';E={$alarm.ExtensionData.Info.LastModifiedTime}},

                @{N='Last Modified By';E={$alarm.ExtensionData.Info.LastModifiedUser}},

                @{N='Entity';E={$alarm.Entity}},

                @{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

                }}

        }

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



  • 5.  RE: Export All Alarms and definitions from VCenter.

    Posted Nov 15, 2018 03:52 PM

    Thank you for the quick reply.  I am getting the following error when trying to run the script.



  • 6.  RE: Export All Alarms and definitions from VCenter.

    Posted Nov 15, 2018 04:49 PM

    Which PowerShell version and PowerCLI version are you using?



  • 7.  RE: Export All Alarms and definitions from VCenter.

    Posted Nov 15, 2018 04:53 PM

    PowerCLI 6.3 Release 1.

    I am about to download 11.0.0 now.



  • 8.  RE: Export All Alarms and definitions from VCenter.

    Posted Nov 15, 2018 04:56 PM

    With PowerCLI 11.0.0 the PipelineVariable should work.



  • 9.  RE: Export All Alarms and definitions from VCenter.

    Posted Nov 15, 2018 07:26 PM

    Thanks again for your help on this!



  • 10.  RE: Export All Alarms and definitions from VCenter.

    Posted Feb 01, 2019 12:46 PM

    How can we customize this script to run through multiple vCenters and export as csv?



  • 11.  RE: Export All Alarms and definitions from VCenter.

    Posted Feb 01, 2019 01:38 PM

    You would need to use an outer ForEach loop, and then use the Server parameter on the cmdlets.
    The script already has an export to a CSV



  • 12.  RE: Export All Alarms and definitions from VCenter.

    Posted Apr 03, 2019 02:33 PM

    Hi LucD,

    thank you for your script.

    Is it posible to export Alarms from vCenter server to csv, then import them to other vCenter?

    I know that VMware provided script to copy alarms from one vCenter to another, but for my case i do not have network connectivity between both VCs.

    That is why for me is better to export, copy and import.

    Thank you in advance.



  • 13.  RE: Export All Alarms and definitions from VCenter.

    Posted Apr 03, 2019 02:44 PM

    The script above copies the alarm definitions to a CSV file.
    Can you copy that CSV file to the other location and import the alarm definitions from there?



  • 14.  RE: Export All Alarms and definitions from VCenter.

    Posted Apr 03, 2019 03:09 PM

    hi,

    thank you for quick answer.

    your script export only alarms with enabled "actions" option. In my case there is 30 alarms.

    I need to have all alarms available on vCenter, becasue i'll setup definitions on one vCenter and import them to all of under my support.

    i can copy csv, but how can i import them to second vCenter?



  • 15.  RE: Export All Alarms and definitions from VCenter.

    Posted Apr 03, 2019 05:22 PM


  • 16.  RE: Export All Alarms and definitions from VCenter.

    Posted Sep 23, 2019 10:26 PM

    LucD,

    Have three new vCenters 2- are production and 1 is more for QA and test.

    All alarms are set to default however need some guidance on setting them up quickly.

    I really like this idea: http://www.cloudyfuture.net/2017/08/08/powercli-script-configure-vcenter-alarm-email/

    However few flaws:

    1. IT would seem from the comments it overwrites the subject field of the email to recipients.

    2. Feel he also has an issue in 6.7 vcsa with multiple recipients in the TO as the ; and , is an issue.

    3. Doesn't really provide for a way to copy EXACTLY what is there today and re-import if needed, meaning you need to set back to a default date.

    4. He doesn't have a most recent copy of alarms for 6.7 U2c

    5. When I look at avail alerts like my "CPU Exhaustion on psc-mydatacenter01-0001" I dont see this is his list, and worried what it will do if it finds or does not find it.

    Really just looking for a way to get up and running quickly in 6.7 vcenter with alarms sent to two or more recipients, and dont want to loose the default if an issue.

    In the end it would also be nice to either perform the same action on both Production vCenters (keep in sync) then alter the emails sent from the non-prod vCenter.- meaning i dont want to send from here as no one really cares about Dev/QA env.

    Have you seen anything avail like he referenced script above that will really do the job in 6.7u2c vCenter?



  • 17.  RE: Export All Alarms and definitions from VCenter.

    Posted Sep 24, 2019 06:22 AM

    Interesting idea, and yes, what you envisage should be possible.

    May I suggest opening a new thread for this, since the concept goes way beyond the original question in this thread.

    And it would make it easier for others to find it,



  • 18.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 24, 2020 05:53 PM

    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 



  • 19.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 24, 2020 06:35 PM

    Try changing the last line to

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

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



  • 20.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 24, 2020 05:11 PM

    HI LuCD,

    I tried to excute this script and it'sworking but in output file , i am geting multiple duplicate values. Could you please fix this.

    Below is the same output:

    Alarm Description Enabled

    Host connection and power state Default alarm to monitor host connection and power state TRUE

    Host connection and power state Default alarm to monitor host connection and power state TRUE

    Host connection and power state Default alarm to monitor host connection and power state TRUE

    Host connection and power state Default alarm to monitor host connection and power state TRUE

    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE

    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE

    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE

    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE

    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE

    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE

    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE

    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE

     
    Alarm Description Enabled
    Host connection and power state Default alarm to monitor host connection and power state TRUE
    Host connection and power state Default alarm to monitor host connection and power state TRUE
    Host connection and power state Default alarm to monitor host connection and power state TRUE
    Host connection and power state Default alarm to monitor host connection and power state TRUE
    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE
    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE
    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE
    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE
    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE
    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE
    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE
    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE


  • 21.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 24, 2020 05:25 PM

    The same alarm might be defined on multiple entities.
    I would need to see the Entity column to see if these are actually duplicates or not.



  • 22.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 24, 2020 06:58 PM

    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



  • 23.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 24, 2020 07:32 PM

    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



  • 24.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 25, 2020 08:10 AM

    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

                }}#>



  • 25.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 25, 2020 09:09 AM

    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.



  • 26.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 24, 2020 05:36 PM
    Alarm Description Enabled Last Modified Last Modified By Entity
    Host connection and power state Default alarm to monitor host connection and power state TRUE 11/6/2015 7:18 Datacenters
    Host connection and power state Default alarm to monitor host connection and power state TRUE 11/6/2015 7:18 Datacenters
    Host connection and power state Default alarm to monitor host connection and power state TRUE 11/6/2015 7:18 Datacenters
    Host connection and power state Default alarm to monitor host connection and power state TRUE 11/6/2015 7:18 Datacenters
    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE 11/6/2015 7:20 com.vmware.vsan.health Datacenters
    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE 11/6/2015 7:20 com.vmware.vsan.health Datacenters
    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE 11/6/2015 7:20 com.vmware.vsan.health Datacenters
    vSAN health alarm 'Hosts with connectivity issues' Default alarm to monitor changes for the health test 'Hosts with connectivity issues' TRUE 11/6/2015 7:20 com.vmware.vsan.health Datacenters
    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE 11/6/2015 7:20 com.vmware.vsan.health Datacenters
    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE 11/6/2015 7:20 com.vmware.vsan.health Datacenters
    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE 11/6/2015 7:20 com.vmware.vsan.health Datacenters
    vSAN health alarm 'Data health' Default alarm to monitor changes for the health group test 'Data health' TRUE 11/6/2015 7:20 com.vmware.vsan.health Datacenters


  • 27.  RE: Export All Alarms and definitions from VCenter.

    Posted Jun 24, 2020 05:43 PM

    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?