Created
March 7, 2013 18:11
-
-
Save cluther/5110321 to your computer and use it in GitHub Desktop.
snmpindex_dct example usage
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 Products.DataCollector.plugins.CollectorPlugin import SnmpPlugin | |
from Products.DataCollector.plugins.CollectorPlugin import GetTableMap | |
class MyPlugin(SnmpPlugin): | |
relname = 'myrelation' | |
modname = 'ZenPacks.example.MyStuff' | |
snmpGetTableMaps = ( | |
GetTableMap('sometable', | |
'1.3.6.1.4.1.58172.100.1.1', { | |
'.1': 'someIndex', | |
'.2': 'someAlternateIndex', | |
'.3': 'someName', | |
}) | |
) | |
def process(self, device, results, log): | |
rm = self.relMap() | |
for snmpindex, row in results[1].get('sometable').items(): | |
# Any SNMP datasources with the 1.3.6.1.4.1.58172.200.1.1 | |
# prefix will use someAlternateIndex as their snmpindex | |
# instead of the component's snmpindex attribute. | |
snmpindex_dct = { | |
'1.3.6.1.4.1.58172.200.1.1': row.get('someAlternateIndex'), | |
} | |
om = self.objectMap({ | |
'id': self.prepId(row['someName']), | |
'title': row.get('someName'), | |
'snmpindex_dct': snmpindex_dct, | |
}) | |
return rm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment