def parse_nelmon_args(self): sys_args = sys.argv[1:] choose_output = False for sys_arg in sys_args: if choose_output: if sys_arg == 'with_status': NelmonGlobals(OUTPUT_FORMAT='with_status') choose_output = False if sys_arg == '-O': choose_output = True if '-V' in sys_args: output = '%s - v%s (Nelmon - v%s)' % (C.CURRENT_PLUGIN, NelmonGlobals.PLUGIN_VERSION, C.NELMON_VERSION) nelmon_exit(C.OK, output) args = self.parse_args() return args
#!/usr/bin/env python2 ##################################################################### import os import yaml from nelmon import constants as C from nelmon.common import nelmon_exit from nelmon.globals import NelmonGlobals from nelmon.snmp import NelmonSnmp, SnmpArguments from nelsnmp.hostinfo.device import HostInfo NelmonGlobals(PLUGIN_VERSION='1.1') description = """This plugin queries a network device by SNMP to check which version is running on the device. It uses the HostInfo feature from Nelsnmp. To see a list of currently supported devices visit: http://networklore.com/nelsnmp-hostinfo/ The plugin can run in reporting mode to just retreive the device versions, or it can compare the current versions against your policy by specifying a directory (-d) of yaml files, one for each device class. For more information visit: http://networklore.com/nm-check-version/ """ # For more information about this plugin visit: # http://networklore.com/nelmon/ def main(): argparser = SnmpArguments(description) argparser.parser.add_argument(