Difference between revisions of "Transforms - Suppress hosts behind down router"

From Zenoss Wiki
Jump to: navigation, search
Line 3: Line 3:
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 
evt.message = "System Down"
 
evt.message = "System Down"
 +
evt.component = device.comments
 
network = device.os.routes.findObjectsById("0.0.0.0")
 
network = device.os.routes.findObjectsById("0.0.0.0")
 
if network is not None and len(network) > 0:
 
if network is not None and len(network) > 0:
  router = dmd.Devices.findDevice(network[0].getNextHopIp())
+
    router = dmd.Devices.findDevice(network[0].getNextHopIp())
  if router is not None:
+
    if router is not None:
    if router.getPingStatus():
+
        if router.getPingStatus():
        evt.message = evt.message + " - Upstream Router is Down"
+
            evt.message = evt.message + " - Upstream Router is Down"
        evt.eventState = 2
+
            evt.severity = 2
         evt.severity = 2
+
         else:
  else:
+
            evt.message = evt.message + " - Upstream Router is OK"
    evt.message = evt.message + " - No Upstream Router Found in the monitoring database"
+
    else:
 +
        evt.message = evt.message + " - Upstream router is not monitored\n"
 +
        evt.message = evt.message + " IP of upstream router is : "
 +
        evt.message = evt.message + network[0].getNextHopIp()
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 13:51, 11 September 2012

This transform will suppress any status/ping errors from devices that are behind routers that you also monitor:

evt.message = "System Down"
evt.component = device.comments
network = device.os.routes.findObjectsById("0.0.0.0")
if network is not None and len(network) > 0:
    router = dmd.Devices.findDevice(network[0].getNextHopIp())
    if router is not None:
        if router.getPingStatus():
            evt.message = evt.message + " - Upstream Router is Down"
            evt.severity = 2
        else:
            evt.message = evt.message + " - Upstream Router is OK"
    else:
        evt.message = evt.message + " - Upstream router is not monitored\n"
        evt.message = evt.message + " IP of upstream router is : "
        evt.message = evt.message + network[0].getNextHopIp()

- Paul Greidanus