3 Replies Latest reply on May 17, 2018 10:50 AM by LucD

    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
          Community WarriorsUser ModeratorsvExpert

          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
              vExpertCommunity WarriorsUser 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