SNMP based plugin

The class NagiosPluginSNMP that inherits from NagiosPlugin is responsible to init a plugin based on SNMP.

She will provides new attributes and methods in order to query a host using SNMP.

If you show the help with --help, you will see extra arguments provided by the class. It uses the same mechanics as we saw in Creating a new plugin, the basics section. It overrides NagiosPlugin.define_plugin_arguments() to define new arguments and NagiosPlugin.verify_plugin_arguments() to do arguments checking.

Getting started

import logging
from monitoring.nagios.plugin import NagiosPluginSNMP

logger = logging.getLogger('plugin')

oids = {
    'descr': '1.3.6.1.2.1.1.1.0',
    'contact': '1.3.6.1.2.1.1.4.0',
}

plugin = NagiosPluginSNMP(version="1.0", description="Get the system description and contact")
snmpquery = plugin.snmp.get(oids)

print "Descr: ", snmpquery['descr']
print "Contact: ", snmpquery['contact']

plugin is a NagiosPluginSNMP instance.

NagiosPluginSNMP.snmp

Instance of ProbeSNMP. Use get() and pass it a dict with a name for your OID as the key and the OID string as the value. You can check for many OIDs as you want, just add their names and the OID string to the dict.

The get() method returns a dict represented by snmpquery with key as the name you defined and as the value it will be the result of the SNMP get query. For example here, the value of OID SysDescr (1.3.6.1.2.1.1.1) is available with snmpquery['descr'].