From 39576516e321454ed9c353aa355b7c43b017ab78 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Thu, 27 Jul 2023 10:42:31 +0200 Subject: [PATCH] ceph osd: shorten ceph exec; show output on error --- check_ceph_osd | 18 +++++++++--------- docs/20_Checks/check_ceph_osd.md | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/check_ceph_osd b/check_ceph_osd index aacd931..bbe1dd5 100755 --- a/check_ceph_osd +++ b/check_ceph_osd @@ -26,12 +26,13 @@ # 2022-10-21 v1.3 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space # 2023-04-24 v1.4 <axel.hahn@unibe.ch> update for newer ceph versions # 2023-06-19 v1.5 <axel.hahn@unibe.ch> add help and param support; no more tmpfile +# 2023-07-27 v1.6 <axel.hahn@unibe.ch> shorten ceph exec; show output on error; shell fixes # ====================================================================== . $(dirname $0)/inc_pluginfunctions self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.5 +self_APPVERSION=1.6 # column number in output where to find the up/ down info iColUpDown=5 @@ -94,19 +95,18 @@ case "$1" in *) esac -data=$( sudo /bin/ceph osd tree 2>&1 ) -if [ $? -ne 0 ]; then +if ! data=$( sudo /bin/ceph osd tree 2>&1 ); then + echo "$data" ph.abort "UNKNOWN: ceph is not available or no sudo permissions to execute ceph commands." fi # set default / override from command line params -typeset -i iWarnLimit=$( ph.getValueWithParam 1 w "$@") -typeset -i iCriticalLimit=$( ph.getValueWithParam 2 c "$@") - -typeset -i iOsdTotal=$( getOsd | wc -l) -typeset -i iOsdDown=$( getOsd | awk '{ print $iColUpDown }' | grep "down" | wc -l) -typeset -i iOsdUp=$( getOsd | awk '{ print $iColUpDown }' | grep "up" | wc -l) +typeset -i iWarnLimit; iWarnLimit=$( ph.getValueWithParam 1 w "$@") +typeset -i iCriticalLimit; iCriticalLimit=$( ph.getValueWithParam 2 c "$@") +typeset -i iOsdTotal; iOsdTotal=$( getOsd | wc -l) +typeset -i iOsdDown; iOsdDown=$( getOsd | awk '{ print $iColUpDown }' | grep "down" | wc -l) +typeset -i iOsdUp; iOsdUp=$( getOsd | awk '{ print $iColUpDown }' | grep "up" | wc -l) if [ $iOsdDown -lt $iWarnLimit ]; then ph.setStatus "ok" diff --git a/docs/20_Checks/check_ceph_osd.md b/docs/20_Checks/check_ceph_osd.md index 8855aec..d1a09a6 100644 --- a/docs/20_Checks/check_ceph_osd.md +++ b/docs/20_Checks/check_ceph_osd.md @@ -18,7 +18,7 @@ critical level. ______________________________________________________________________ CHECK_CEPH_OSD -v1.5 +v1.6 (c) Institute for Medical Education - University of Bern Licence: GNU GPL 3 -- GitLab