13 Replies Latest reply on Jun 6, 2018 2:18 AM by Satheeshkumar

    Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Satheeshkumar Novice

      Hi All, i am looking for an option to get the "Configured Alarms list per VC, DC, Cluster, Host, VM Level" with the powercli script.,

      and another script which is to pull all the triggered script in the infra.

        • 1. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          What do you mean with "triggered scrip in the infra"?

          Or do you mean triggered alarms in the infra?

          And if yes, over which time frame?

          • 2. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
            Satheeshkumar Novice

            Hi LucD,

            please find the request as below.

            1. Alarms configured in my infra under alarm definition( object VM\Host\vcenter\DC\Cluster\Datastore) - this is for audit purpose (we will do the modification at later point)

            2. current Triggered alarms in the infra.(as our infra is with 27vcenter server, each vc have more than 80 alarms) so want to collect the report of current triggred list.

            • 3. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
              LucD Guru
              Community WarriorsvExpertUser Moderators

              1. Defined alarms

               

              foreach($vc in $global:defaultVIservers){

                 foreach($alarm in Get-AlarmDefinition -Server $vc){

                 $obj = [ordered]@{

                vCenter = $vc.Name

                Datacenter = ''

                Cluster = ''

                ResourcePool = ''

                VMHost = ''

                Folder = ''

                VM = ''

                Alarm = $alarm.Name

                Description = $alarm.Description

                Enabled = $alarm.Enabled

                }

                 switch($alarm.Entity.GetType().Name){

                 'DatacenterImpl' {

                 $obj.Datacenter = $alarm.Entity.Name

                }

                 'ClusterImpl' {

                 $obj.Cluster = $alarm.Entity.Name

                 $obj.Datacenter = (Get-Datacenter -Cluster $alarm.Entity.Name).Name

                }

                 'VMHostImpl' {

                 $obj.VMHost = $alarm.Entity.Name

                 $obj.Cluster = (Get-Cluster -VMHost $alarm.Entity.Name).Name

                }

                 'ResourcePoolImpl' {

                 $obj.ResourcePool = $alarm.Entity.Name

                 $obj.Cluster = (Get-Cluster | where{(Get-ResourcePool -Location $_).Name -eq $alarm.Entity.Name}).Name

                 $obj.Datacenter = Get-Datacenter -Cluster $obj.Cluster

                }

                 'FolderImpl' {

                 if($alarm.Entity.Name -ne 'Datacenters'){

                 $obj.Folder = $alarm.Entity.Name

                 $obj.Datacenter = (Get-Folder -Name $alarm.Entity.Name | Get-Datacenter).Name

                }

                }

                 'VirtualMachineImpl' {

                 $obj.VM = $alarm.Entity.Name

                 $obj.VMHost = (Get-VMHost -VM $alarm.Entity.Name).Name

                 $obj.Cluster = (Get-Cluster -VM $alarm.Entity.Name).Name

                 $obj.Datacenter = (Get-Datacenter -Cluster $obj.Cluster).Name

                }

                Default {

                 Write-Host "$_ unknown type"

                }

                }

                 New-Object -TypeName PSObject -Property $obj

                }

              }

               

               

              2. Triggered alarms

               

              foreach($vc in $global:defaultVIservers){

                 $si = Get-View ServiceInstance -Server $vc

                 $root = Get-View -Id $si.Content.RootFolder

                 $root.TriggeredAlarmState |

                Select @{N='vCenter';E={$vc.Name}},

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

                Time,OverallStatus,Acknowledged,

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


              }

              1 person found this helpful
              • 4. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                Satheeshkumar Novice

                Hi LuCd,

                when execute the same, i am not getting the output properly

                i am getting most of the values are empty, can you please help on this?

                ======================

                 

                vCenter      : EIVC50XXXXXXXXX

                Datacenter   :

                Cluster      :

                ResourcePool :

                VMHost       :

                Folder       :

                VM           :

                Alarm        : VTS - ESX CPU UTILIZATION

                Description  : Alarm to monitor the host CPU utilization

                Enabled      : True

                 

                 

                vCenter      : EIVC50XXXXXXXXX

                Datacenter   :

                Cluster      :

                ResourcePool :

                VMHost       :

                Folder       :

                VM           :

                Alarm        : VTS - ESX MEMORY UTILIZATION

                Description  : Alarm to monitor ESXi memory utilization

                Enabled      : True

                 

                 

                vCenter      : EIVC50XXXXXXXXX

                Datacenter   :

                Cluster      :

                ResourcePool :

                VMHost       :

                Folder       :

                VM           :

                Alarm        : VTS - NETOWRK HEALTH

                Description  : Alarm to monitor the redundancy of the network paths

                Enabled      : True

                 

                 

                vCenter      : EIVC50XXXXXXXXX

                Datacenter   :

                Cluster      :

                ResourcePool :

                VMHost       :

                Folder       :

                VM           :

                Alarm        : VTS - STORAGE HEALTH

                Description  : Alarm to monitor host connectivity to storage device

                Enabled      : True

                ===================

                • 5. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                  LucD Guru
                  vExpertCommunity WarriorsUser Moderators

                  On which inventory object did you define those alarms?

                  On the vCenter?

                  • 6. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                    Satheeshkumar Novice

                    in our infra, we used to set alarms on vcenter level with the monitoring type as host\vm\vcenter\cluster(it is monitoring type in gui).

                    so how can i export with respective values

                    • 7. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                      LucD Guru
                      User ModeratorsvExpertCommunity Warriors

                      In this variation I have added the AlarmType property, this indicates for which kind of object the alarm is set.

                      The empty Datacenter, Cluster, ResourcePool, VMHost... indicate that the Alarm was defined on the vCenter root, the hidden Datacenters folder.

                       

                      foreach ($vc in $global:defaultVIservers) {

                       

                         foreach ($alarm in Get-AlarmDefinition -Server $vc) {

                         $obj = [ordered]@{

                        vCenter = $vc.Name

                        Datacenter = ''

                        Cluster = ''

                        ResourcePool = ''

                        VMHost = ''

                        Folder = ''

                        VM = ''

                        Alarm = $alarm.Name

                        AlarmType = $alarm.ExtensionData.Info.Expression.Expression.Type +

                         $alarm.ExtensionData.Info.Expression.Expression.ObjectType +

                         $alarm.ExtensionData.Info.Expression.Expression.Expression.ObjectType +

                         $alarm.ExtensionData.Info.Expression.Expression.Expression.Type |

                        Sort-Object -Unique

                        Description = $alarm.Description

                        Enabled = $alarm.Enabled

                        }

                         switch ($alarm.Entity.GetType().Name) {

                         'DatacenterImpl' {

                         $obj.Datacenter = $alarm.Entity.Name

                        }

                         'ClusterImpl' {

                         $obj.Cluster = $alarm.Entity.Name

                         $obj.Datacenter = (Get-Datacenter -Cluster $alarm.Entity.Name).Name

                        }

                         'VMHostImpl' {

                         $obj.VMHost = $alarm.Entity.Name

                         $obj.Cluster = (Get-Cluster -VMHost $alarm.Entity.Name).Name

                        }

                         'ResourcePoolImpl' {

                         $obj.ResourcePool = $alarm.Entity.Name

                         $obj.Cluster = (Get-Cluster | where {(Get-ResourcePool -Location $_).Name -eq $alarm.Entity.Name}).Name

                         $obj.Datacenter = Get-Datacenter -Cluster $obj.Cluster

                        }

                         'FolderImpl' {

                         if ($alarm.Entity.Name -ne 'Datacenters') {

                         $obj.Folder = $alarm.Entity.Name

                         $obj.Datacenter = (Get-Folder -Name $alarm.Entity.Name | Get-Datacenter).Name

                        }

                        }

                         'VirtualMachineImpl' {

                         $obj.VM = $alarm.Entity.Name

                         $obj.VMHost = (Get-VMHost -VM $alarm.Entity.Name).Name

                         $obj.Cluster = (Get-Cluster -VM $alarm.Entity.Name).Name

                         $obj.Datacenter = (Get-Datacenter -Cluster $obj.Cluster).Name

                        }

                        Default {

                        Write-Host "$_ unknown type"

                        }

                        }

                        New-Object -TypeName PSObject -Property $obj

                        }

                      }

                      • 8. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                        Satheeshkumar Novice
                        for the same alerts, is it possible to get threshold details as well per alarm?
                        • 9. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                          LucD Guru
                          Community WarriorsUser ModeratorsvExpert

                          How do you plan to display that in the output?

                          Especially if an Alarm has multiple trigger expressions.

                          • 10. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                            Satheeshkumar Novice

                            i wound like to get output as csv file only like we got from existing.

                            1. All the threshold valued per alarm in a single table.(seperate lines in same table as array)

                            2. All the alarm actions per alarm in single table(send email: send trap along with details)

                            • 11. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                              LucD Guru
                              User ModeratorsvExpertCommunity Warriors

                              Did I get that right?
                              You want a separate CSV file for the triggers and another one for the actions for each alarm?

                              That will produce an awful lot of CSV files.

                              • 12. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                                Satheeshkumar Novice

                                Hi LuCD,

                                Nope, i meant to collect the data on same csv per alarm in the same row like below.

                                Alarm, AlarmType, Description, vCentername, Threshold, Trigger Action

                                 

                                Ofcourse, threshold & Triggeraction will have more lines per alarm as it will have many condtion.

                                • 13. Re: Configured Alarms list per VC, DC, Cluster, Host, VM Level
                                  Satheeshkumar Novice

                                  hi LuCD,

                                  i have added the below content and i am able to get it.

                                   

                                  $alarm = $alarmname | Get-AlarmAction

                                        $threshold = foreach ($expression in ($alarmname | %{$_.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

                                          }

                                      } 

                                   

                                  if ($alarm.ActionType -match "SendEmail") {

                                  $action =  "" + $alarm.ActionType + " to " + $alarm.To

                                  }

                                  else {

                                  $action = "" + $alarm.ActionType }

                                   

                                  i am able to get the output like what i expected.

                                  Alarm AlarmType Description Enabled threshold Action

                                  VMware HTTP Reverse Proxy Service Health Alarm. Default alarm that monitors the health status of HTTP Reverse Proxy Service. TRUE "Normal: vim.event.HealthStatusChangedEvent

                                  Warning: vim.event.HealthStatusChangedEvent

                                  Warning: vim.event.HealthStatusChangedEvent

                                  Alert: vim.event.HealthStatusChangedEvent" SendSNMP

                                  vSphere UI Health Alarm vSphere UI service alarm to monitor health status TRUE "Normal: vim.event.HealthStatusChangedEvent

                                  Warning: vim.event.HealthStatusChangedEvent

                                  Warning: vim.event.HealthStatusChangedEvent

                                  Alert: vim.event.HealthStatusChangedEvent" SendSNMP

                                  vCenter Stats Monitor Service Health Alarm. Default alarm that monitors the health status of vCenter Stats Monitor Service. TRUE "Normal: vim.event.HealthStatusChangedEvent

                                  Warning: vim.event.HealthStatusChangedEvent

                                  Warning: vim.event.HealthStatusChangedEvent

                                  Alert: vim.event.HealthStatusChangedEvent" SendSNMP

                                  vCenter HA Service Health Alarm. Default alarm that monitors the health status of vCenter HA Service. TRUE "Normal: vim.event.HealthStatusChangedEvent

                                  Warning: vim.event.HealthStatusChangedEvent

                                  Warning: vim.event.HealthStatusChangedEvent

                                  Alert: vim.event.HealthStatusChangedEvent" SendSNMP