From 86a404d7ce805a25762cd66c310b1ad9e3a2a779 Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Thu, 10 Apr 2014 15:48:32 +0530 Subject: plugins: Enhanced volume status with quota status Added an optional parameter to query quota status Added command to nrpe.cfg Change-Id: I9f60ed1a98cb2ca59b799cf9c09e3621b7bd8c0c Signed-off-by: Sahina Bose --- plugins/Makefile.am | 1 + plugins/check_volume_status.py | 33 ++++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/Makefile.am b/plugins/Makefile.am index eb88ee1..c74cc3e 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -11,6 +11,7 @@ dist_glusternagiosplugins_PYTHON = \ check_disk_and_inode.py \ check_vol_utilization.py \ check_vol_status.py \ + check_volume_status.py \ cpu.py \ discoverpeers.py \ discoverlogicalcomponents.py \ diff --git a/plugins/check_volume_status.py b/plugins/check_volume_status.py index 383ec14..df68657 100755 --- a/plugins/check_volume_status.py +++ b/plugins/check_volume_status.py @@ -39,23 +39,46 @@ def getVolumeStatus(args): exitstatus = utils.PluginStatusCode.CRITICAL message = "CRITICAL: Volume is stopped" except glustercli.GlusterCmdFailedException as e: - out = "UNKNOWN: Command execution failed" - return utils.PluginStatusCode.UNKNOWN,out + out = ("UNKNOWN: Command execution failed %s" % e.message) + return utils.PluginStatusCode.UNKNOWN, out return exitstatus, message + +def getVolumeQuotaStatus(args): + try: + status = glustercli.volumeQuotaStatus(args.volume) + except glustercli.GlusterCmdFailedException as e: + out = ("QUOTA: Quota status could not be determined %s" % e.message) + return utils.PluginStatusCode.UNKNOWN, out + + if status == glustercli.VolumeQuotaStatus.EXCEEDED: + return utils.PluginStatusCode.WARNING, "QUOTA: limit exceeded" + elif status == glustercli.VolumeQuotaStatus.DISABLED: + return utils.PluginStatusCode.OK, "QUOTA: not enabled or configured" + else: + return utils.PluginStatusCode.OK, "QUOTA: OK" + + def parse_input(): parser = argparse.ArgumentParser() parser.add_argument("-v", "--volume", action="store", required=True, - help="Name of the volume for which" - " status is to be shown") + help="Name of the volume for status") + parser.add_argument("-t", "--type", action="store", + default="info", + dest="type", + help="Type of status to be shown. Possible values:", + choices=["info", "quota"]) args = parser.parse_args() return args if __name__ == '__main__': args = parse_input() - exitstatus, message = getVolumeStatus(args) + if args.type == "info": + exitstatus, message = getVolumeStatus(args) + if args.type == "quota": + exitstatus, message = getVolumeQuotaStatus(args) print message exit(exitstatus) -- cgit