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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
icinga-checks
Merge requests
!215
6907 backup server
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
6907 backup server
6907_backup_server
into
master
Overview
0
Commits
2
Pipelines
0
Changes
1
Merged
6907 backup server
Hahn Axel (hahn)
requested to merge
6907_backup_server
into
master
Dec 21, 2023
Overview
0
Commits
2
Pipelines
0
Changes
1
0
0
Merge request reports
Viewing commit
b5f5d346
Prev
Next
Show latest version
1 file
+
40
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
b5f5d346
iml backup: first version
· b5f5d346
Hahn Axel (hahn)
authored
Dec 21, 2023
check_backup_one
+
40
−
5
View file @ b5f5d346
Edit in single-file editor
Open in Web IDE
Show full file
@@ -12,6 +12,7 @@
# ----------------------------------------------------------------------
# 2020-07-27 v0.x <axel.hahn@iml.unibe.ch>
# 2023-12-20 v0.2 <axel.hahn@iml.unibe.ch>
# 2023-12-21 v1.0 <axel.hahn@iml.unibe.ch> first version
# ======================================================================
@@ -55,7 +56,15 @@ $_self -m backupstatus
EOF
}
function
_getServerOfStatus
(){
local
_key
=
"
$1
"
local
_data
=
"
$2
"
grep
"
$_key
.*| [0-9].* |"
<<<
"
$_data
"
}
function
_getStatusCount
(){
_getServerOfStatus
"
$1
"
"
$2
"
|
wc
-l
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
@@ -74,13 +83,13 @@ while [[ "$#" -gt 0 ]]; do case $1 in
esac
;
done
if
[
-z
"
$sMode
"
]
;
then
ph.abort
"ERROR: The mode was not set. Use parameter -m
.
"
ph.abort
"ERROR: The mode was not set. Use parameter -m
for it. Get help wit -h
"
fi
myscript
=
"
$sInstalldir
/
$sScript
"
if
[
!
-x
"
$myscript
"
]
;
then
ph.abort
"UNKNOWN:
$myscript
is not available / executable. Use -d to fix the installation dir."
ph.abort
"UNKNOWN:
$myscript
is not available / executable. Use -d to fix the installation dir.
Get help wit -h
"
fi
# --- read data
@@ -91,12 +100,38 @@ case "$sMode" in
typeset
-i
iTotal
;
iTotal
=
$(
grep
"^total : "
<<<
"
$data
"
|
cut
-f
2
-d
":"
|
awk
'{ print $1 }'
)
typeset
-i
iErrors
;
iErrors
=
$(
grep
"^errors: "
<<<
"
$data
"
|
cut
-f
2
-d
":"
)
typeset
-i
iOK
;
iOK
=
$(
_getStatusCount
"
\.
"
"
$data
"
)
typeset
-i
iNotStarted
;
iNotStarted
=
$(
_getStatusCount
"
\?
"
"
$data
"
)
typeset
-i
iDisable
;
iDisable
=
$(
_getStatusCount
"D"
"
$data
"
)
typeset
-i
iRunning
;
iRunning
=
$(
_getStatusCount
"R"
"
$data
"
)
if
[
$iErrors
-gt
0
]
;
then
ph.setStatus critical
fi
ph.status
"Server Backups -
$iTotal
server -
$iErrors
errors"
echo
"
$data
"
|
tr
'|'
':'
ph.status
"Server Backups -
$iTotal
server -
$iErrors
errors -
$iDisable
disbled"
echo
List of server backups grouped by status
echo
(
# draw 1st line with table header
echo
"
$data
"
|
grep
"server.*start.*end"
echo
# show servers grouped by status
for
mystatus
in
E D R
"
\?
"
D
"
\.
"
do
_getServerOfStatus
"
$mystatus
"
"
$data
"
done
echo
-e
"
\e
[0m"
echo
"
$data
"
|
grep
"server.*start.*end"
echo
)
|
tr
'|'
':'
ph.perfadd
"notstarted"
"
${
iNotStarted
}
"
""
""
0
$iTotal
ph.perfadd
"disabled"
"
${
iDisable
}
"
""
""
0
$iTotal
ph.perfadd
"ok"
"
${
iOK
}
"
""
""
0
$iTotal
ph.perfadd
"running"
"
${
iRunning
}
"
""
""
0
$iTotal
ph.perfadd
"error"
"
${
iErrors
}
"
""
""
0
$iTotal
;;
"status"
)
typeset
-i
iRunning
;
iRunning
=
$(
grep
"STATUS"
<<<
"
$data
"
|
cut
-f
2
-d
" "
)
Loading