Created
March 16, 2017 19:05
-
-
Save PFortin93/8ef84fdb346a1f0b5a2a369e0f73e006 to your computer and use it in GitHub Desktop.
vCenter Alarm Setup Script for vCenter 6/6.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## VMWare Alert Setup Script | |
| ##Modified from https://fixingitpro.com/2012/07/09/powercli-script-to-automatically-setup-vcenter-alarm-email-notification/ | |
| ## For use with vCenter 6/ 6.5 | |
| ## Modifications by Pierce Fortin | |
| ## PFortin93@gmail.com | |
| $user="USERNAME" | |
| $pass="PASSWORD" | |
| $vCenterServer="vCenterIP" | |
| $MailtoAddresses= "EMAIL@ADDRESS.TLD" | |
| #----Connect to the vCenter Server | |
| Connect-VIServer -Server $vCenterServer -Protocol https -User $user -Password $pass -WarningAction SilentlyContinue | Out-Null | |
| $sessionManager = Get-View -Id $global:DefaultVIServer.ExtensionData.Content.SessionManager | |
| $sessionManager.SetLocale(“en-US”) | |
| #----These Alarms will send a single email message and not repeat ---- | |
| $LowPriorityAlarms="Timed out starting Secondary VM",` | |
| "Virtual Machine Fault Tolerance vLockStep interval Status Changed",` | |
| "Migration error",` | |
| "Exit standby error",` | |
| "License error",` | |
| "Virtual machine Fault Tolerance state changed",` | |
| "VMKernel NIC not configured correctly",` | |
| "Unmanaged workload detected on SIOC-enabled datastore",` | |
| "Host IPMI System Event Log status",` | |
| "Host Baseboard Management Controller status",` | |
| "License user threshold monitoring",` | |
| "Insufficient vSphere HA failover resources",` | |
| "License capacity monitoring",` | |
| "Pre-4.1 host connected to SIOC-enabled datastore",` | |
| "License inventory monitoring",` | |
| "Appliance Management Health Alarm",` | |
| "Cannot connect to storage",` | |
| "Cannot find vSphere HA master agent",` | |
| "Data Service Health Alarm",` | |
| "ESX Agent Manager Health Alarm",` | |
| "Host error",` | |
| "Host hardware fan status",` | |
| "Host hardware power status",` | |
| "Host hardware system board status",` | |
| "Host hardware temperature status",` | |
| "Host hardware voltage",` | |
| "Host IPMI System Event Log status",` | |
| "Host memory status",` | |
| "Host processor status",` | |
| "Host service console swap rates",` | |
| "Host storage status",` | |
| "Network connectivity lost",` | |
| "Network uplink redundancy degraded",` | |
| "Network uplink redundancy lost",` | |
| "Status of other host hardware objects",` | |
| "vCenter Server Health Alarm",` | |
| "Virtual machine Consolidation Needed status",` | |
| "VM MAC Conflict",` | |
| "VMware Common Logging Service Health Alarm",` | |
| "vSphere HA failover in progress",` | |
| "vSphere HA virtual machine failover failed",` | |
| "vSphere HA virtual machine monitoring action",` | |
| "vSphere HA virtual machine monitoring error",` | |
| "vSphere HA VM Component Protection could not power off a virtual machine",` | |
| "vSphere HA virtual machine failover failed",` | |
| "vSphere vCenter Host Certificate Management Mode",` | |
| "License capacity monitoring" | |
| #----These Alarms will repeat every 24 hours---- | |
| $MediumPriorityAlarms=` | |
| "Virtual machine error",` | |
| "Host cpu usage",` | |
| "Health status monitoring",` | |
| "Host memory usage",` | |
| "Cannot find vSphere HA master agent",` | |
| "vSphere HA host status",` | |
| "Host service console swap rates",` | |
| "vSphere HA virtual machine monitoring action",` | |
| "vSphere HA virtual machine monitoring error" | |
| #----These Alarms will repeat every 2 hours---- | |
| $HighPriorityAlarms=` | |
| "Host connection and power state",` | |
| "Host processor status",` | |
| "Host memory status",` | |
| "Host hardware fan status",` | |
| "Host hardware voltage",` | |
| "Host hardware temperature status",` | |
| "Host hardware power status",` | |
| "Host hardware system board status",` | |
| "Host battery status",` | |
| "Status of other host hardware objects",` | |
| "Host storage status",` | |
| "Host error",` | |
| "Host connection failure",` | |
| "Cannot connect to storage",` | |
| "Network connectivity lost",` | |
| "Network uplink redundancy lost",` | |
| "Network uplink redundancy degraded",` | |
| "Thin-provisioned volume capacity threshold exceeded.",` | |
| "Datastore cluster is out of space",` | |
| "vSphere HA failover in progress",` | |
| "vSphere HA virtual machine failover failed" | |
| #---Set Alarm Action for Low Priority Alarms--- | |
| Foreach ($LowPriorityAlarm in $LowPriorityAlarms) { | |
| Get-AlarmDefinition -Name "$LowPriorityAlarm" | Get-AlarmAction -ActionType SendEmail| Remove-AlarmAction -Confirm:$false | |
| Get-AlarmDefinition -Name "$LowPriorityAlarm" | New-AlarmAction -Email -To @($MailtoAddresses) | |
| Get-AlarmDefinition -Name "$LowPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow" | |
| #Get-AlarmDefinition -Name "$LowPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Red" # This ActionTrigger is enabled by default. | |
| Get-AlarmDefinition -Name "$LowPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Red" -EndStatus "Yellow" | |
| Get-AlarmDefinition -Name "$LowPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Green" | |
| } | |
| #---Set Alarm Action for Medium Priority Alarms--- | |
| Foreach ($MediumPriorityAlarm in $MediumPriorityAlarms) { | |
| Get-AlarmDefinition -Name "$MediumPriorityAlarm" | Get-AlarmAction -ActionType SendEmail| Remove-AlarmAction -Confirm:$false | |
| Set-AlarmDefinition "$MediumPriorityAlarm" -ActionRepeatMinutes (60 * 24) # 24 Hours | |
| Get-AlarmDefinition -Name "$MediumPriorityAlarm" | New-AlarmAction -Email -To @($MailtoAddresses) | |
| Get-AlarmDefinition -Name "$MediumPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow" | |
| Get-AlarmDefinition -Name "$MediumPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | Get-AlarmActionTrigger | Select -First 1 | Remove-AlarmActionTrigger -Confirm:$false | |
| Get-AlarmDefinition -Name "$MediumPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Red" -Repeat | |
| Get-AlarmDefinition -Name "$MediumPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Red" -EndStatus "Yellow" | |
| Get-AlarmDefinition -Name "$MediumPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Green" | |
| } | |
| #---Set Alarm Action for High Priority Alarms--- | |
| Foreach ($HighPriorityAlarm in $HighPriorityAlarms) { | |
| Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail| Remove-AlarmAction -Confirm:$false | |
| Set-AlarmDefinition "$HighPriorityAlarm" -ActionRepeatMinutes (60 * 2) # 2 hours | |
| Get-AlarmDefinition -Name "$HighPriorityAlarm" | New-AlarmAction -Email -To @($MailtoAddresses) | |
| Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow" | |
| Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | Get-AlarmActionTrigger | Select -First 1 | Remove-AlarmActionTrigger -Confirm:$false | |
| Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Red" -Repeat | |
| Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Red" -EndStatus "Yellow" | |
| Get-AlarmDefinition -Name "$HighPriorityAlarm" | Get-AlarmAction -ActionType SendEmail | New-AlarmActionTrigger -StartStatus "Yellow" -EndStatus "Green" | |
| } | |
| #---Disconnect from vCenter Server---- | |
| Disconnect-VIServer -Server $vCenterServer -Force:$true -Confirm:$false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment