mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-22 02:13:44 +01:00
check_eva - fix mixed tab/spaces
This commit is contained in:
parent
ec2973e743
commit
ceb039eb45
@ -179,16 +179,16 @@ subitems['port'] = 'fibrechannelports'
|
|||||||
|
|
||||||
'''runCommand: Runs command from the shell prompt. Exit Nagios style if unsuccessful'''
|
'''runCommand: Runs command from the shell prompt. Exit Nagios style if unsuccessful'''
|
||||||
def runCommand(command):
|
def runCommand(command):
|
||||||
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE,)
|
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,stderr=subprocess.PIPE,)
|
||||||
stdout, stderr = proc.communicate('through stdin to stdout')
|
stdout, stderr = proc.communicate('through stdin to stdout')
|
||||||
if proc.returncode > 0:
|
if proc.returncode > 0:
|
||||||
print "Error %s: %s\n command was: '%s'" % (proc.returncode,stderr.strip(),command)
|
print "Error %s: %s\n command was: '%s'" % (proc.returncode,stderr.strip(),command)
|
||||||
if proc.returncode == 127 or proc.returncode == 1: # File not found, lets print path
|
if proc.returncode == 127 or proc.returncode == 1: # File not found, lets print path
|
||||||
path=getenv("PATH")
|
path=getenv("PATH")
|
||||||
print "Current Path: %s" % (path)
|
print "Current Path: %s" % (path)
|
||||||
exit(unknown)
|
exit(unknown)
|
||||||
else:
|
else:
|
||||||
return stdout
|
return stdout
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -341,16 +341,16 @@ def end(summary,perfdata,longserviceoutput,nagios_state):
|
|||||||
print message
|
print message
|
||||||
exit(nagios_state)
|
exit(nagios_state)
|
||||||
class ProxiedTransport(xmlrpclib.Transport):
|
class ProxiedTransport(xmlrpclib.Transport):
|
||||||
def set_proxy(self, proxy):
|
def set_proxy(self, proxy):
|
||||||
self.proxy = proxy
|
self.proxy = proxy
|
||||||
def make_connection(self, host):
|
def make_connection(self, host):
|
||||||
self.realhost = host
|
self.realhost = host
|
||||||
h = httplib.HTTP(self.proxy)
|
h = httplib.HTTP(self.proxy)
|
||||||
return h
|
return h
|
||||||
def send_request(self, connection, handler, request_body):
|
def send_request(self, connection, handler, request_body):
|
||||||
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
|
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
|
||||||
def send_host(self, connection, host):
|
def send_host(self, connection, host):
|
||||||
connection.putheader('Host', self.realhost)
|
connection.putheader('Host', self.realhost)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -435,30 +435,29 @@ def check_operationalstate(object, print_failed_objects=False,namefield='objectn
|
|||||||
|
|
||||||
|
|
||||||
def check_generic(command="ls disk full",namefield="objectname", perfdata_fields=[], longserviceoutputfields=[], detailedsummary=False):
|
def check_generic(command="ls disk full",namefield="objectname", perfdata_fields=[], longserviceoutputfields=[], detailedsummary=False):
|
||||||
summary=""
|
summary=""
|
||||||
global perfdata
|
global perfdata
|
||||||
nagios_state = ok
|
nagios_state = ok
|
||||||
systems = run_sssu()
|
systems = run_sssu()
|
||||||
objects = []
|
objects = []
|
||||||
if command == 'ls system full':
|
if command == 'ls system full':
|
||||||
objects = systems
|
objects = systems
|
||||||
for i in systems: i['systemname'] = '' #i['objectname']
|
for i in systems: i['systemname'] = '' #i['objectname']
|
||||||
else:
|
else:
|
||||||
for i in systems:
|
for i in systems:
|
||||||
result = run_sssu(system=i['objectname'], command=command)
|
result = run_sssu(system=i['objectname'], command=command)
|
||||||
for x in result:
|
for x in result:
|
||||||
x['systemname'] = i['objectname']
|
x['systemname'] = i['objectname']
|
||||||
objects.append( x )
|
objects.append( x )
|
||||||
summary = "%s objects found " % len(objects)
|
summary = "%s objects found " % len(objects)
|
||||||
for i in objects:
|
for i in objects:
|
||||||
systemname = i['systemname']
|
systemname = i['systemname']
|
||||||
|
|
||||||
# Some versions of commandview use "objectname" instead of namefield
|
# Some versions of commandview use "objectname" instead of namefield
|
||||||
if i.has_key( namefield ):
|
if i.has_key( namefield ):
|
||||||
objectname = i[namefield]
|
objectname = i[namefield]
|
||||||
else:
|
else:
|
||||||
objectname = i['objectname']
|
objectname = i['objectname']
|
||||||
# Some versions of CV also return garbage objects, luckily it is easy to find these
|
# Some versions of CV also return garbage objects, luckily it is easy to find these
|
||||||
if i.has_key('objecttype') and i['objecttype'] == 'typenotset':
|
if i.has_key('objecttype') and i['objecttype'] == 'typenotset':
|
||||||
long("Object %s was skipped because objecttype == typenotset\n" % objectname )
|
long("Object %s was skipped because objecttype == typenotset\n" % objectname )
|
||||||
continue
|
continue
|
||||||
@ -468,10 +467,10 @@ def check_generic(command="ls disk full",namefield="objectname", perfdata_fields
|
|||||||
|
|
||||||
# Lets add to the summary
|
# Lets add to the summary
|
||||||
if i['operationalstate'] != 'good' or detailedsummary == True:
|
if i['operationalstate'] != 'good' or detailedsummary == True:
|
||||||
summary = summary + " %s/%s=%s " %(systemname,objectname, i['operationalstate'])
|
summary = summary + " %s/%s=%s " %(systemname,objectname, i['operationalstate'])
|
||||||
|
|
||||||
# Lets get some perfdata
|
# Lets get some perfdata
|
||||||
identifier = "%s/%s_" % (systemname,objectname)
|
identifier = "%s/%s_" % (systemname,objectname)
|
||||||
i['identifier'] = identifier
|
i['identifier'] = identifier
|
||||||
|
|
||||||
|
|
||||||
@ -487,7 +486,7 @@ def check_generic(command="ls disk full",namefield="objectname", perfdata_fields
|
|||||||
warninggb= totalstoragespacegb * occupancyalarmlvel / 100
|
warninggb= totalstoragespacegb * occupancyalarmlvel / 100
|
||||||
add_perfdata( " '%sdiskusage'=%s;%s;%s "% (identifier, usedstoragespacegb,warninggb,totalstoragespacegb) )
|
add_perfdata( " '%sdiskusage'=%s;%s;%s "% (identifier, usedstoragespacegb,warninggb,totalstoragespacegb) )
|
||||||
|
|
||||||
# Long Serviceoutput
|
# Long Serviceoutput
|
||||||
|
|
||||||
# There are usually to many disks for nagios to display. Skip.
|
# There are usually to many disks for nagios to display. Skip.
|
||||||
if command != "ls disk full":
|
if command != "ls disk full":
|
||||||
@ -510,11 +509,11 @@ def check_generic(command="ls disk full",namefield="objectname", perfdata_fields
|
|||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'communicationbuses'))
|
nagios_state = max(nagios_state, check_multiple_objects(i, 'communicationbuses'))
|
||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'fibrechannelports'))
|
nagios_state = max(nagios_state, check_multiple_objects(i, 'fibrechannelports'))
|
||||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'modules'))
|
nagios_state = max(nagios_state, check_multiple_objects(i, 'modules'))
|
||||||
for x in longserviceoutputfields:
|
for x in longserviceoutputfields:
|
||||||
if i.has_key( x ):
|
if i.has_key( x ):
|
||||||
long( "- %s = %s\n" % (x, i[x]))
|
long( "- %s = %s\n" % (x, i[x]))
|
||||||
|
|
||||||
end(summary,perfdata,longserviceoutput,nagios_state)
|
end(summary,perfdata,longserviceoutput,nagios_state)
|
||||||
|
|
||||||
def check_multiple_objects(object, name):
|
def check_multiple_objects(object, name):
|
||||||
item_status = not_present
|
item_status = not_present
|
||||||
@ -661,18 +660,17 @@ def set_path():
|
|||||||
else:
|
else:
|
||||||
path = ":/usr/local/bin"
|
path = ":/usr/local/bin"
|
||||||
current_path = "%s%s" % (current_path,path)
|
current_path = "%s%s" % (current_path,path)
|
||||||
environ['PATH'] = current_path
|
environ['PATH'] = current_path
|
||||||
set_path()
|
set_path()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if mode == 'check_systems':
|
if mode == 'check_systems':
|
||||||
perfdata_fields = 'totalstoragespace usedstoragespace availablestoragespace'.split()
|
perfdata_fields = 'totalstoragespace usedstoragespace availablestoragespace'.split()
|
||||||
longserviceoutputfields = 'licensestate systemtype firmwareversion nscfwversion totalstoragespace usedstoragespace availablestoragespace'.split()
|
longserviceoutputfields = 'licensestate systemtype firmwareversion nscfwversion totalstoragespace usedstoragespace availablestoragespace'.split()
|
||||||
command = "ls system full"
|
command = "ls system full"
|
||||||
namefield="objectname"
|
namefield="objectname"
|
||||||
check_generic(command=command,namefield=namefield,longserviceoutputfields=longserviceoutputfields, perfdata_fields=perfdata_fields)
|
check_generic(command=command,namefield=namefield,longserviceoutputfields=longserviceoutputfields, perfdata_fields=perfdata_fields)
|
||||||
#check_systems
|
|
||||||
elif mode == 'check_controllers':
|
elif mode == 'check_controllers':
|
||||||
check_controllers()
|
check_controllers()
|
||||||
elif mode == 'check_diskgroups':
|
elif mode == 'check_diskgroups':
|
||||||
@ -684,7 +682,7 @@ elif mode == 'check_diskgroups':
|
|||||||
elif mode == 'check_disks':
|
elif mode == 'check_disks':
|
||||||
check_generic(command="ls disk full",namefield="objectname")
|
check_generic(command="ls disk full",namefield="objectname")
|
||||||
elif mode == 'check_diskshelfs' or mode == 'check_diskshelves':
|
elif mode == 'check_diskshelfs' or mode == 'check_diskshelves':
|
||||||
check_generic(command="ls diskshelf full",namefield="diskshelfname",longserviceoutputfields=[], perfdata_fields=[])
|
check_generic(command="ls diskshelf full",namefield="diskshelfname",longserviceoutputfields=[], perfdata_fields=[])
|
||||||
else:
|
else:
|
||||||
print "* Error: Mode %s not found" % mode
|
print "* Error: Mode %s not found" % mode
|
||||||
print_help()
|
print_help()
|
||||||
|
Loading…
Reference in New Issue
Block a user