mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-22 02:13:44 +01:00
This commit is contained in:
parent
0f99d2b5e6
commit
0cd2359f2f
Binary file not shown.
Binary file not shown.
@ -40,6 +40,10 @@ username="eva"
|
||||
password="eva1234"
|
||||
mode="check_systems"
|
||||
path=''
|
||||
nagios_server = ""
|
||||
nagios_port = 8002
|
||||
nagios_myhostname = "localhost"
|
||||
escape_newlines = False
|
||||
|
||||
# No real need to change anything below here
|
||||
version="1.0"
|
||||
@ -67,9 +71,13 @@ from sys import exit
|
||||
from sys import argv
|
||||
from os import getenv,putenv
|
||||
import subprocess
|
||||
import xmlrpclib
|
||||
import socket
|
||||
socket.setdefaulttimeout(5)
|
||||
|
||||
|
||||
def print_help():
|
||||
print broken
|
||||
print "check_eva version %s" % version
|
||||
print "This plugin checks HP EVA Array with the sssu command"
|
||||
print ""
|
||||
@ -131,6 +139,14 @@ while len(arguments) > 0:
|
||||
show_perfdata = True
|
||||
elif arg == '--no-perfdata':
|
||||
show_perfdata = False
|
||||
elif arg == '--nagios_myhostname':
|
||||
nagios_myhostname = arguments.pop(0)
|
||||
elif arg == '--nagios_server':
|
||||
nagios_server = arguments.pop(0)
|
||||
elif arg == '--nagiosport':
|
||||
nagios_port = arguments.pop(0)
|
||||
elif arg == '--escape-newlines':
|
||||
escape_newlines = True
|
||||
elif arg == '-h' or '--help':
|
||||
print_help()
|
||||
exit(ok)
|
||||
@ -271,12 +287,36 @@ def run_sssu(system=None, command="ls system full"):
|
||||
def end(summary,perfdata,longserviceoutput,nagios_state):
|
||||
global show_longserviceoutput
|
||||
global show_perfdata
|
||||
if not show_perfdata: perfdata = ""
|
||||
print "%s - %s | %s" % (state[nagios_state], summary,perfdata)
|
||||
global nagios_server
|
||||
global nagios_port
|
||||
global nagios_myhostname
|
||||
global hostname
|
||||
global mode
|
||||
global escape_newlines
|
||||
|
||||
message = "%s - %s" % ( state[nagios_state], summary)
|
||||
if show_perfdata:
|
||||
message = "%s | %s" % ( message, perfdata)
|
||||
if show_longserviceoutput:
|
||||
print longserviceoutput
|
||||
message = "%s\n%s" % ( message, longserviceoutput.strip())
|
||||
if escape_newlines == True:
|
||||
lines = message.split('\n')
|
||||
message = '\\n'.join(lines)
|
||||
if nagios_server is not None:
|
||||
try:
|
||||
phone_home(nagios_server,nagios_port, status=nagios_state, message=message, hostname=nagios_myhostname, servicename=mode)
|
||||
except:
|
||||
pass
|
||||
print message
|
||||
exit(nagios_state)
|
||||
|
||||
''' 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):
|
||||
uri = "http://%s:%s" % (nagios_server,nagios_port)
|
||||
s = xmlrpclib.ServerProxy( uri )
|
||||
s.nagiosupdate(hostname, servicename, status, message)
|
||||
return 0
|
||||
|
||||
def check_systems():
|
||||
summary=""
|
||||
perfdata=""
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user