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
51205c81
Commit
51205c81
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
no more tmpfile
parent
36a30c40
Branches
Branches containing commit
No related tags found
1 merge request
!123
no more tmpfile
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_ceph_diskfree
+15
-16
15 additions, 16 deletions
check_ceph_diskfree
with
15 additions
and
16 deletions
check_ceph_diskfree
+
15
−
16
View file @
51205c81
...
@@ -19,11 +19,11 @@
...
@@ -19,11 +19,11 @@
# 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
# 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-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
.
$(
dirname
$0
)
/inc_pluginfunctions
tmpfile
=
/tmp/ceph_df_output__
$$
outfile
=
/tmp/check_ceph_df_out__
$$
outfile
=
/tmp/check_ceph_df_out__
$$
typeset
-i
iWarning
=
0
typeset
-i
iWarning
=
0
...
@@ -31,7 +31,7 @@ typeset -i iCritical=0
...
@@ -31,7 +31,7 @@ typeset -i iCritical=0
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPVERSION
=
1.
3
self_APPVERSION
=
1.
4
function
showHelp
(){
function
showHelp
(){
cat
<<
EOF
cat
<<
EOF
...
@@ -76,9 +76,9 @@ typeset -i iWarnLimit=$( ph.getValueWithParam 70 w "$@")
...
@@ -76,9 +76,9 @@ typeset -i iWarnLimit=$( ph.getValueWithParam 70 w "$@")
typeset
-i
iCriticalLimit
=
$(
ph.getValueWithParam 90 c
"
$@
"
)
typeset
-i
iCriticalLimit
=
$(
ph.getValueWithParam 90 c
"
$@
"
)
if
!
sudo
/bin/ceph
df
>
$tmpfile
2>&1
if
!
data
=
$(
sudo
/bin/ceph
df
2>&1
)
then
then
rm
-f
$tmpfile
echo
"
$data
"
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
...
@@ -86,13 +86,14 @@ rm -f $outfile 2>/dev/null
...
@@ -86,13 +86,14 @@ rm -f $outfile 2>/dev/null
isHeader
=
0
isHeader
=
0
area
=
area
=
grep
"[a-zA-Z]"
$tmpfile
|
while
read
line
out
=
$(
grep
"[a-zA-Z]"
<<<
"
$data
"
|
while
read
line
do
do
newArea
=
$(
echo
$line
|
grep
"^
\-\-\-
[A-Z]*"
|
sed
"s#--- ##"
|
sed
"s# ---##"
)
newArea
=
$(
echo
$line
|
grep
"^
\-\-\-
[A-Z]*"
|
sed
"s#--- ##"
|
sed
"s# ---##"
)
lineStatus
=
" "
lineStatus
=
" "
if
[
!
-z
"
$newArea
"
]
;
then
if
[
-n
"
$newArea
"
]
;
then
echo
>>
$outfile
echo
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
...
@@ -111,10 +112,8 @@ do
...
@@ -111,10 +112,8 @@ do
percentUsed
=
$(
echo
$line
|
awk
-v
ipos
=
$iPos
'{ print $ipos }'
|
sed
"s#
\.
.*##"
)
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
lineStatus
=
"CRITICAL "
lineStatus
=
"CRITICAL "
else
else
iWarning
=
$iWarning
+1
lineStatus
=
"WARNING "
lineStatus
=
"WARNING "
fi
fi
else
else
...
@@ -122,9 +121,12 @@ do
...
@@ -122,9 +121,12 @@ do
fi
fi
fi
fi
fi
fi
echo
"
$lineStatus
$line
"
>>
$outfile
echo
"
$lineStatus
$line
"
done
done
)
iWarning
=
$(
grep
-c
"^WARNING"
<<<
"
$out
"
)
iCritical
=
$(
grep
-c
"^CRITICAL"
<<<
"
$out
"
)
if
[
$iCritical
-gt
0
]
;
then
if
[
$iCritical
-gt
0
]
;
then
ph.setStatus
"critical"
ph.setStatus
"critical"
...
@@ -135,10 +137,10 @@ else
...
@@ -135,10 +137,10 @@ else
fi
fi
ph.status
"Disksize on Ceph cluster and its pools - warnings:
$iWarning
(
$iWarnLimit
%) .. critcal:
$iCritical
(
$iCriticalLimit
%)"
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...
# 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"
# echo "DEBUG: totalLine = $totalLine"
# DEBUG: totalLine = TOTAL 18 T 18 T 428 G 428 G 2.30
# DEBUG: totalLine = TOTAL 18 T 18 T 428 G 428 G 2.30
...
@@ -155,9 +157,6 @@ ph.perfadd "global-total" "${iTotal}" "" "" 0 ${iTotal}
...
@@ -155,9 +157,6 @@ 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
rm
-f
$tmpfile
$outfile
2>/dev/null
ph.exit
ph.exit
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
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