diff options
author | Timothy Asir <tjeyasin@redhat.com> | 2014-07-09 16:04:43 +0530 |
---|---|---|
committer | Sahina Bose <sabose@redhat.com> | 2014-07-10 04:43:16 -0700 |
commit | 083e4a72dc51b8d319a6b285c10a87cefc3e22dc (patch) | |
tree | 911ebe4aaa2c780b6669376f0e1b05065aad52c9 /plugins | |
parent | 1fe7a5d03799ba043c99e7a3bdcac5579ed5174a (diff) |
Add option to show critical and warning disks in the status
Currently the critical status message shows the sum of all usage
which is actually confusing the user when there are multiple disks
available and any/few disk status moved to critical state.
This patch adds option to show critical and warning disk details
in the status message whenever there is any change in disk status
to critical or warning.
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1116710
Change-Id: I7a44f669a4a554aff748c2758bcf6a104365aed8
Signed-off-by: Timothy Asir <tjeyasin@redhat.com>
Reviewed-on: http://review.gluster.org/8273
Tested-by: Timothy Asir <tim.gluster@gmail.com>
Reviewed-by: Kanagaraj M <kmayilsa@redhat.com>
Reviewed-by: Sahina Bose <sabose@redhat.com>
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/check_disk_and_inode.py | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/plugins/check_disk_and_inode.py b/plugins/check_disk_and_inode.py index 1025d4d..393bd94 100755 --- a/plugins/check_disk_and_inode.py +++ b/plugins/check_disk_and_inode.py @@ -147,22 +147,30 @@ def parse_input(): parser.add_option('-x', '--exclude', action="append", type='string', dest='exclude', help='Exclude disk/brick') + parser.add_option('-s', action="store_true", default=False, + dest='showErrorDisk', + help='Show critical or warning disks in the status') return parser.parse_args() def _getMsg(okList, warnList, critList): msg = ", ".join(critList) + errorDiskMsg = msg if critList and (warnList or okList): msg = "CRITICAL: " + msg if warnList: if msg: msg += "; WARNING: " msg += ", ".join(warnList) + if errorDiskMsg: + errorDiskMsg += "; WARNING: " + ", ".join(warnList) + else: + errorDiskMsg = msg if okList: if msg: msg += "; OK: " msg += ", ".join(okList) - return msg + return msg, errorDiskMsg def _getUnitAndType(val): @@ -174,7 +182,7 @@ def _getUnitAndType(val): def showDiskUsage(warn, crit, mountPaths, toListInode, usage=False, - isLvm=False, ignoreError=False): + isLvm=False, ignoreError=False, showErrorDisk=True): diskPerf = [] warnList = [] critList = [] @@ -275,7 +283,7 @@ def showDiskUsage(warn, crit, mountPaths, toListInode, usage=False, statusCode = utils.PluginStatusCode.UNKNOWN okList.append(msg) - msg = _getMsg(okList, warnList, critList) + msg, errorDiskMsg = _getMsg(okList, warnList, critList) if totalUsed == 0 and totalSize == 0: # avoid zero div error @@ -303,8 +311,11 @@ def showDiskUsage(warn, crit, mountPaths, toListInode, usage=False, totalSize, usage) - if usageMsg: + if showErrorDisk: + msg = "%s\n:mount(s): (%s)" % (errorDiskMsg, msg) + else: msg = "%s:mount(s): (%s)" % (usageMsg, msg) + return statusCode, msg, diskPerf @@ -325,7 +336,8 @@ if __name__ == '__main__': options.inode, options.usage, options.lvm, - options.ignore) + options.ignore, + options.showErrorDisk) if utils.PluginStatusCode.CRITICAL == statusCode: sys.stdout.write("%s : %s | %s\n" % ( @@ -340,7 +352,9 @@ if __name__ == '__main__': " ".join(diskPerf))) sys.exit(utils.PluginStatusCode.WARNING) else: - sys.stdout.write("%s : %s | %s\n" % ( - utils.PluginStatus.OK, - msg, - " ".join(diskPerf))) + if options.showErrorDisk: + sys.stdout.write("%s %s | %s\n" % ( + utils.PluginStatus.OK, msg, " ".join(diskPerf))) + else: + sys.stdout.write("%s : %s | %s\n" % ( + utils.PluginStatus.OK, msg, " ".join(diskPerf))) |