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

Merge branch 'update-docs' into 'master'

no more tmpfile

See merge request !123
parents f6ac42ad fc639fe1
No related branches found
No related tags found
1 merge request!123no more tmpfile
......@@ -19,19 +19,17 @@
# 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
# 2023-06-19 v1.4 <axel.hahn@unibe.ch> no more tmpfile
# ======================================================================
. $(dirname $0)/inc_pluginfunctions
tmpfile=/tmp/ceph_df_output__$$
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
self_APPVERSION=1.4
function showHelp(){
cat <<EOF
......@@ -76,23 +74,23 @@ typeset -i iWarnLimit=$( ph.getValueWithParam 70 w "$@")
typeset -i iCriticalLimit=$( ph.getValueWithParam 90 c "$@")
if ! sudo /bin/ceph df > $tmpfile 2>&1
if ! data=$( sudo /bin/ceph df 2>&1 )
then
rm -f $tmpfile
echo "$data"
ph.abort "UNKNOWN: ceph is not available or no sudo permissions to execute ceph commands."
fi
rm -f $outfile 2>/dev/null
isHeader=0
area=
grep "[a-zA-Z]" $tmpfile | while read line
out=$(
grep "[a-zA-Z]" <<< "$data" | while read line
do
newArea=$(echo $line | grep "^\-\-\- [A-Z]*" | sed "s#--- ##" | sed "s# ---##" )
lineStatus=" "
if [ ! -z "$newArea" ]; then
echo>>$outfile
area=$(echo $newArea | cut -f 1 -d ":")
if [ -n "$newArea" ]; then
echo
area=$(echo "$newArea" | cut -f 1 -d ":")
isHeader=1
# Position of disk usage in the sections
......@@ -111,10 +109,8 @@ do
percentUsed=$(echo $line | awk -v ipos=$iPos '{ print $ipos }' | sed "s#\..*##")
if [ $percentUsed -ge $iWarnLimit ]; then
if [ $percentUsed -ge $iCriticalLimit ]; then
iCritical=$iCritical+1
lineStatus="CRITICAL "
else
iWarning=$iWarning+1
lineStatus="WARNING "
fi
else
......@@ -122,9 +118,12 @@ do
fi
fi
fi
echo "$lineStatus $line" >> $outfile
echo "$lineStatus $line"
done
)
iWarning=$( grep -c "^WARNING" <<< "$out" )
iCritical=$( grep -c "^CRITICAL" <<< "$out" )
if [ $iCritical -gt 0 ]; then
ph.setStatus "critical"
......@@ -135,10 +134,10 @@ else
fi
ph.status "Disksize on Ceph cluster and its pools - warnings: $iWarning ($iWarnLimit %) .. critcal: $iCritical ($iCriticalLimit %)"
cat $outfile
echo "$out"
# global size status is in TOTAL...
totalLine="$( grep '^TOTAL' $tmpfile | sed 's#iB##g' )"
totalLine="$( grep '^TOTAL' <<< "$data" | sed 's#iB##g' )"
# echo "DEBUG: totalLine = $totalLine"
# DEBUG: totalLine = TOTAL 18 T 18 T 428 G 428 G 2.30
......@@ -155,9 +154,6 @@ ph.perfadd "global-total" "${iTotal}" "" "" 0 ${iTotal}
ph.perfadd "global-avail" "${iAvail}" "" "" 0 ${iTotal}
ph.perfadd "global-used" "${iUsed}" "" "" 0 ${iTotal}
# cleanup
rm -f $tmpfile $outfile 2>/dev/null
ph.exit
# ----------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment