helper.parser.add_option( '-t', '--type', dest='power_Status', help='Select a Type, for a list of all possible Types use the argument -l') helper.parser.add_option('-l', '--list', dest='listFlag', default='False', action='store_true', help='Lists all output possibilities') helper.parse_arguments() status = helper.options.power_Status flag_list = helper.options.listFlag host, version, community = get_common_options(helper) basicoid = '.1.3.6.1.4.1.34278.' output = [] oid = [ '1.1.0', '1.2.0', '1.3.0', '1.7.0', '1.8.0', '1.9.0', '1.10.0', '1.11.0', '1.12.0', '1.13.0', '1.14.0', '1.15.0', '1.16.0', '1.17.0', '1.18.0', '1.19.0', '1.20.0', '1.21.0', '1.22.0', '1.23.0', '1.24.0', '2.1.0', '2.2.0', '2.3.0', '1.4.0', '1.5.0', '1.6.0' ] names = [ 'uL1', 'uL2', 'uL3', 'iL1', 'iL2', 'iL3', 'iL4', 'iL5', 'iL6', 'pL1', 'pL2', 'pL3', 'qL1', 'qL2', 'qL3', 'sL1', 'sL2', 'sL3', 'cosPL1', 'cosPL2', 'cosPL3', 'p3', 'q3', 's3', 'uL1L2', 'uL2L3', 'uL3L1'
from snmpSessionBaseClass import add_common_options, get_common_options, verify_host, attempt_get_data, walk_data from pynag.Plugins import PluginHelper,ok,critical # Create an instance of PluginHelper() helper = PluginHelper() # Add command line parameters add_common_options(helper) helper.parser.add_option('-s', '--service', help="The name of the service you want to monitor (-s scan for scanning)", dest="service", default='') helper.parser.add_option('-S', '--scan', dest = 'scan_flag', default = False, action = "store_true", help = 'Show all available services') helper.parse_arguments() # get the options host, version, community = get_common_options(helper) service = helper.options.service scan = helper.options.scan_flag # that is the base id base_oid = ".1.3.6.1.4.1.77.1.2.3.1.1" ''' # for check_snmp_service we need to adapt the service_get_data function def service_get_data(sess, host, version, community, oid): var = netsnmp.Varbind(oid) data = netsnmp.snmpget(var, Version=version, DestHost=host, Community=community) value = data[0] return value '''
if a_helper.options.type: a_helper.options.type = a_helper.options.type.lower() return a_helper if __name__ == "__main__": a_helper = setup_plugin_helper() secname, seclevel, authproto, authpass, privproto, privpass = a_helper.options.secname, \ a_helper.options.seclevel, \ a_helper.options.authproto, \ a_helper.options.authpass, \ a_helper.options.privproto, \ a_helper.options.privpass host, version, community = snmpSessionBaseClass.get_common_options(a_helper) snmpSessionBaseClass.verify_host(host, a_helper) verify_type(a_helper.options.type, a_helper) snmp_session = netsnmp.Session(Version=version, DestHost=host, SecLevel=seclevel, SecName=secname, AuthProto=authproto, AuthPass=authpass, PrivProto=privproto, PrivPass=privpass, Community=community) # The default return value should be always OK a_helper.status(pynag.Plugins.ok) eaton_check = eaton_check_configs[a_helper.options.type]["check"] eaton_oid = eaton_check_configs[a_helper.options.type]["oid"] allow_empty = eaton_check_configs[a_helper.options.type].get("allow_snmp_empty", False)
a_helper.parse_arguments() return a_helper if __name__ == "__main__": a_helper = setup_plugin_helper() secname, seclevel, authproto, authpass, privproto, privpass = a_helper.options.secname, \ a_helper.options.seclevel, \ a_helper.options.authproto, \ a_helper.options.authpass, \ a_helper.options.privproto, \ a_helper.options.privpass host, version, community = snmpSessionBaseClass.get_common_options( a_helper) snmpSessionBaseClass.verify_host(host, a_helper) verify_type(a_helper.options.type, a_helper) snmp_session = netsnmp.Session(Version=version, DestHost=host, SecLevel=seclevel, SecName=secname, AuthProto=authproto, AuthPass=authpass, PrivProto=privproto, PrivPass=privpass, Community=community) # The default return value should be always OK