Well after some work I came across this example linked from another forum that 
works.

First I'll also note that dev is not defined. I should have used device which 
has an instance most of the time. I didnt see anything in the logs because 
event-wide transforms log to zenhubs log whereas event-mapping transforms log 
in zentrap.log

Although confusing they are still logged which is good. Now there are two ways 
you can do this.

1st and easiest: 

Navigate to /Events/Status/Snmp click More -> Transform paste code directly 
below

Code:
if evt.summary.startswith('snmp agent down'):
    evt.eventClassKey = "SnmpTest"



Now that sets an eventClassKey on the agent down event so we can now map it to 
an event mapping.

Inside the eventmapping which matches the above eventClassKey paste the code 
below into the transform.


Code:
# Rotate to the next SNMP community string when an agent goes down
if device and evt.summary.startswith('snmp agent down '):
    strings = device.zSnmpCommunities
    for i in range(len(strings)):
        if device.zSnmpCommunity == strings[i]:
            if i == len(strings)-1:
                device.zSnmpCommunity = strings[0]
                break
            else:
                device.zSnmpCommunity = strings[i+1]
                break



2nd: Harder but wee bit faster.

The other way you can do this is to simply edit the source code for 
$ZENHOME/Products/ZenRRD/zenperfsnmp.py

go to line 181 where you see the code for snmpStatusEvent. Make it look like 
this


Code:
    snmpStatusEvent = {'eventClass': Status_Snmp,
                       'component': 'snmp',
                       'eventGroup': 'SnmpTest',
                       'eventClassKey': 'SnmpTest'}



Notice all I added was the last line where we set the eventClassKey to 
SnmpTest. You will need to restart zenperfsnmp before it uses the new code. If 
you get any errors just fall back to the backup you made ;)

Now we dont need the eventwide transform which should speed up things if you 
have a billion agent down events. Of course hand editing this code might ruin 
your support contract with Zenoss or insult your mother but it works fine for 
me. You will lose changes if you upgrade or anything like that.

Now all you need is an eventclass mapping under /Events/Status/Snmp which 
matches the eventClassKey SnmpTest

Paste this code below into that transform and you should be golden


Code:
# Rotate to the next SNMP community string when an agent goes down
if evt.summary.startswith('snmp agent down '):
    strings = device.zSnmpCommunities
    for i in range(len(strings)):
        if device.zSnmpCommunity == strings[i]:
            if i == len(strings)-1:
                device.zSnmpCommunity = strings[0]
                break
            else:
                device.zSnmpCommunity = strings[i+1]
                break



Enjoy.




-------------------- m2f --------------------

Read this topic online here:
http://community.zenoss.com/forums/viewtopic.php?p=15756#15756

-------------------- m2f --------------------



_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to