From 4c7b746beb22eb08d31d159e95f0232841dd27cf Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Tue, 9 May 2023 14:29:40 +0200
Subject: [PATCH] ceph diskfree - add help

---
 check_ceph_diskfree | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/check_ceph_diskfree b/check_ceph_diskfree
index d285efe..3167e17 100755
--- a/check_ceph_diskfree
+++ b/check_ceph_diskfree
@@ -18,6 +18,7 @@
 # 2020-03-04  v1.0  <axel.hahn@iml.unibe.ch>
 # 2020-03-05  v1.1  <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
 # 2023-04-24  v1.2  <axel.hahn@unibe.ch>     update for newer ceph versions
+# 2023-05-09  v1.3  <axel.hahn@unibe.ch>     add help
 # ======================================================================
 
 . $(dirname $0)/inc_pluginfunctions
@@ -28,10 +29,48 @@ outfile=/tmp/check_ceph_df_out__$$
 typeset -i iWarning=0
 typeset -i iCritical=0
 
+
+self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
+self_APPVERSION=1.3
+
+function showHelp(){
+cat <<EOF
+______________________________________________________________________
+
+$self_APPNAME 
+v$self_APPVERSION
+
+(c) Institute for Medical Education - University of Bern
+Licence: GNU GPL 3
+______________________________________________________________________
+
+Show available and free space on a ceph cluster.
+This check sends performance data.
+
+It uses 'ceph df' to parse data.
+
+SYNTAX:
+$(basename $0)
+
+OPTIONS:
+    -h or --help   show this help.
+
+EOF
+}
+
 # ----------------------------------------------------------------------
 # MAIN
 # ----------------------------------------------------------------------
 
+# --- check param -h
+case "$1" in
+    "--help"|"-h")
+        showHelp
+        exit 0
+        ;;
+    *)
+esac
+
 # set default / override from command line params
 typeset -i iWarnLimit=$(     ph.getValueWithParam 70 w "$@")
 typeset -i iCriticalLimit=$( ph.getValueWithParam 90 c "$@")
@@ -40,7 +79,7 @@ typeset -i iCriticalLimit=$( ph.getValueWithParam 90 c "$@")
 if ! sudo /bin/ceph df > $tmpfile 2>&1
 then
     rm -f $tmpfile
-ph.abort "UNKNOWN: ceph is not available or no sudo permissions to execute ceph commands."
+    ph.abort "UNKNOWN: ceph is not available or no sudo permissions to execute ceph commands."
 fi
 
 rm -f $outfile 2>/dev/null
-- 
GitLab