Skip to content

Instantly share code, notes, and snippets.

@cluther
Created March 7, 2013 18:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cluther/5110321 to your computer and use it in GitHub Desktop.
Save cluther/5110321 to your computer and use it in GitHub Desktop.
snmpindex_dct example usage
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