Search
j0ke.net Open Build Service
>
Projects
>
server:monitoring
>
nagios-plugins-rhev
> check_rhev-hosts_and_checkALL.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File check_rhev-hosts_and_checkALL.patch of Package nagios-plugins-rhev
--- check_rhev.orig 2012-02-21 11:35:30.661735279 +0100 +++ check_rhev 2012-02-21 17:52:31.101692703 +0100 @@ -24,12 +24,6 @@ WARNING = 1 CRITICAL = 2 -############### -# ATTENTION: # -############### -# Add your rhev-h host below, like "192.168.1.101,192.168.1.102, ..." -HOSTS = "" - # General macros VDSM_PORT = 54321 TIMEOUT_SOCKET_SEC = 5 @@ -98,11 +92,53 @@ ssh.close() i += 1 + ########################################################################## + # checkALL() # + # Description: Check All Guests # + ########################################################################## + + + def checkALL(self, hosts, user, passw): + i = 0 + while(i < len(hosts)): + ssh = paramiko.SSHClient() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + try: + ssh.connect(hosts[i],username=user,password=passw) + stdin, stdout, stderr = ssh.exec_command(VDSM_COMMAND + ' -s 0 list table|awk \'{print $3","$4}\'') + data = stdout.readlines() + output= "" + down = 0 + for line in data: + vm,status = line.split(",") + status = status.strip('\n\r') + if status != 'Up': + down += 1 + output += "OK: %s %s " % (vm, status) + + output += "@ %s" % (hosts[i]) + print output + if down == 0: + sys.exit(OK) + else: + sys.exit(WARNING) + error = stderr.readlines() + for line in error: + status = "command not found" + if line.find(status) != -1: + print "error: please install vdsClient, host: %s" % hosts[i] + except Exception, e: + ssh.close() + + ssh.close() + i += 1 + # MAIN if __name__ == "__main__": usage = "usage: %prog [options] arg" parser = OptionParser(usage) + parser.add_option("-H", "--host", action="store", dest="HOSTS") parser.add_option("-v", "--verbose", action="store_true", dest="verbose") parser.add_option("-q", "--quiet", action="store_false", dest="verbose") parser.add_option("-t", "--type-service", action="store", dest="type_service") @@ -111,7 +147,7 @@ parser.add_option("-p", "--password", action="store", dest="passw") (options, args) = parser.parse_args() - if HOSTS == "": + if options.HOSTS == "": print "UNKNOWN: please add your RHEV-H hosts into check_rhev!" sys.exit(UNKNOWN) @@ -121,7 +157,7 @@ # Generic calls - every option will use them rhev = checkRHEV() - hosts = HOSTS.split(",") + hosts = options.HOSTS.split(",") user = options.user passw = options.passw @@ -141,6 +177,9 @@ if options.type_service == 'checkVMS': rhev.checkVMS(hosts, user, passw, guest) sys.exit(CRITICAL) + if options.type_service == 'checkALL': + rhev.checkALL(hosts, user, passw) + sys.exit(CRITICAL) else: print "UNKNOWN: invalid option, please verify check_rhev -h" sys.exit(UNKNOWN) --- README.orig 2012-02-21 12:36:02.956972975 +0100 +++ README 2012-02-21 12:37:38.500123516 +0100 @@ -1,2 +1,8 @@ All info available at: http://github.com/dougsland/nagios-plugins-rhev/wiki + +Service Types: + - checkHOST + - checkVMS (needs options -u, -p, -g) + - checkALL (needs optiosn -u, -p) +