From b9f07ec56cb823d591623ff87a579f53995ad3b7 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Mon, 24 Apr 2023 14:55:27 +0200
Subject: [PATCH] update for newer ceph versions

---
 check_ceph_osd | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/check_ceph_osd b/check_ceph_osd
index 4f8160f..3a71a65 100755
--- a/check_ceph_osd
+++ b/check_ceph_osd
@@ -2,7 +2,7 @@
 # ======================================================================
 #
 # Icinga/ Nagios Check
-# CEPH STATUS / HEALTH
+# CEPH OSD STATUS
 #
 # ----------------------------------------------------------------------
 #
@@ -10,12 +10,13 @@
 #   - ceph
 #
 # SYNTAX:
-#   - check_ceph_status
+#   - check_ceph_status -w [count for warnming] -w [count for critical]
 #     No parameter required
 #
 # RESULT:
 #     OK        = all OSDs up
-#     CRITITCAL = min. 1 OSD is down
+#     WARNING   = 1 OSD is down
+#     CRITITCAL = min. 2 OSDs are down
 #     UNKNOWN   = ceph osd tree is not executable
 #
 # ----------------------------------------------------------------------
@@ -23,11 +24,13 @@
 # 2020-03-05  v1.1  <axel.hahn@iml.unibe.ch>  added params -w -c 
 # 2020-03-05  v1.2  <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
 # 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
 # ======================================================================
 
-. `dirname $0`/inc_pluginfunctions
+. $(dirname $0)/inc_pluginfunctions
 
 tmpfile=/tmp/ceph_status_output_$$
+iColUpDown=5
 
 # ----------------------------------------------------------------------
 # FUNCTIONS
@@ -48,12 +51,12 @@ if [ $? -ne 0 ]; then
 fi
 
 # set default / override from command line params
-typeset -i iWarnLimit=`     ph.getValueWithParam 1 w "$@"`
-typeset -i iCriticalLimit=` ph.getValueWithParam 2 c "$@"`
+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 $4 }' | grep "down" | wc -l`
-typeset -i iOsdUp=`    getOsd | awk '{ print $4 }' | grep "up"   | wc -l`
+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)
 
 
 if [ $iOsdDown -lt $iWarnLimit ]; then
-- 
GitLab