1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-22 10:23:46 +01:00

Phone home added to check_eva.py

This commit is contained in:
Páll Guðjón Sigurðsson 2010-09-08 16:07:48 +00:00
parent d2cd0974e3
commit 34b497e621
2 changed files with 26 additions and 11 deletions

View File

@ -41,7 +41,8 @@ password="eva1234"
mode="check_systems" mode="check_systems"
path='' path=''
nagios_server = "" nagios_server = ""
nagios_port = None nagios_port = 8002
nagios_myhostname = "localhost"
# No real need to change anything below here # No real need to change anything below here
version="1.0" version="1.0"
@ -69,9 +70,13 @@ from sys import exit
from sys import argv from sys import argv
from os import getenv,putenv from os import getenv,putenv
import subprocess import subprocess
import xmlrpclib
import socket
socket.setdefaulttimeout(5)
def print_help(): def print_help():
print broken
print "check_eva version %s" % version print "check_eva version %s" % version
print "This plugin checks HP EVA Array with the sssu command" print "This plugin checks HP EVA Array with the sssu command"
print "" print ""
@ -133,13 +138,15 @@ while len(arguments) > 0:
show_perfdata = True show_perfdata = True
elif arg == '--no-perfdata': elif arg == '--no-perfdata':
show_perfdata = False show_perfdata = False
elif arg == '-h' or '--help': elif arg == '--nagios_myhostname':
print_help() nagios_myhostname = arguments.pop(0)
exit(ok) elif arg == '--nagios_server':
elif arg == '--nagioserver':
nagios_server = arguments.pop(0) nagios_server = arguments.pop(0)
elif arg == '--nagiosport': elif arg == '--nagiosport':
nagios_port = arguments.pop(0) nagios_port = arguments.pop(0)
elif arg == '-h' or '--help':
print_help()
exit(ok)
else: else:
error( "Invalid argument %s"% arg) error( "Invalid argument %s"% arg)
@ -279,20 +286,29 @@ def end(summary,perfdata,longserviceoutput,nagios_state):
global show_perfdata global show_perfdata
global nagios_server global nagios_server
global nagios_port global nagios_port
global nagios_myhostname
global hostname
global mode
message = "%s - %s" % ( state[nagios_state], summary) message = "%s - %s" % ( state[nagios_state], summary)
if show_perfdata: if show_perfdata:
message = "%s | %s" % ( message, perfdata) message = "%s | %s" % ( message, perfdata)
if show_longserviceoutput: if show_longserviceoutput:
message = "%s\n%s" % ( message, longserviceoutput) message = "%s\n%s" % ( message, longserviceoutput.strip())
if nagios_server is not None: if nagios_server is not None:
pass try:
phone_home(nagios_server,nagios_port, status=nagios_state, message=message, hostname=nagios_myhostname, servicename=mode)
except:
pass
print message print message
exit(nagios_state) exit(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):
pass uri = "http://%s:%s" % (nagios_server,nagios_port)
s = xmlrpclib.ServerProxy( uri )
s.nagiosupdate(hostname, servicename, status, message)
return 0
def check_systems(): def check_systems():
summary="" summary=""

View File

@ -7,10 +7,9 @@
$HOSTNAME=$ARGV[0]; $HOSTNAME=$ARGV[0];
$databases = `/usr/lib/nagios/plugins/check_nrpe -H $HOSTNAME -c listCounterInstances -a "SQLServer:Databases"`; $databases = `/usr/lib/nagios/plugins/check_nrpe -H $HOSTNAME -t 60 -c listCounterInstances -a "SQLServer:Databases"`;
@array1 = split(/\,/, $databases); @array1 = split(/\,/, $databases);
print "$databases ";
#[root@nagios ~]# check_nrpe -H $HOSTNAME -c CheckCounter -a "Counter:Vanskilaskra=\SQLServer:Databases(Vanskilaskra)\Data File(s) Size (KB)"# OK all counters within bounds.|'Vanskilaskra'=30996480;0;0; #[root@nagios ~]# check_nrpe -H $HOSTNAME -c CheckCounter -a "Counter:Vanskilaskra=\SQLServer:Databases(Vanskilaskra)\Data File(s) Size (KB)"# OK all counters within bounds.|'Vanskilaskra'=30996480;0;0;
$num_databases = 0; $num_databases = 0;
@ -21,7 +20,7 @@ foreach $database (@array1)
$database =~ s/^\s*(.*?)\s*$/$1/; $database =~ s/^\s*(.*?)\s*$/$1/;
# Call check_nrpe # Call check_nrpe
$dbSize = `/usr/lib/nagios/plugins/check_nrpe -H $HOSTNAME -c CheckCounter -a 'Counter:$database=\\SQLServer:Databases($database)\\Data File(s) Size (KB)'`; $dbSize = `/usr/lib/nagios/plugins/check_nrpe -H $HOSTNAME -t 60 -c CheckCounter -a 'Counter:$database=\\SQLServer:Databases($database)\\Data File(s) Size (KB)'`;
# Strip everything but the performance data # Strip everything but the performance data
$dbSize =~ s/^.*\|(.*?)$/$1/; $dbSize =~ s/^.*\|(.*?)$/$1/;