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
0eb5c045
Commit
0eb5c045
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update for newer ceph versions
parent
3819f1cc
No related branches found
No related tags found
1 merge request
!63
6303 update ceph checks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_ceph_diskfree
+28
-23
28 additions, 23 deletions
check_ceph_diskfree
with
28 additions
and
23 deletions
check_ceph_diskfree
+
28
−
23
View file @
0eb5c045
...
@@ -17,9 +17,10 @@
...
@@ -17,9 +17,10 @@
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2020-03-04 v1.0 <axel.hahn@iml.unibe.ch>
# 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
# 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
# ======================================================================
# ======================================================================
.
`
dirname
$0
`
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
tmpfile
=
/tmp/ceph_df_output__
$$
tmpfile
=
/tmp/ceph_df_output__
$$
outfile
=
/tmp/check_ceph_df_out__
$$
outfile
=
/tmp/check_ceph_df_out__
$$
...
@@ -32,34 +33,33 @@ typeset -i iCritical=0
...
@@ -32,34 +33,33 @@ typeset -i iCritical=0
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# set default / override from command line params
# set default / override from command line params
typeset
-i
iWarnLimit
=
`
ph.getValueWithParam 70 w
"
$@
"
`
typeset
-i
iWarnLimit
=
$(
ph.getValueWithParam 70 w
"
$@
"
)
typeset
-i
iCriticalLimit
=
`
ph.getValueWithParam 90 c
"
$@
"
`
typeset
-i
iCriticalLimit
=
$(
ph.getValueWithParam 90 c
"
$@
"
)
sudo
/bin/ceph
df
>
$tmpfile
2>&1
if
!
sudo
/bin/ceph
df
>
$tmpfile
2>&1
if
[
$?
-ne
0
]
;
then
then
rm
-f
$tmpfile
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
fi
rm
-f
$outfile
2>/dev/null
rm
-f
$outfile
2>/dev/null
isHeader
=
0
isHeader
=
0
area
=
area
=
while
read
line
grep
"[a-zA-Z]"
$tmpfile
|
while
read
line
do
do
# echo "DEBUG: $line"
newArea
=
$(
echo
$line
|
grep
"^
\-\-\-
[A-Z]*"
|
sed
"s#--- ##"
|
sed
"s# ---##"
)
newArea
=
`
echo
$line
|
grep
"^[A-Z]*:"
`
lineStatus
=
" "
lineStatus
=
" "
if
[
!
-z
"
$newArea
"
]
;
then
if
[
!
-z
"
$newArea
"
]
;
then
echo
>>
$outfile
echo
>>
$outfile
area
=
`
echo
$newArea
|
cut
-f
1
-d
":"
`
area
=
$(
echo
$newArea
|
cut
-f
1
-d
":"
)
isHeader
=
1
isHeader
=
1
# Position of disk usage in the sections
# Position of disk usage in the sections
iPos
=
0
iPos
=
0
test
"
$area
"
=
"
GLOBAL
"
&&
iPos
=
4
test
"
$area
"
=
"
RAW STORAGE
"
&&
iPos
=
10
test
"
$area
"
=
"POOLS"
&&
iPos
=
4
test
"
$area
"
=
"POOLS"
&&
iPos
=
9
if
[
$iPos
-eq
0
]
;
then
if
[
$iPos
-eq
0
]
;
then
ph.abort
"ERROR: unhandled section: [
$area
]"
ph.abort
"ERROR: unhandled section: [
$area
]"
fi
fi
...
@@ -68,7 +68,8 @@ do
...
@@ -68,7 +68,8 @@ do
if
[
$isHeader
-eq
1
]
;
then
if
[
$isHeader
-eq
1
]
;
then
isHeader
=
0
isHeader
=
0
else
else
typeset
-i
percentUsed
=
`
echo
$line
|
awk
-v
ipos
=
$iPos
'{ print $ipos }'
|
sed
"s#
\.
.*##"
`
typeset
-i
percentUsed
percentUsed
=
$(
echo
$line
|
awk
-v
ipos
=
$iPos
'{ print $ipos }'
|
sed
"s#
\.
.*##"
)
if
[
$percentUsed
-ge
$iWarnLimit
]
;
then
if
[
$percentUsed
-ge
$iWarnLimit
]
;
then
if
[
$percentUsed
-ge
$iCriticalLimit
]
;
then
if
[
$percentUsed
-ge
$iCriticalLimit
]
;
then
iCritical
=
$iCritical
+1
iCritical
=
$iCritical
+1
...
@@ -83,7 +84,7 @@ do
...
@@ -83,7 +84,7 @@ do
fi
fi
fi
fi
echo
"
$lineStatus
$line
"
>>
$outfile
echo
"
$lineStatus
$line
"
>>
$outfile
done
<
$tmpfile
done
if
[
$iCritical
-gt
0
]
;
then
if
[
$iCritical
-gt
0
]
;
then
...
@@ -94,23 +95,27 @@ else
...
@@ -94,23 +95,27 @@ else
ph.setStatus
"ok"
ph.setStatus
"ok"
fi
fi
ph.status
"Disksize on Ceph cluster and its pools -
critcal:
$iCritical
(
$iCriticalLimit
%) .. warnings:
$iWarning
(
$iWarn
Limit
%)"
ph.status
"Disksize on Ceph cluster and its pools -
warnings:
$iWarning
(
$iWarnLimit
%) .. critcal:
$iCritical
(
$iCritical
Limit
%)"
cat
$outfile
cat
$outfile
# 3rd line is global size status
# global size status is in TOTAL...
sTotal
=
`
sed
-n
3p
$tmpfile
|
awk
'{ print $1 }'
`
totalLine
=
"
$(
grep
'^TOTAL'
$tmpfile
|
sed
's#iB##g'
)
"
sAvail
=
`
sed
-n
3p
$tmpfile
|
awk
'{ print $2 }'
`
sUsed
=
`
sed
-n
3p
$tmpfile
|
awk
'{ print $3 }'
`
iTotal
=
`
ph.toUnit
$sTotal
""
`
# echo "DEBUG: totalLine = $totalLine"
iAvail
=
`
ph.toUnit
$sAvail
""
`
# DEBUG: totalLine = TOTAL 18 T 18 T 428 G 428 G 2.30
iUsed
=
`
ph.toUnit
$sUsed
""
`
sTotal
=
$(
echo
$totalLine
|
awk
'{ print $2 $3 }'
)
sAvail
=
$(
echo
$totalLine
|
awk
'{ print $4 $5 }'
)
sUsed
=
$(
echo
$totalLine
|
awk
'{ print $6 $7 }'
)
iTotal
=
$(
ph.toUnit
$sTotal
""
)
iAvail
=
$(
ph.toUnit
$sAvail
""
)
iUsed
=
$(
ph.toUnit
$sUsed
""
)
ph.perfadd
"global-total"
"
${
iTotal
}
"
""
""
0
${
iTotal
}
ph.perfadd
"global-total"
"
${
iTotal
}
"
""
""
0
${
iTotal
}
ph.perfadd
"global-avail"
"
${
iAvail
}
"
""
""
0
${
iTotal
}
ph.perfadd
"global-avail"
"
${
iAvail
}
"
""
""
0
${
iTotal
}
ph.perfadd
"global-used"
"
${
iUsed
}
"
""
""
0
${
iTotal
}
ph.perfadd
"global-used"
"
${
iUsed
}
"
""
""
0
${
iTotal
}
# cleanup
# cleanup
rm
-f
$tmpfile
$outfile
2>/dev/null
rm
-f
$tmpfile
$outfile
2>/dev/null
...
...
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