Skip to content

Instantly share code, notes, and snippets.

@dougsyer
Last active October 25, 2017 16:39
Show Gist options
  • Save dougsyer/4b21043e4e0143a20534 to your computer and use it in GitHub Desktop.
Save dougsyer/4b21043e4e0143a20534 to your computer and use it in GitHub Desktop.
parsing zenoss trap snmp trap ciscoEnvMonTempStatusChangeNotif
# your modeller needs to strip off the "GREEN", yellow etc. or you can just change this to walk through the components
# and check to find the right now.
# i have updated envmonE to fix these but i need to publish the update to the public repo..
if device:
from Products.ZenUtils.Utils import prepId
import re
state_map = {
0: ('unknown', 3),
1: ('normal', 0),
2: ('warning', 5),
3: ('critical', 5),
4: ('shutdown', 5),
5: ('notPresent', 2),
6: ('notFunctioning', 5)
}
conditions = ('RED', 'YELLOW', 'GREEN')
state_and_sev = state_map.get(int(getattr(evt, 'ciscoEnvMonTemperatureState', state_map.get(0))))
state = state_and_sev[0]
desc = getattr(evt, 'ciscoEnvMonTemperatureStatusDescr', 'unknown')
tmp = str(getattr(evt, 'ciscoEnvMonTemperatureStatusValue', 'unknown'))
# remove this causes confusion
evt.component = " ".join(desc.split()[-1])
evt.summary = evt.message =
"Trap: Cisco Envmon Temperature Alert: %s registered temperature of %s, state is %s" % (desc, tmp, state)
# drop if not monitored
ts_id = prepId(evt.component)
ts = getattr(device.hw.ciscoenvtempsensors, ts_id, False)
if ts and not ts.monitored():
evt._action = "drop"
evt.severity = state_and_sev[1] if evt.component != 'unknown' else 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment