From 3f8ce76f2458fea466179ab74cca5712ec7c34d9 Mon Sep 17 00:00:00 2001 From: ndarshan Date: Fri, 4 Apr 2014 15:15:51 +0530 Subject: Server-addons: Fix for volume utilization status not proper. This patch adds correct exit status for the plugin check_volume_utilization_server so that status change is reflected when the thresholds are crossed. Change-Id: I8829b6fcd9347729216502fefedee7d4f5101453 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1080950 Signed-off-by: ndarshan Reviewed-on: https://code.engineering.redhat.com/gerrit/22551 Reviewed-by: Kanagaraj Mayilsamy --- plugins/check_vol_utilization_server.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/check_vol_utilization_server.py b/plugins/check_vol_utilization_server.py index d34e212..cdc36ff 100755 --- a/plugins/check_vol_utilization_server.py +++ b/plugins/check_vol_utilization_server.py @@ -4,6 +4,7 @@ import commands import random import argparse import livestatus +import os _NRPEPath = "/usr/lib64/nagios/plugins/check_nrpe" @@ -16,8 +17,8 @@ def excecNRPECommand(host): command = (_NRPEPath + " -H " + answer.rstrip() + " -c " + "check_vol_utilization -a " + args.volume + " " + str(args.warning) + " " + str(args.critical)) - status = commands.getoutput(command) - return status + status, output = commands.getstatusoutput(command) + return status, output def showVolumeUtilization(args): @@ -28,21 +29,21 @@ def showVolumeUtilization(args): list_hosts = tab1[0].split(",") #First take a random host from the group and send the request host = random.choice(list_hosts) - status = excecNRPECommand(host) + status, output = excecNRPECommand(host) #if success return from here - if "Volume Utilization" in status: - return status + if "Volume Utilization" in output: + return status, output #radom host is not able to execute the command #Now try to iterate through the list of hosts #in the host group and send the command until #the command is successful for host in list_hosts: - status = excecNRPECommand(host) + status, output = excecNRPECommand(host) #if success return from here - if "Volume Utilization" in status: - return status + if "Volume Utilization" in output: + return status, output break - return status + return status, output def parse_input(): @@ -77,5 +78,6 @@ def parse_input(): if __name__ == '__main__': args = parse_input() - status = showVolumeUtilization(args) - print status + status, output = showVolumeUtilization(args) + print output + exit(os.WEXITSTATUS(status)) -- cgit