mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-22 02:13:44 +01:00
PEP8 cleanup
This commit is contained in:
parent
39f2413957
commit
9907356c39
@ -23,17 +23,12 @@
|
||||
# binaries for Windows and Linux
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Some Defaults
|
||||
show_perfdata = True
|
||||
show_longserviceoutput = True
|
||||
debugging = False
|
||||
|
||||
|
||||
|
||||
# check_eva defaults
|
||||
hostname = "localhost"
|
||||
username = "eva"
|
||||
@ -48,7 +43,8 @@ escape_newlines = False
|
||||
check_system = None # By default check all systems
|
||||
proxyserver = None
|
||||
|
||||
server_side_troubleshooting = False # set to true, if you do not have sssu binary handy
|
||||
# set to true, if you do not have sssu binary handy
|
||||
server_side_troubleshooting = False
|
||||
|
||||
# No real need to change anything below here
|
||||
version = "1.0"
|
||||
@ -59,7 +55,6 @@ unknown=3
|
||||
not_present = -1
|
||||
|
||||
|
||||
|
||||
state = {}
|
||||
state[not_present] = "Not Present"
|
||||
state[ok] = "OK"
|
||||
@ -70,13 +65,15 @@ state[unknown] = "Unknown"
|
||||
longserviceoutput = "\n"
|
||||
perfdata = ""
|
||||
|
||||
valid_modes = ( "check_systems", "check_controllers", "check_diskgroups","check_disks", "check_diskshelfs", "check_diskshelves")
|
||||
valid_modes = ("check_systems", "check_controllers", "check_diskgroups",
|
||||
"check_disks", "check_diskshelfs", "check_diskshelves")
|
||||
|
||||
from sys import exit
|
||||
from sys import argv
|
||||
from os import getenv, putenv, environ
|
||||
import subprocess
|
||||
import xmlrpclib,httplib
|
||||
import xmlrpclib
|
||||
import httplib
|
||||
import socket
|
||||
socket.setdefaulttimeout(5)
|
||||
|
||||
@ -107,6 +104,7 @@ def error(errortext):
|
||||
print "* Error: %s" % errortext
|
||||
exit(unknown)
|
||||
|
||||
|
||||
def debug(debugtext):
|
||||
global debugging
|
||||
if debugging:
|
||||
@ -164,8 +162,6 @@ while len(arguments) > 0:
|
||||
error("Invalid argument %s" % arg)
|
||||
|
||||
|
||||
|
||||
|
||||
subitems = {}
|
||||
subitems['fan'] = 'fans'
|
||||
subitems['source'] = 'powersources'
|
||||
@ -177,14 +173,15 @@ subitems['bus'] = 'communicationbuses'
|
||||
subitems['port'] = 'fibrechannelports'
|
||||
|
||||
|
||||
|
||||
def runCommand(command):
|
||||
""" runCommand: Runs command from the shell prompt. Exit Nagios style if unsuccessful """
|
||||
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')
|
||||
if proc.returncode > 0:
|
||||
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
|
||||
# File not found, lets print path
|
||||
if proc.returncode == 127 or proc.returncode == 1:
|
||||
path = getenv("PATH")
|
||||
print "Current Path: %s" % path
|
||||
exit(unknown)
|
||||
@ -192,14 +189,13 @@ def runCommand(command):
|
||||
return stdout
|
||||
|
||||
|
||||
|
||||
|
||||
def run_sssu(system=None, command="ls system full"):
|
||||
"""Runs the sssu command. This one is responsible for error checking from sssu"""
|
||||
commands = []
|
||||
|
||||
continue_on_error = "set option on_error=continue"
|
||||
login="select manager %s USERNAME=%s PASSWORD=%s"%(hostname,username,password)
|
||||
login = "select manager %s USERNAME=%s PASSWORD=%s" % (
|
||||
hostname, username, password)
|
||||
|
||||
commands.append(continue_on_error)
|
||||
commands.append(login)
|
||||
@ -229,14 +225,21 @@ def run_sssu(system=None, command="ls system full"):
|
||||
|
||||
output = output.split('\n')
|
||||
|
||||
# Lets process the top few results from the sssu command. Make sure the results make sense
|
||||
# Lets process the top few results from the sssu command. Make sure the
|
||||
# results make sense
|
||||
error = 0
|
||||
if output.pop(0).strip() != '': error = 1
|
||||
if output.pop(0).strip() != '': error = 1
|
||||
if output.pop(0).strip() != 'SSSU for HP StorageWorks Command View EVA': error = 1
|
||||
if output.pop(0).strip().find('Version:') != 0: error=1
|
||||
if output.pop(0).strip().find('Build:') != 0: error=1
|
||||
if output.pop(0).strip().find('NoSystemSelected> ') != 0: error=1
|
||||
if output.pop(0).strip() != '':
|
||||
error = 1
|
||||
if output.pop(0).strip() != '':
|
||||
error = 1
|
||||
if output.pop(0).strip() != 'SSSU for HP StorageWorks Command View EVA':
|
||||
error = 1
|
||||
if output.pop(0).strip().find('Version:') != 0:
|
||||
error = 1
|
||||
if output.pop(0).strip().find('Build:') != 0:
|
||||
error = 1
|
||||
if output.pop(0).strip().find('NoSystemSelected> ') != 0:
|
||||
error = 1
|
||||
#if output.pop(0).strip() != '': error = 1
|
||||
#if output.pop(0).strip().find('NoSystemSelected> ') != 0: error=1
|
||||
#if output.pop(0).strip() != '': error = 1
|
||||
@ -246,7 +249,8 @@ def run_sssu(system=None, command="ls system full"):
|
||||
if i.find('Error') > -1:
|
||||
print "This is the command i was trying to execute: %s" % i
|
||||
error = 1
|
||||
if i.find('information:') > 0: break
|
||||
if i.find('information:') > 0:
|
||||
break
|
||||
if error > 0:
|
||||
print "Error running the sssu command"
|
||||
print commandstring
|
||||
@ -261,11 +265,13 @@ def run_sssu(system=None, command="ls system full"):
|
||||
tmp = line.split()
|
||||
if len(tmp) == 0:
|
||||
if current_object:
|
||||
if not current_object['master'] in objects: objects.append( current_object['master'] )
|
||||
if not current_object['master'] in objects:
|
||||
objects.append(current_object['master'])
|
||||
current_object = None
|
||||
continue
|
||||
key = tmp[0].strip()
|
||||
if current_object and not current_object['master'] in objects: objects.append( current_object['master'] )
|
||||
if current_object and not current_object['master'] in objects:
|
||||
objects.append(current_object['master'])
|
||||
if key == 'object':
|
||||
current_object = {}
|
||||
current_object['master'] = current_object
|
||||
@ -285,8 +291,6 @@ def run_sssu(system=None, command="ls system full"):
|
||||
current_object['master'][mastergroup] = []
|
||||
current_object['master'][mastergroup].append(current_object)
|
||||
|
||||
|
||||
|
||||
if line.find('.:') > 0:
|
||||
# We work on first come, first serve basis, so if
|
||||
# we accidentally see same key again, we will ignore
|
||||
@ -303,6 +307,7 @@ def run_sssu(system=None, command="ls system full"):
|
||||
objects = tmp_objects
|
||||
return objects
|
||||
|
||||
|
||||
def end(summary, perfdata, longserviceoutput, nagios_state):
|
||||
global show_longserviceoutput
|
||||
global show_perfdata
|
||||
@ -349,20 +354,25 @@ def end(summary,perfdata,longserviceoutput,nagios_state):
|
||||
raise
|
||||
print message
|
||||
exit(nagios_state)
|
||||
|
||||
|
||||
class ProxiedTransport(xmlrpclib.Transport):
|
||||
|
||||
def set_proxy(self, proxy):
|
||||
self.proxy = proxy
|
||||
|
||||
def make_connection(self, host):
|
||||
self.realhost = host
|
||||
h = httplib.HTTP(self.proxy)
|
||||
return h
|
||||
|
||||
def send_request(self, connection, handler, request_body):
|
||||
connection.putrequest("POST", 'http://%s%s' % (self.realhost, handler))
|
||||
|
||||
def send_host(self, connection, host):
|
||||
connection.putheader('Host', self.realhost)
|
||||
|
||||
|
||||
|
||||
def phone_home(nagios_server, nagios_port, status, message, hostname=None, servicename=None, system=None):
|
||||
"""phone_home: Sends results to remote nagios server via python xml-rpc"""
|
||||
debug("phoning home: %s" % servicename)
|
||||
@ -380,6 +390,7 @@ def phone_home(nagios_server,nagios_port, status, message, hostname=None, servic
|
||||
s.nagiosupdate(hostname, servicename, status, message)
|
||||
return 0
|
||||
|
||||
|
||||
def check_systems():
|
||||
summary = ""
|
||||
perfdata = ""
|
||||
@ -396,9 +407,11 @@ def check_systems():
|
||||
summary += " %s=%s " % (name, operationalstate)
|
||||
# Collect the performance data
|
||||
interesting_perfdata = 'totalstoragespace|usedstoragespace|availablestoragespace'
|
||||
perfdata += get_perfdata(i, interesting_perfdata.split('|'), identifier="%s_" % name)
|
||||
perfdata += get_perfdata(
|
||||
i, interesting_perfdata.split('|'), identifier="%s_" % name)
|
||||
# Collect extra info for longserviceoutput
|
||||
longoutput("%s = %s (%s)\n" % ( i['objectname'], i['operationalstate'], i['operationalstatedetail']) )
|
||||
longoutput("%s = %s (%s)\n" %
|
||||
(i['objectname'], i['operationalstate'], i['operationalstatedetail']))
|
||||
interesting_fields = 'licensestate|systemtype|firmwareversion|nscfwversion|totalstoragespace|usedstoragespace|availablestoragespace'
|
||||
for x in interesting_fields.split('|'):
|
||||
longoutput("- %s = %s \n" % (x, i[x]))
|
||||
@ -406,45 +419,53 @@ def check_systems():
|
||||
end(summary, perfdata, longserviceoutput, nagios_state)
|
||||
|
||||
|
||||
|
||||
def get_perfdata(my_object, interesting_fields, identifier=""):
|
||||
perfdata = ""
|
||||
for i in interesting_fields:
|
||||
if i == '': continue
|
||||
if i == '':
|
||||
continue
|
||||
perfdata += "'%s%s'=%s " % (identifier, i, my_object[i])
|
||||
return perfdata
|
||||
|
||||
|
||||
def add_perfdata(text):
|
||||
global perfdata
|
||||
text = text.strip()
|
||||
perfdata += " %s " % text
|
||||
|
||||
|
||||
def longoutput(text):
|
||||
global longserviceoutput
|
||||
longserviceoutput = longserviceoutput + text
|
||||
|
||||
|
||||
def get_longserviceoutput(my_object, interesting_fields):
|
||||
longserviceoutput = ""
|
||||
for i in interesting_fields:
|
||||
longserviceoutput += "%s = %s \n" % (i, my_object[i])
|
||||
return longserviceoutput
|
||||
|
||||
|
||||
def check_operationalstate(my_object, print_failed_objects=False, namefield='objectname', detailfield='operationalstatedetail', statefield='operationalstate', valid_states=None):
|
||||
if not valid_states:
|
||||
valid_states = ['good']
|
||||
if not my_object.has_key(detailfield): detailfield = statefield
|
||||
if not my_object.has_key(detailfield):
|
||||
detailfield = statefield
|
||||
if not my_object.has_key(statefield):
|
||||
if print_failed_objects:
|
||||
longoutput("- Warning, %s does not have any '%s'" % ( my_object[namefield], statefield ) )
|
||||
longoutput("- Warning, %s does not have any '%s'" %
|
||||
(my_object[namefield], statefield))
|
||||
return warning
|
||||
if my_object[statefield] not in valid_states:
|
||||
if print_failed_objects:
|
||||
longoutput("- Warning, %s=%s (%s)\n" % ( my_object[namefield], my_object['operationalstate'], my_object[detailfield] ))
|
||||
longoutput("- Warning, %s=%s (%s)\n" %
|
||||
(my_object[namefield], my_object['operationalstate'], my_object[detailfield]))
|
||||
return warning
|
||||
debug( "OK, %s=%s (%s)\n" % ( my_object[namefield], my_object['operationalstate'], my_object[detailfield] ) )
|
||||
debug("OK, %s=%s (%s)\n" %
|
||||
(my_object[namefield], my_object['operationalstate'], my_object[detailfield]))
|
||||
return ok
|
||||
|
||||
|
||||
|
||||
def check_generic(command="ls disk full", namefield="objectname", perfdata_fields=None, longserviceoutputfields=None, detailedsummary=False):
|
||||
if not perfdata_fields:
|
||||
perfdata_fields = []
|
||||
@ -456,7 +477,8 @@ def check_generic(command="ls disk full",namefield="objectname", perfdata_fields
|
||||
objects = []
|
||||
if command == 'ls system full':
|
||||
objects = systems
|
||||
for i in systems: i['systemname'] = '' #i['objectname']
|
||||
for i in systems:
|
||||
i['systemname'] = '' # i['objectname']
|
||||
else:
|
||||
for i in systems:
|
||||
result = run_sssu(system=i['objectname'], command=command)
|
||||
@ -474,27 +496,29 @@ def check_generic(command="ls disk full",namefield="objectname", perfdata_fields
|
||||
objectname = i[namefield]
|
||||
else:
|
||||
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':
|
||||
longoutput("Object %s was skipped because objecttype == typenotset\n" % objectname )
|
||||
longoutput(
|
||||
"Object %s was skipped because objecttype == typenotset\n" % objectname)
|
||||
continue
|
||||
# Lets see if this object is working
|
||||
nagios_state = max(check_operationalstate(i), nagios_state)
|
||||
|
||||
|
||||
# Lets add to the summary
|
||||
if i['operationalstate'] != 'good' or detailedsummary == True:
|
||||
summary += " %s/%s=%s " % (systemname, objectname, i['operationalstate'])
|
||||
summary += " %s/%s=%s " % (
|
||||
systemname, objectname, i['operationalstate'])
|
||||
|
||||
# Lets get some perfdata
|
||||
identifier = "%s/%s_" % (systemname, objectname)
|
||||
i['identifier'] = identifier
|
||||
|
||||
|
||||
for field in perfdata_fields:
|
||||
if field == '': continue
|
||||
print perfdata_fields
|
||||
add_perfdata( "'%s%s'=%s " % (identifier, field, i.get(field,None) ))
|
||||
if field == '':
|
||||
continue
|
||||
add_perfdata("'%s%s'=%s " %
|
||||
(identifier, field, i.get(field, None)))
|
||||
|
||||
# Disk group gets a special perfdata treatment
|
||||
if command == "ls disk_group full":
|
||||
@ -502,30 +526,39 @@ def check_generic(command="ls disk full",namefield="objectname", perfdata_fields
|
||||
usedstoragespacegb = float(i['usedstoragespacegb'])
|
||||
occupancyalarmlvel = float(i['occupancyalarmlevel'])
|
||||
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
|
||||
|
||||
# There are usually to many disks for nagios to display. Skip.
|
||||
if command != "ls disk full":
|
||||
longoutput( "\n%s/%s = %s (%s)\n"%(systemname,objectname,i['operationalstate'], i['operationalstatedetail']) )
|
||||
longoutput("\n%s/%s = %s (%s)\n" %
|
||||
(systemname, objectname, i['operationalstate'], i['operationalstatedetail']))
|
||||
|
||||
# If diskgroup has a problem because it is over allocated. Lets inform about that
|
||||
# If diskgroup has a problem because it is over allocated. Lets inform
|
||||
# about that
|
||||
if command == "ls disk_group full" and usedstoragespacegb > warninggb:
|
||||
longoutput("- %s - diskgroup usage is over %s%% threshold !\n" % (state[warning], occupancyalarmlvel) )
|
||||
longoutput(
|
||||
"- %s - diskgroup usage is over %s%% threshold !\n" %
|
||||
(state[warning], occupancyalarmlvel))
|
||||
# If a disk has a problem, lets display some extra info on it
|
||||
elif command == "ls disk full" and i['operationalstate'] != 'good':
|
||||
longoutput( "Warning - %s=%s (%s)\n" % (i['diskname'], i['operationalstate'], i['operationalstatedetail'] ))
|
||||
fields="modelnumber firmwareversion serialnumber failurepredicted diskdrivetype".split()
|
||||
longoutput("Warning - %s=%s (%s)\n" %
|
||||
(i['diskname'], i['operationalstate'], i['operationalstatedetail']))
|
||||
fields = "modelnumber firmwareversion serialnumber failurepredicted diskdrivetype".split(
|
||||
)
|
||||
for field in fields:
|
||||
longoutput("- %s = %s\n" % (field, i[field]))
|
||||
|
||||
|
||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'sensors'))
|
||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'fans'))
|
||||
nagios_state = max(nagios_state, check_multiple_objects(i, 'powersupplies'))
|
||||
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, 'powersupplies'))
|
||||
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, 'modules'))
|
||||
for x in longserviceoutputfields:
|
||||
if i.has_key(x):
|
||||
@ -533,6 +566,7 @@ def check_generic(command="ls disk full",namefield="objectname", perfdata_fields
|
||||
|
||||
end(summary, perfdata, longserviceoutput, nagios_state)
|
||||
|
||||
|
||||
def check_multiple_objects(my_object, name):
|
||||
item_status = not_present
|
||||
if my_object.has_key(name):
|
||||
@ -541,22 +575,23 @@ def check_multiple_objects(my_object, name):
|
||||
namefield = "name"
|
||||
detailfield = 'operationalstatedetail'
|
||||
|
||||
|
||||
|
||||
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(my_object[name])
|
||||
for item in my_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)
|
||||
item_status = max(stat, item_status)
|
||||
longoutput('- %s on %s (%s detected)\n'% (state[item_status], name, num_items) )
|
||||
add_perfdata( " '%s%s'=%s" % (my_object['identifier'],name, num_items) )
|
||||
longoutput('- %s on %s (%s detected)\n' %
|
||||
(state[item_status], name, num_items))
|
||||
add_perfdata(" '%s%s'=%s" %
|
||||
(my_object['identifier'], name, num_items))
|
||||
return item_status
|
||||
|
||||
|
||||
|
||||
def check_controllers():
|
||||
perfdata = ""
|
||||
# longserviceoutput="\n"
|
||||
@ -584,21 +619,23 @@ def check_controllers():
|
||||
nagios_state = max(unknown, nagios_state)
|
||||
continue
|
||||
elif i['operationalstate'] != 'good':
|
||||
summary += " %s/%s=%s " % (systemname, controllername, i['operationalstate'])
|
||||
summary += " %s/%s=%s " % (
|
||||
systemname, controllername, i['operationalstate'])
|
||||
|
||||
# Lets get some perfdata
|
||||
interesting_fields = "controllermainmemory"
|
||||
identifier = "%s/%s_" % (systemname, controllername)
|
||||
perfdata += get_perfdata(i, interesting_fields.split('|'), identifier=identifier)
|
||||
perfdata += get_perfdata(
|
||||
i, interesting_fields.split('|'), identifier=identifier)
|
||||
|
||||
# Long Serviceoutput
|
||||
#longserviceoutput = longserviceoutput + get_longserviceoutput(i, interesting_fields.split('|') )
|
||||
#longserviceoutput = longserviceoutput + "\n%s/%s\n"%(systemname,controllername)
|
||||
longoutput( "\n%s/%s = %s (%s)\n"%(systemname,controllername,i['operationalstate'], i['operationalstatedetail']) )
|
||||
longoutput("\n%s/%s = %s (%s)\n" %
|
||||
(systemname, controllername, i['operationalstate'], i['operationalstatedetail']))
|
||||
longoutput("- firmwareversion = %s \n" % (i['firmwareversion']))
|
||||
longoutput("- serialnumber = %s \n" % (i['serialnumber']))
|
||||
|
||||
|
||||
controllertemper1aturestatus = not_present
|
||||
fanstate = not_present
|
||||
hostportstate = not_present
|
||||
@ -619,54 +656,60 @@ def check_controllers():
|
||||
else:
|
||||
controllertemperaturestatus = warning
|
||||
|
||||
|
||||
# Process the subsensors
|
||||
for hostport in i['hostports']:
|
||||
#long(" %s = %s\n" % (hostport['portname'], hostport['operationalstate']))
|
||||
hostportstate = max(hostportstate, ok)
|
||||
if hostport['operationalstate'] != 'good':
|
||||
hostportstate = max(warning, hostport_state)
|
||||
message = "Hostport %s state = %s\n" % (hostport['portname'], hostport['operationalstate'])
|
||||
message = "Hostport %s state = %s\n" % (
|
||||
hostport['portname'], hostport['operationalstate'])
|
||||
longoutput(message)
|
||||
if i.has_key('fans'):
|
||||
for fan in i['fans']:
|
||||
fanstate = max(fanstate, ok)
|
||||
#long(" %s = %s\n" % (fan['fanname'], fan['status']))
|
||||
if fan.has_key('status'): status = fan['status']
|
||||
elif fan.has_key('installstatus'): status = fan['installstatus']
|
||||
if fan.has_key('status'):
|
||||
status = fan['status']
|
||||
elif fan.has_key('installstatus'):
|
||||
status = fan['installstatus']
|
||||
if status != 'normal' and status != 'yes':
|
||||
fanstate = max(warning, fanstate)
|
||||
longoutput("Fan %s status = %s\n" % (fan['fanname'],status))
|
||||
longoutput("Fan %s status = %s\n" %
|
||||
(fan['fanname'], status))
|
||||
if i.has_key('powersources'):
|
||||
for source in i['powersources']:
|
||||
source_state = max(source_state, ok)
|
||||
if not source.has_key('status'): continue
|
||||
if not source.has_key('status'):
|
||||
continue
|
||||
if source['state'] != 'good':
|
||||
source_state = max(warning, source_state)
|
||||
longoutput("Powersource %s status = %s\n" % (source['type'],source['state']))
|
||||
longoutput("Powersource %s status = %s\n" %
|
||||
(source['type'], source['state']))
|
||||
if i.has_key('modules'):
|
||||
for module in i['modules']:
|
||||
module_state = max(module_state, ok)
|
||||
if module['operationalstate'] not in ('good', 'not_present'):
|
||||
module_state = max(warning, module_state)
|
||||
longoutput("Battery Module %s status = %s\n" % (module['name'],module['operationalstate']))
|
||||
|
||||
longoutput("Battery Module %s status = %s\n" %
|
||||
(module['name'], module['operationalstate']))
|
||||
|
||||
for i in (fanstate, hostportstate, sensorstate, source_state, module_state, cache_state, controllertemperaturestatus):
|
||||
nagios_state = max(nagios_state, i)
|
||||
|
||||
longoutput("- %s on fans\n" % (state[fanstate]))
|
||||
longoutput("- %s on cachememory\n" % (state[cache_state]))
|
||||
longoutput("- %s on temperature\n"%( state[controllertemperaturestatus] ) )
|
||||
longoutput("- %s on temperature\n" %
|
||||
(state[controllertemperaturestatus]))
|
||||
longoutput("- %s on hostports\n" % (state[hostportstate]))
|
||||
longoutput("- %s on sensors\n" % (state[sensorstate]))
|
||||
longoutput("- %s on powersupplies\n" % (state[source_state]))
|
||||
longoutput("- %s on batterymodules\n" % (state[module_state]))
|
||||
|
||||
|
||||
longoutput('\n')
|
||||
end(summary, perfdata, longserviceoutput, nagios_state)
|
||||
|
||||
|
||||
def set_path():
|
||||
global path
|
||||
current_path = getenv('PATH')
|
||||
@ -680,25 +723,30 @@ def set_path():
|
||||
set_path()
|
||||
|
||||
|
||||
|
||||
if mode == 'check_systems':
|
||||
perfdata_fields = 'totalstoragespace usedstoragespace availablestoragespace'.split()
|
||||
longserviceoutputfields = 'licensestate systemtype firmwareversion nscfwversion totalstoragespace usedstoragespace availablestoragespace'.split()
|
||||
perfdata_fields = 'totalstoragespace usedstoragespace availablestoragespace'.split(
|
||||
)
|
||||
longserviceoutputfields = 'licensestate systemtype firmwareversion nscfwversion totalstoragespace usedstoragespace availablestoragespace'.split(
|
||||
)
|
||||
command = "ls system full"
|
||||
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)
|
||||
elif mode == 'check_controllers':
|
||||
check_controllers()
|
||||
elif mode == 'check_diskgroups':
|
||||
command = "ls disk_group full"
|
||||
namefield = 'diskgroupname'
|
||||
longserviceoutputfields = "totaldisks levelingstate levelingprogress totalstoragespacegb usedstoragespacegb occupancyalarmlevel".split()
|
||||
longserviceoutputfields = "totaldisks levelingstate levelingprogress totalstoragespacegb usedstoragespacegb occupancyalarmlevel".split(
|
||||
)
|
||||
perfdata_fields = "totaldisks".split()
|
||||
check_generic(command=command,namefield=namefield,longserviceoutputfields=longserviceoutputfields, perfdata_fields=perfdata_fields)
|
||||
check_generic(command=command, namefield=namefield,
|
||||
longserviceoutputfields=longserviceoutputfields, perfdata_fields=perfdata_fields)
|
||||
elif mode == 'check_disks':
|
||||
check_generic(command="ls disk full", namefield="objectname")
|
||||
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:
|
||||
print "* Error: Mode %s not found" % mode
|
||||
print_help()
|
||||
|
Loading…
Reference in New Issue
Block a user