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
!213
rewrite backup_one check
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
rewrite backup_one check
6907_backup_server
into
master
Overview
0
Commits
1
Pipelines
0
Changes
2
Merged
Hahn Axel (hahn)
requested to merge
6907_backup_server
into
master
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
2
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
98db295f
1 commit,
1 year ago
2 files
+
86
−
14
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
check_backup_one
+
85
−
13
View file @ 98db295f
Edit in single-file editor
Open in Web IDE
Show full file
@@ -11,33 +11,105 @@
#
# ----------------------------------------------------------------------
# 2020-07-27 v0.x <axel.hahn@iml.unibe.ch>
# 2023-12-20 v0.2 <axel.hahn@iml.unibe.ch>
# ======================================================================
.
`
dirname
$0
`
/inc_pluginfunctions
.
$(
dirname
$0
)
/inc_pluginfunctions
export
self_APPVERSION
=
0.2
sInstalldir
=
/opt/imlbackup/server
sScript
=
storage_helper.sh
sMode
=
# ----------------------------------------------------------------------
# FUNCTIONS
# ----------------------------------------------------------------------
function
showHelp
(){
local
_self
;
_self
=
$(
basename
$0
)
cat
<<
EOF
$(
ph.showImlHelpHeader
)
Show status of backup server.
You can get the count of connections or the status of server backup.
See https://os-docs.iml.unibe.ch/iml-backup-server/
SYNTAX:
$_self
[-d DIRECTORY]
OPTIONS:
-h or --help show this help.
-d or --dir set installation dir of iml deployment to find its check skript
default dir:
${
sInstalldir
}
script:
${
sInstalldir
}
/
${
sScript
}
-m or --mode mode: set type of result; one of status|backupstatus
backupstatus status of backup sets of all servers
status count of connected servers
EXAMPLE:
$_self
-m status
$_self
-m backupstatus
EOF
}
myscript
=
/opt/imlbackup/server/storage_helper.sh
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
if
[
!
-x
$myscript
]
;
then
ph.abort
"UNKNOWN:
$myscript
is not available / executable."
# --- check param -h
while
[[
"$#"
-gt
0
]]
;
do case
$1
in
-h
|
--help
)
showHelp
;
exit
0
;;
-d
|
--dir
)
sInstalldir
=
$2
;
shift
;
shift
;;
-m
|
--mode
)
sMode
=
$2
;
shift
;
shift
if
!
grep
-E
"^(status|backupstatus)$"
<<<
"
$sMode
"
>
/dev/null
;
then
ph.abort
"ERROR: unknown mode [
$sMode
]."
fi
;;
*
)
echo
"ERROR: Unknown parameter:
$1
"
;
showHelp
;
exit
1
;
esac
;
done
if
[
-z
"
$sMode
"
]
;
then
ph.abort
"ERROR: The mode was not set. Use parameter -m."
fi
myscript
=
"
$sInstalldir
/
$sScript
"
if
[
!
-x
"
$myscript
"
]
;
then
ph.abort
"UNKNOWN:
$myscript
is not available / executable. Use -d to fix the installation dir."
fi
# --- read data
tmpfile
=
$(
mktemp
)
$myscript
status
>
$tmpfile
typeset
-i
iRunning
=
`
cat
$tmpfile
|
grep
"STATUS"
|
cut
-f
2
-d
" "
`
typeset
-i
iMax
=
`
cat
$tmpfile
|
grep
"STATUS"
|
cut
-f
8
-d
" "
|
tr
-d
'.'
`
data
=
$(
"
$myscript
"
"
$sMode
"
)
case
"
$sMode
"
in
"backupstatus"
)
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
":"
)
if
[
$iErrors
-gt
0
]
;
then
ph.setStatus critical
fi
ph.status
"Server Backups -
$iTotal
server -
$iErrors
errors"
echo
"
$data
"
;;
"status"
)
typeset
-i
iRunning
;
iRunning
=
$(
grep
"STATUS"
<<<
"
$data
"
|
cut
-f
2
-d
" "
)
typeset
-i
iMax
;
iMax
=
$(
grep
"STATUS"
<<<
"
$data
"
|
cut
-f
8
-d
" "
|
tr
-d
'.'
)
# --- status output
ph.status
"Backups running:
$iRunning
(max
$iMax
)"
# echo "$data"
# --- status output
ph.status
"Backups running:
$iRunning
(max
$iMax
)"
cat
$tmpfile
rm
-f
$tmpfile
ph.perfadd
"running"
"
${
iRunning
}
"
""
""
0
$iMax
;;
esac
ph.perfadd
"running"
"
${
iRunning
}
"
""
""
0
$iMax
ph.exit
# ----------------------------------------------------------------------
Loading