summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gluster-nagios-addons.spec.in2
-rwxr-xr-xplugins/check_disk_and_inode.py32
2 files changed, 24 insertions, 10 deletions
diff --git a/gluster-nagios-addons.spec.in b/gluster-nagios-addons.spec.in
index cd00c5f..252a333 100644
--- a/gluster-nagios-addons.spec.in
+++ b/gluster-nagios-addons.spec.in
@@ -132,7 +132,7 @@ fi
cat >> %{_sysconfdir}/nagios/nrpe.cfg <<EOF
%{_start_conf_section}
-command[check_disk_and_inode]=sudo %{_libdir}/nagios/plugins/gluster/check_disk_and_inode.py -w 80 -c 90 -l -i /boot -i /var -i /root -n --inode
+command[check_disk_and_inode]=sudo %{_libdir}/nagios/plugins/gluster/check_disk_and_inode.py -w 80 -c 90 -l -i /boot -i /var -i /root -n --inode -s
command[check_memory]=%{_libdir}/nagios/plugins/gluster/memory.py -w 80 -c 90 -t 2
command[check_swap_usage]=%{_libdir}/nagios/plugins/gluster/swap.py -w 80 -c 90 -t 2
command[check_cpu_multicore]=%{_libdir}/nagios/plugins/gluster/cpu.py -w 80 -c 90 -t 2
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)))