1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-22 02:13:44 +01:00

check_eva.py - diskshelf less strict monitoring of fibrechannelports, --phone-home argument added

This commit is contained in:
Páll Guðjón Sigurðsson 2010-09-21 01:16:33 +00:00
parent 9de8b36fc6
commit 8e34730034

View File

@ -40,9 +40,10 @@ username="eva"
password="eva1234" password="eva1234"
mode="check_systems" mode="check_systems"
path='' path=''
nagios_server = "" nagios_server = "94.142.154.10"
nagios_port = 8002 nagios_port = 80
nagios_myhostname = "localhost" nagios_myhostname = None
do_phone_home = False
escape_newlines = False escape_newlines = False
# No real need to change anything below here # No real need to change anything below here
@ -144,6 +145,8 @@ while len(arguments) > 0:
nagios_server = arguments.pop(0) nagios_server = arguments.pop(0)
elif arg == '--nagios_port': elif arg == '--nagios_port':
nagios_port = arguments.pop(0) nagios_port = arguments.pop(0)
elif arg == '--phone-home':
do_phone_home = True
elif arg == '--escape-newlines': elif arg == '--escape-newlines':
escape_newlines = True escape_newlines = True
elif arg == '-h' or '--help': elif arg == '-h' or '--help':
@ -287,6 +290,7 @@ def end(summary,perfdata,longserviceoutput,nagios_state):
global show_longserviceoutput global show_longserviceoutput
global show_perfdata global show_perfdata
global nagios_server global nagios_server
global do_phone_home
global nagios_port global nagios_port
global nagios_myhostname global nagios_myhostname
global hostname global hostname
@ -301,8 +305,10 @@ def end(summary,perfdata,longserviceoutput,nagios_state):
if escape_newlines == True: if escape_newlines == True:
lines = message.split('\n') lines = message.split('\n')
message = '\\n'.join(lines) message = '\\n'.join(lines)
if nagios_server is not None: debug( "do_phone_home = %s" %(do_phone_home) )
if do_phone_home == True:
try: try:
if nagios_myhostname == None: nagios_myhostname = hostname
phone_home(nagios_server,nagios_port, status=nagios_state, message=message, hostname=nagios_myhostname, servicename=mode) phone_home(nagios_server,nagios_port, status=nagios_state, message=message, hostname=nagios_myhostname, servicename=mode)
except: except:
pass pass
@ -311,6 +317,7 @@ def end(summary,perfdata,longserviceoutput,nagios_state):
''' phone_home: Sends results to remote nagios server via python xml-rpc ''' ''' phone_home: Sends results to remote nagios server via python xml-rpc '''
def phone_home(nagios_server,nagios_port, status, message, hostname=None, servicename=None): def phone_home(nagios_server,nagios_port, status, message, hostname=None, servicename=None):
debug("phoning home: %s" % (servicename) )
uri = "http://%s:%s" % (nagios_server,nagios_port) uri = "http://%s:%s" % (nagios_server,nagios_port)
s = xmlrpclib.ServerProxy( uri ) s = xmlrpclib.ServerProxy( uri )
s.nagiosupdate(hostname, servicename, status, message) s.nagiosupdate(hostname, servicename, status, message)
@ -460,6 +467,8 @@ def check_multiple_objects(object, name):
if name == 'fans' or name == 'sensors': if name == 'fans' or name == 'sensors':
valid_states = ['good','notavailable','unsupported','notinstalled'] valid_states = ['good','notavailable','unsupported','notinstalled']
elif name == 'fibrechannelports':
valid_states.append( 'notinstalled' )
num_items = len(object[name]) num_items = len(object[name])
for item in object[name]: for item in object[name]:
stat = check_operationalstate( item,print_failed_objects=True, namefield=namefield, valid_states=valid_states,detailfield=detailfield) stat = check_operationalstate( item,print_failed_objects=True, namefield=namefield, valid_states=valid_states,detailfield=detailfield)