From e12bd0bcb0e257019cfe3d69a6f0d071c1f38ee6 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Thu, 11 May 2023 13:24:49 +0200 Subject: [PATCH] ceph_io: handle ceph status without io data --- check_ceph_io | 19 +++++++++++++------ docs/20_Checks/check_ceph_io.md | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/check_ceph_io b/check_ceph_io index f698704..e5b65a8 100755 --- a/check_ceph_io +++ b/check_ceph_io @@ -17,12 +17,13 @@ # 2023-05-09 v1.0 <axel.hahn@unibe.ch> # 2023-05-10 v1.1 <axel.hahn@unibe.ch> fix for small transfer rates in B/s # 2023-05-10 v1.2 <axel.hahn@unibe.ch> add tests +# 2023-05-11 v1.3 <axel.hahn@unibe.ch> handle ceph status without io data in output # ====================================================================== . $(dirname $0)/inc_pluginfunctions self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.2 +self_APPVERSION=1.3 function showHelp(){ _self=$(basename $0) @@ -75,6 +76,7 @@ if [ "$1" = "-t" ]; then # TEST: client: 8.9 KiB/s rd, 887 KiB/s wr, 138 op/s rd, 140 op/s wr # TEST: client: 255 B/s rd, 85 B/s wr, 0 op/s rd, 0 op/s # TEST: client: 255 B/s rd, 0 op/s rd, 0 op/s wr + # TEST: no line with client if [ -z "$2" ]; then echo; echo ">>>>>>>>>> TESTS"; echo grep '# TEST: ' $0 | grep -v grep | cut -f 2- -d ':' | while read -r teststring @@ -90,16 +92,20 @@ if [ "$1" = "-t" ]; then else # --- check required tools ph.require ceph - CEPHIO=$( sudo ceph status 2>/dev/null | grep "client:") -fi - -if [ -z "${CEPHIO}" ]; then + # --- get output of ceph + if ! CEPHOUT=$( sudo ceph status 2>&1 ); then ph.setStatus "unknown" ph.status "no data" echo "There is no output from 'sudo ceph status'." echo "No ceph here or no sudo permissions on ceph command?" -else + echo "$CEPHOUT" + fi + CEPHIO=$( echo "$CEPHOUT" | grep "client:") +fi + + +if [ -n "${CEPHOUT}${CEPHIO}" ]; then CEPHDATA=$( echo "${CEPHIO}" | cut -f 2 -d ':' ) SEG_R=$( echo "${CEPHDATA}" | cut -f 1 -d "," | grep "rd" | awk '{ print $1 " " $2 }') @@ -111,6 +117,7 @@ else IO_READ=$( echo "${SEG_R}" | sed -E "s#([0-9]*) (.).(.).*#\1\2\3#g" | tr -d 's') IO_WRITE=$( echo "${SEG_W}" | sed -E "s#([0-9]*) (.).(.).*#\1\2\3#g" | tr -d 's') + test -z "$CEPHIO" && CEPHIO="'ceph status' successful - but there are no io data in output." test -z "$IO_READ" && IO_READ="0" test -z "$IO_WRITE" && IO_WRITE="0" ph.status "$( echo "${CEPHIO}" | cut -f 2 -d ":" )" diff --git a/docs/20_Checks/check_ceph_io.md b/docs/20_Checks/check_ceph_io.md index 162ea29..f406e88 100644 --- a/docs/20_Checks/check_ceph_io.md +++ b/docs/20_Checks/check_ceph_io.md @@ -15,7 +15,7 @@ It returns a single line for the status and performance data. ______________________________________________________________________ CHECK_CEPH_IO -v1.2 +v1.3 (c) Institute for Medical Education - University of Bern Licence: GNU GPL 3 -- GitLab