diff options
author | ndarshan <dnarayan@redhat.com> | 2014-04-04 15:15:51 +0530 |
---|---|---|
committer | Bala.FA <barumuga@redhat.com> | 2014-04-29 10:21:37 +0530 |
commit | 3f8ce76f2458fea466179ab74cca5712ec7c34d9 (patch) | |
tree | bb9781a411b9b38c1d57e535eb2fb10905466870 | |
parent | 05278f31d54d89ef0a68e94af389d66a3c3b6f74 (diff) |
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 <dnarayan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/22551
Reviewed-by: Kanagaraj Mayilsamy <kmayilsa@redhat.com>
-rwxr-xr-x | plugins/check_vol_utilization_server.py | 24 |
1 files 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)) |