Created
June 16, 2014 19:17
-
-
Save complexsplit/21271e1d2e31da2d4106 to your computer and use it in GitHub Desktop.
Get vCenter alarms with Trigger events that have an "Unset" status
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
from pyVim.connect import SmartConnect, Disconnect | |
from pyVmomi import vim, vmodl | |
# this script is intended to be run against all vcenters daily in order to | |
# guard against a possible vcenter crash due to alarms with an unset status. | |
# it prints all alarms with Trigger events w/ an "Unset" status. | |
# this bug is detailed at http://kb.vmware.com/kb/2062989 | |
user = "username" | |
pwd = "password" | |
vcs = ["vcenter"] | |
for vc in vcs: | |
si = SmartConnect(host=vc, user=user, pwd=pwd) | |
content = si.RetrieveContent() | |
am = content.alarmManager | |
alarms = am.GetAlarm(content.rootFolder) # get all alarms | |
for alarm in alarms: | |
try: | |
# only alarms of type EventAlarms can be unset | |
if isinstance(alarm.info.expression.expression[0], vim.alarm.EventAlarmExpression): | |
# status can be Normal, Warning, Alert, or Unset. Unset maps to "none" | |
if alarm.info.expression.expression[0].status == None: | |
print alarm.info.name | |
except AttributeError, e: | |
None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment