1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-21 18:03:45 +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"
path=''
nagios_server = ""
nagios_port = None
nagios_port = 8002
nagios_myhostname = "localhost"
# No real need to change anything below here
version="1.0"
@ -69,9 +70,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 ""
@ -133,13 +138,15 @@ while len(arguments) > 0:
show_perfdata = True
elif arg == '--no-perfdata':
show_perfdata = False
elif arg == '-h' or '--help':
print_help()
exit(ok)
elif arg == '--nagioserver':
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 == '-h' or '--help':
print_help()
exit(ok)
else:
error( "Invalid argument %s"% arg)
@ -279,20 +286,29 @@ def end(summary,perfdata,longserviceoutput,nagios_state):
global show_perfdata
global nagios_server
global nagios_port
global nagios_myhostname
global hostname
global mode
message = "%s - %s" % ( state[nagios_state], summary)
if show_perfdata:
message = "%s | %s" % ( message, perfdata)
if show_longserviceoutput:
message = "%s\n%s" % ( message, longserviceoutput)
message = "%s\n%s" % ( message, longserviceoutput.strip())
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
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):
pass
uri = "http://%s:%s" % (nagios_server,nagios_port)
s = xmlrpclib.ServerProxy( uri )
s.nagiosupdate(hostname, servicename, status, message)
return 0
def check_systems():
summary=""

View File

@ -7,10 +7,9 @@
$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);
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;
$num_databases = 0;
@ -21,7 +20,7 @@ foreach $database (@array1)
$database =~ s/^\s*(.*?)\s*$/$1/;
# 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
$dbSize =~ s/^.*\|(.*?)$/$1/;