Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Commits
72e25202
Commit
72e25202
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update ceph_status
parent
b9f07ec5
Branches
Branches containing commit
No related tags found
1 merge request
!65
update ceph_status
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_ceph_status
+21
-20
21 additions, 20 deletions
check_ceph_status
with
21 additions
and
20 deletions
check_ceph_status
+
21
−
20
View file @
72e25202
...
...
@@ -18,9 +18,10 @@
# 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-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
tmpfile
=
/tmp/ceph-status.out_
$$
...
...
@@ -46,16 +47,16 @@ function readCephStatus(){
fi
}
function
getCephStatus
(){
cat
$tmpfile
|
grep
"health"
|
awk
'{ print $2 }'
cat
$tmpfile
|
grep
"health
:
"
|
awk
'{ print $2 }'
}
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
(){
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
(){
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(){
readCephStatus
if
[
!
-f
$initfile
]
;
then
echo
"
sStart=
\"
`
date
`
\"
iTsStart=
`
date
+%s
`
typeset -i iDeg=
`
getDegraded
`
typeset -i iMis=
`
getMisplaced
`
sStart=
\"
$(
date
)
\"
iTsStart=
$(
date
+%s
)
typeset -i iDeg=
$(
getDegraded
)
typeset -i iMis=
$(
getMisplaced
)
"
>
$initfile
fi
...
...
@@ -78,7 +79,8 @@ fi
iLastDeg
=
$iDeg
iLastMis
=
$iMis
sCephStatus
=
`
getCephStatus
`
sCephStatus
=
$(
getCephStatus
)
if
[
"
$sCephStatus
"
=
"HEALTH_OK"
]
;
then
ph.setStatus
"ok"
...
...
@@ -99,8 +101,8 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
iTsNow
=
`
date
+%s
`
typeset
-i
iDegNow
=
`
getDegraded
`
typeset
-i
iMisNow
=
`
getMisplaced
`
typeset
-i
iDegNow
=
$(
getDegraded
)
typeset
-i
iMisNow
=
$(
getMisplaced
)
typeset
-i
iTsDelta
=
$iTsNow
-
$iTsStart
typeset
-i
iTsDeltaMin
=
$iTsDelta
/60
...
...
@@ -116,7 +118,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
typeset
-i
iDegPerMin
=
$iDoneDeg
/
$iTsDelta
*
60
if
[
$iDegPerMin
-gt
0
]
;
then
# timeByDeg=`echo $iTsDelta*$iObjCount/$iDoneDeg/60 - $iTsDelta/60 | bc`
timeByDeg
=
`
echo
$iDegNow
/
$iDegPerMin
| bc
`
timeByDeg
=
$(
echo
$iDegNow
/
$iDegPerMin
| bc
)
else
timeByDeg
=
"???"
...
...
@@ -125,14 +127,14 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
typeset
-i
iMisPerMin
=
$iDoneMis
/
$iTsDelta
*
60
if
[
$iMisPerMin
-gt
0
]
;
then
# timeByMis=`echo $iTsDelta*$iObjCount/$iDoneMis/60 - $iTsDelta/60 | bc`
timeByMis
=
`
echo
$iMisNow
/
$iMisPerMin
| bc
`
timeByMis
=
$(
echo
$iMisNow
/
$iMisPerMin
| bc
)
else
timeByMis
=
"???"
fi
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
sTimeLeft
=
"
$sTimeLeft
min ... about
`
echo
$sTimeLeft
/60 | bc
`
h"
sTimeLeft
=
"
$sTimeLeft
min ... about
$(
echo
$sTimeLeft
/60 | bc
)
h"
else
sTimeLeft
=
"
$sTimeLeft
min"
fi
...
...
@@ -142,7 +144,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
fi
typeset
-i
iDoneTotal
=
$iDoneDeg
+
$iDoneMis
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
eater
=
"C"
else
...
...
@@ -155,8 +157,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
# ----- output
test
$doSingleLoop
=
1
||
clear
# echo "Rebuild detected on $sStart ... running for $iTsDelta s [= $iTsDeltaMin min]"
echo
"Rebuild detected on
$sStart
... running for
$iTsDeltaMin
min"
echo
"Problem detected on
$sStart
... running for
$iTsDeltaMin
min"
# --- progress bar
echo
-n
"["
...
...
@@ -188,7 +189,7 @@ while [ ! "$sCephStatus" = "HEALTH_OK" -a $doLoop = 1 ]; do
else
sleep
$iSleep
readCephStatus
sCephStatus
=
`
getCephStatus
`
sCephStatus
=
$(
getCephStatus
)
fi
done
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment