print "==========================\n" print 'Could not find "monitoringplugin.py"!\n' print 'Did you download "%s"' % os.path.basename(sys.argv[0]) print 'without "monitoringplugin.py"?\n' print "Please go back to" print "http://oss.teamix.org/projects/monitoringplugins/ and download it," print "or even better:" print "get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n" sys.exit(127) plugin = MonitoringPlugin( pluginname="check_sensors", tagforstatusline="Sensors", description="Check environment sensors", version="0.2" ) plugin.add_cmdlineoption("-s", "", "sensorid", "(comma separated list of) sensor id(s), no spaces", default=None) plugin.add_cmdlineoption( "-m", "", "maxage", "maximum age of data files (default: 900 seconds/15 minutes)", type="int", default=900 ) plugin.add_cmdlineoption("-p", "", "path", "path to data files", default="/tmp") plugin.add_cmdlineoption("-b", "", "basefilename", "base of sensor file name", default="sensor_") plugin.add_cmdlineoption("-w", "", "tempwarn", "warning thresold for temperature sensors", default=None) plugin.add_cmdlineoption("-c", "", "tempcrit", "critical thresold for temperature sensors", default=None) plugin.add_cmdlineoption("-W", "", "humwarn", "warning thresold for humidity sensors", default=None) plugin.add_cmdlineoption("-C", "", "humcrit", "critical thresold for humidity sensors", default=None) plugin.parse_cmdlineoptions() # No sensor id if not plugin.options.sensorid: plugin.back2nagios(3, "Need at least one sensor id!")
'MINACTLATENCY': ['MINACTSVCLAT', 'MINACTHSTLAT', ], 'AVGPSVLATENCY': ['AVGPSVSVCLAT', 'AVGPSVHSTLAT', ], 'MAXPSVLATENCY': ['MAXPSVSVCLAT', 'MAXPSVHSTLAT', ], 'MINPSVLATENCY': ['MINPSVSVCLAT', 'MINPSVHSTLAT', ], 'AVGLATENCY': ['AVGACTSVCLAT', 'AVGACTHSTLAT', 'AVGPSVSVCLAT', 'AVGPSVHSTLAT', ], 'MAXLATENCY': ['MAXACTSVCLAT', 'MAXACTHSTLAT', 'MAXPSVSVCLAT', 'MAXPSVHSTLAT',], 'MINLATENCY': ['MINACTSVCLAT', 'MINACTHSTLAT', 'MINPSVSVCLAT', 'MINPSVHSTLAT',], 'AVGEXECTIME': ['AVGACTSVCEXT', 'AVGACTHSTEXT', ], 'MAXEXECTIME': ['MAXACTSVCEXT', 'MAXACTHSTEXT', ], 'MINEXECTIME': ['MINACTSVCEXT', 'MINACTHSTEXT', ], 'PERFORMANCE': ['AVGACTSVCLAT', 'AVGPSVSVCLAT', 'AVGACTSVCEXT', 'AVGACTHSTLAT', 'AVGPSVHSTLAT', 'AVGACTHSTEXT', ], 'PEAK': [ 'MAXACTSVCLAT', 'MAXPSVSVCLAT', 'MAXACTSVCEXT', 'MAXACTHSTLAT', 'MAXPSVHSTLAT', 'MAXACTHSTEXT', ], } plugin.add_cmdlineoption('-C', '', 'checks', 'Use built-in checks (predefined lists of variables)', default='') plugin.add_cmdlineoption('-V', '', 'vars', 'List of "nagiostats" variables to check', default='') plugin.add_cmdlineoption('-n', '', 'nagiostats', 'Full path to nagiostat', default='') plugin.add_cmdlineoption('-w', '', 'warn', 'warning thresold', default='') plugin.add_cmdlineoption('-c', '', 'crit', 'warning thresold', default='') plugin.parse_cmdlineoptions() if not plugin.options.nagiostats: plugin.verbose(2, 'Auto-detecting path to "nagiostats"...') for nagiostats in NAGIOSTATSs: if os.path.exists(nagiostats): plugin.options.nagiostats = nagiostats plugin.verbose(2, 'Found it at "%s"' % nagiostats) break
print '==========================' print 'AIKS! Python import error!' print '==========================\n' print 'Could not find "monitoringplugin.py"!\n' print 'Did you download "%s"' % os.path.basename(sys.argv[0]) print 'without "monitoringplugin.py"?\n' print 'Please go back to' print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,' print 'or even better:' print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n' sys.exit(127) plugin = MonitoringPlugin(pluginname='check_apaches', tagforstatusline='APACHE', description='Check Apache workers', version='0.1') plugin.add_cmdlineoption('-H', '', 'host', 'Hostname/IP to check', default='localhost') plugin.add_cmdlineoption('-p', '', 'port', 'port to connect', default=None) plugin.add_cmdlineoption('-P', '', 'proto', 'protocol to use', default='http') plugin.add_cmdlineoption('-u', '', 'url', 'path to "server-status"', default='/server-status') plugin.add_cmdlineoption('-a', '', 'httpauth', 'HTTP Username and Password, separated by ":"') plugin.add_cmdlineoption('-w', '', 'warn', 'warning thresold', default='20') plugin.add_cmdlineoption('-c', '', 'crit', 'warning thresold', default='50') plugin.add_cmdlineoption('', '--statistics', 'statistics', 'Output worker statistics', action='store_true') plugin.parse_cmdlineoptions() if plugin.options.proto not in ['http', 'https']: plugin.back2nagios(3, 'Unknown protocol "' + plugin.options.proto + '"') if not plugin.options.port: if plugin.options.proto == 'https':
print '==========================' print 'AIKS! Python import error!' print '==========================\n' print 'Could not find "monitoringplugin.py"!\n' print 'Did you download "%s"' % os.path.basename(sys.argv[0]) print 'without "monitoringplugin.py"?\n' print 'Please go back to' print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,' print 'or even better:' print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n' sys.exit(127) plugin = MonitoringPlugin(pluginname='check_netconnections', tagforstatusline='NETCONNS', description='Count network connections', version='0.1') plugin.add_cmdlineoption('-p', '', 'port', 'port number', default=None) plugin.add_cmdlineoption('-t', '--tcp', 'tcp', 'count TCP connections (default)', action='store_true') plugin.add_cmdlineoption('-u', '--udp', 'udp', 'count TCP connections', action='store_true') plugin.add_cmdlineoption('-4', '', 'v4', 'count IPv4 connections (default)', action='store_true') plugin.add_cmdlineoption('-6', '', 'v6', 'count IPv6 connections (default)', action='store_true') plugin.add_cmdlineoption('-w', '', 'warn', 'warning thresold', default='20') plugin.add_cmdlineoption('-c', '', 'crit', 'warning thresold', default='50') plugin.parse_cmdlineoptions() # Need a port number if not plugin.options.port: plugin.back2nagios(3, 'No port number specified!') else: plugin.options.port = int(plugin.options.port)
#!/usr/bin/python from monitoringplugin import MonitoringPlugin import fcntl import socket import struct def get_ipv4_address(iface): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl(sock.fileno(), 0x8915, struct.pack('256s', iface[:15]))[20:24]) plugin = MonitoringPlugin(pluginname='check_iface-dns', tagforstatusline='IFACE-DNS', description='Check interface address vs. DNS', version='0.1') plugin.add_cmdlineoption('-i', '', 'iface', 'Interface to get IP from', default='lo') plugin.add_cmdlineoption('-d', '', 'dns', 'DNS object(s) to check, comma separated list', default='localhost') #plugin.add_cmdlineoption('-4', '', 'v4', 'Use IPv4', action='store_true') #plugin.add_cmdlineoption('-6', '', 'v6', 'Use IPv6', action='store_true') plugin.parse_cmdlineoptions() #if not plugin.options.v4 and not plugin.options.v6: # plugin.options.v4 = True # #if plugin.options.v4: # plugin.verbose(1, 'Using IPv4') # #if plugin.options.v6: # plugin.verbose(1, 'Using IPv6')