Automation

 View Only
Expand all | Collapse all

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

  • 1.  Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 17, 2018 09:15 AM

    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.



  • 2.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 17, 2018 09:28 AM

    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?



  • 3.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 17, 2018 01:26 PM

    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.



  • 4.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 17, 2018 05:50 PM

    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}}


    }



  • 5.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 23, 2018 08:10 AM

    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

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



  • 6.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 23, 2018 08:57 AM

    On which inventory object did you define those alarms?

    On the vCenter?



  • 7.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 23, 2018 09:03 AM

    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



  • 8.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 23, 2018 09:26 AM

    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

      }

    }



  • 9.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 31, 2018 09:36 AM
    for the same alerts, is it possible to get threshold details as well per alarm?


  • 10.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 31, 2018 09:53 AM

    How do you plan to display that in the output?

    Especially if an Alarm has multiple trigger expressions.



  • 11.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 31, 2018 11:04 AM

    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)



  • 12.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 31, 2018 12:45 PM

    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.



  • 13.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted May 31, 2018 04:39 PM

    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.



  • 14.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level
    Best Answer

    Posted Jun 06, 2018 09:18 AM

    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



  • 15.  RE: Configured Alarms list per VC, DC, Cluster, Host, VM Level

    Posted Apr 14, 2020 02:09 PM

    Hello sateesh,

    can you give me full script of this in a text file.

    Also can you let me know how to pull to excel.