From e14e4b613bc76e66f8ff26bfaa06d2b0d5a68121 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Fri, 20 Oct 2023 16:02:38 +0200 Subject: [PATCH] update sudo handling --- check_ceph_diskfree | 7 ++++--- check_ceph_io | 6 +----- check_proc_mem | 14 +++++++++++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/check_ceph_diskfree b/check_ceph_diskfree index 28ab2ef..ef608ca 100755 --- a/check_ceph_diskfree +++ b/check_ceph_diskfree @@ -64,15 +64,16 @@ case "$1" in *) esac +# --- check required tools +ph.require ceph + # set default / override from command line params typeset -i iWarnLimit=$( ph.getValueWithParam 70 w "$@") typeset -i iCriticalLimit=$( ph.getValueWithParam 90 c "$@") - if ! data=$( sudo -n /bin/ceph df 2>&1 ) then - echo "$data" - ph.abort "UNKNOWN: ceph is not available or no sudo permissions to execute ceph commands." + ph.abort "UNKNOWN: No sudo permissions to execute ceph commands." fi isHeader=0 diff --git a/check_ceph_io b/check_ceph_io index bb1e89b..a5034a5 100755 --- a/check_ceph_io +++ b/check_ceph_io @@ -89,11 +89,7 @@ else # --- get output of ceph if ! CEPHOUT=$( sudo -n 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?" - echo "$CEPHOUT" + ph.abort "UNKNOWN: No sudo permissions to execute ceph commands." fi CEPHIO=$( echo "$CEPHOUT" | grep "client:") fi diff --git a/check_proc_mem b/check_proc_mem index 91b2bbe..0742809 100755 --- a/check_proc_mem +++ b/check_proc_mem @@ -11,10 +11,15 @@ # # ---------------------------------------------------------------------- # 2020-03-02 v1.0 initial version -# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions -# 2023-02-13 v1.2 <axel.hahn@unibe.ch> some shell fixes +# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions +# 2023-02-13 v1.2 <axel.hahn@unibe.ch> some shell fixes +# 2023-08-24 v1.3 <axel.hahn@unibe.ch> add help; do not use tmp file anymore # ====================================================================== +. $( dirname $0 )/inc_pluginfunctions + +export self_APPVERSION=1.1 + # --- tmp files for internal usage tmpfile=/tmp/processlist1_$$ tmpfile2=/tmp/processlist2_$$ @@ -31,7 +36,10 @@ typeset -i iCountCritical=0 rm -f $tmpfile $tmpfile2 $outCritical $outWarning 2>/dev/null -. $(dirname $0)/inc_pluginfunctions +# ---------------------------------------------------------------------- +# functions +# ---------------------------------------------------------------------- + # ---------------------------------------------------------------------- # MAIN -- GitLab