Skip to content
Snippets Groups Projects
Commit 72e25202 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update ceph_status

parent b9f07ec5
No related branches found
No related tags found
1 merge request!65update ceph_status
...@@ -18,9 +18,10 @@ ...@@ -18,9 +18,10 @@
# 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 2020-03-05 v1.1 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2021-03-31 v1.2 <axel.hahn@iml.unibe.ch> estimate remaining time of ceph recovery # 2021-03-31 v1.2 <axel.hahn@iml.unibe.ch> estimate remaining time of ceph recovery
# 2021-04-12 v1.3 <axel.hahn@iml.unibe.ch> if degraded items are 0 delete init file too # 2021-04-12 v1.3 <axel.hahn@iml.unibe.ch> if degraded items are 0 delete init file too
# 2023-04-24 v1.4 <axel.hahn@unibe.ch> update for newer ceph versions
# ====================================================================== # ======================================================================
. `dirname $0`/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
initfile=/tmp/ceph-status-not-ok-start initfile=/tmp/ceph-status-not-ok-start
tmpfile=/tmp/ceph-status.out_$$ tmpfile=/tmp/ceph-status.out_$$
...@@ -46,16 +47,16 @@ function readCephStatus(){ ...@@ -46,16 +47,16 @@ function readCephStatus(){
fi fi
} }
function getCephStatus(){ function getCephStatus(){
cat $tmpfile | grep "health" | awk '{ print $2 }' cat $tmpfile | grep "health:" | awk '{ print $2 }'
} }
function getTotalObjects(){ function getTotalObjects(){
cat $tmpfile | grep "recovery.*objects degraded" | awk '{ print $2 }' | cut -f 2 -d "/" cat $tmpfile | grep "pgs:.*objects degraded" | awk '{ print $2 }' | cut -f 2 -d "/"
} }
function getDegraded(){ function getDegraded(){
cat $tmpfile | grep "recovery.*objects degraded" | awk '{ print $2 }' | cut -f 1 -d "/" cat $tmpfile | grep "pgs:.*objects degraded" | awk '{ print $2 }' | cut -f 1 -d "/"
} }
function getMisplaced(){ function getMisplaced(){
cat $tmpfile | grep "recovery.*objects misplaced" | awk '{ print $2 }' | cut -f 1 -d "/" cat $tmpfile | grep ".*objects misplaced" | awk '{ print $2 }' | cut -f 1 -d "/"
} }
...@@ -67,10 +68,10 @@ function getMisplaced(){ ...@@ -67,10 +68,10 @@ function getMisplaced(){
readCephStatus readCephStatus
if [ ! -f $initfile ]; then if [ ! -f $initfile ]; then
echo " echo "
sStart=\"`date`\" sStart=\"$(date)\"
iTsStart=`date +%s` iTsStart=$(date +%s)
typeset -i iDeg=`getDegraded` typeset -i iDeg=$(getDegraded)
typeset -i iMis=`getMisplaced` typeset -i iMis=$(getMisplaced)
">$initfile ">$initfile
fi fi
...@@ -78,7 +79,8 @@ fi ...@@ -78,7 +79,8 @@ fi
iLastDeg=$iDeg iLastDeg=$iDeg
iLastMis=$iMis iLastMis=$iMis
sCephStatus=`getCephStatus`
sCephStatus=$(getCephStatus)
if [ "$sCephStatus" = "HEALTH_OK" ]; then if [ "$sCephStatus" = "HEALTH_OK" ]; then
ph.setStatus "ok" ph.setStatus "ok"
...@@ -99,8 +101,8 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do ...@@ -99,8 +101,8 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
iTsNow=`date +%s` iTsNow=`date +%s`
typeset -i iDegNow=`getDegraded` typeset -i iDegNow=$(getDegraded)
typeset -i iMisNow=`getMisplaced` typeset -i iMisNow=$(getMisplaced)
typeset -i iTsDelta=$iTsNow-$iTsStart typeset -i iTsDelta=$iTsNow-$iTsStart
typeset -i iTsDeltaMin=$iTsDelta/60 typeset -i iTsDeltaMin=$iTsDelta/60
...@@ -116,7 +118,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do ...@@ -116,7 +118,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
typeset -i iDegPerMin=$iDoneDeg/$iTsDelta*60 typeset -i iDegPerMin=$iDoneDeg/$iTsDelta*60
if [ $iDegPerMin -gt 0 ]; then if [ $iDegPerMin -gt 0 ]; then
# timeByDeg=`echo $iTsDelta*$iObjCount/$iDoneDeg/60 - $iTsDelta/60 | bc` # timeByDeg=`echo $iTsDelta*$iObjCount/$iDoneDeg/60 - $iTsDelta/60 | bc`
timeByDeg=`echo $iDegNow/$iDegPerMin | bc` timeByDeg=$(echo $iDegNow/$iDegPerMin | bc)
else else
timeByDeg="???" timeByDeg="???"
...@@ -125,14 +127,14 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do ...@@ -125,14 +127,14 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
typeset -i iMisPerMin=$iDoneMis/$iTsDelta*60 typeset -i iMisPerMin=$iDoneMis/$iTsDelta*60
if [ $iMisPerMin -gt 0 ]; then if [ $iMisPerMin -gt 0 ]; then
# timeByMis=`echo $iTsDelta*$iObjCount/$iDoneMis/60 - $iTsDelta/60 | bc` # timeByMis=`echo $iTsDelta*$iObjCount/$iDoneMis/60 - $iTsDelta/60 | bc`
timeByMis=`echo $iMisNow/$iMisPerMin | bc` timeByMis=$(echo $iMisNow/$iMisPerMin | bc)
else else
timeByMis="???" timeByMis="???"
fi fi
if [ $iDegPerMin -gt 0 -o $iMisPerMin -gt 0 ]; then if [ $iDegPerMin -gt 0 -o $iMisPerMin -gt 0 ]; then
sTimeLeft=`echo "($iDegNow+$iMisNow)/($iDegPerMin+$iMisPerMin)" | bc` sTimeLeft=$(echo "($iDegNow+$iMisNow)/($iDegPerMin+$iMisPerMin)" | bc)
if [ $sTimeLeft -gt 120 ]; then if [ $sTimeLeft -gt 120 ]; then
sTimeLeft="$sTimeLeft min ... about `echo $sTimeLeft/60 | bc` h" sTimeLeft="$sTimeLeft min ... about $(echo $sTimeLeft/60 | bc) h"
else else
sTimeLeft="$sTimeLeft min" sTimeLeft="$sTimeLeft min"
fi fi
...@@ -142,7 +144,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do ...@@ -142,7 +144,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
fi fi
typeset -i iDoneTotal=$iDoneDeg+$iDoneMis typeset -i iDoneTotal=$iDoneDeg+$iDoneMis
typeset -i iNowTotal=$iDegNow+$iMisNow typeset -i iNowTotal=$iDegNow+$iMisNow
typeset -i iProgress=`echo "$iDoneTotal*100/$iObjCount" | bc` typeset -i iProgress=$(echo "$iDoneTotal*100/$iObjCount" | bc)
if [ "$eater" = "o" ]; then if [ "$eater" = "o" ]; then
eater="C" eater="C"
else else
...@@ -155,8 +157,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do ...@@ -155,8 +157,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
# ----- output # ----- output
test $doSingleLoop = 1 || clear test $doSingleLoop = 1 || clear
# echo "Rebuild detected on $sStart ... running for $iTsDelta s [= $iTsDeltaMin min]" echo "Problem detected on $sStart ... running for $iTsDeltaMin min"
echo "Rebuild detected on $sStart ... running for $iTsDeltaMin min"
# --- progress bar # --- progress bar
echo -n "[" echo -n "["
...@@ -188,7 +189,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do ...@@ -188,7 +189,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
else else
sleep $iSleep sleep $iSleep
readCephStatus readCephStatus
sCephStatus=`getCephStatus` sCephStatus=$(getCephStatus)
fi fi
done done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment