Skip to content
Snippets Groups Projects
Commit 28fe6a23 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '6907_backup_server' into 'master'

6907 backup server

See merge request !215
parents 8a32f675 1d0409a2
No related branches found
No related tags found
1 merge request!2156907 backup server
#!/bin/bash #!/bin/bash
# ====================================================================== # ======================================================================
# #
# WORK IN PROGRESS # Check IML BACKUP SERVER
# #
# Check ONE BACKUP connection count # requires access to storage_helper.sh
# # in /opt/imlbackup/server/
# requirements access to storage_helper.sh
# ls -ld /opt/imlbackup/server/
# drwxr-x--- 3 imlbackup imlbackup 4096 Jul 27 06:25 /opt/imlbackup/server/
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2020-07-27 v0.x <axel.hahn@iml.unibe.ch> # 2020-07-27 v0.x <axel.hahn@iml.unibe.ch>
# 2023-12-20 v0.2 <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
# ====================================================================== # ======================================================================
...@@ -37,7 +35,7 @@ You can get the count of connections or the status of server backup. ...@@ -37,7 +35,7 @@ You can get the count of connections or the status of server backup.
See https://os-docs.iml.unibe.ch/iml-backup-server/ See https://os-docs.iml.unibe.ch/iml-backup-server/
SYNTAX: SYNTAX:
$_self [-d DIRECTORY] $_self [-d DIRECTORY] -m MODE
OPTIONS: OPTIONS:
-h or --help show this help. -h or --help show this help.
...@@ -55,7 +53,15 @@ $_self -m backupstatus ...@@ -55,7 +53,15 @@ $_self -m backupstatus
EOF EOF
} }
function _getServerOfStatus(){
local _key="$1"
local _data="$2"
grep "$_key .*| [0-9].* |" <<< "$_data"
}
function _getStatusCount(){
_getServerOfStatus "$1" "$2" | wc -l
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# MAIN # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -74,13 +80,13 @@ while [[ "$#" -gt 0 ]]; do case $1 in ...@@ -74,13 +80,13 @@ while [[ "$#" -gt 0 ]]; do case $1 in
esac; done esac; done
if [ -z "$sMode" ]; then 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 fi
myscript="$sInstalldir/$sScript" myscript="$sInstalldir/$sScript"
if [ ! -x "$myscript" ]; then 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 fi
# --- read data # --- read data
...@@ -91,12 +97,40 @@ case "$sMode" in ...@@ -91,12 +97,40 @@ case "$sMode" in
typeset -i iTotal; iTotal=$( grep "^total : " <<< "$data" | cut -f 2 -d ":" | awk '{ print $1 }' ) 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 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 if [ $iErrors -gt 0 ]; then
ph.setStatus critical ph.setStatus critical
fi fi
ph.status "Server Backups - $iTotal server - $iErrors errors" if [ $iNotStarted -eq $iTotal ]; then
echo "$data" | tr '|' ':' ph.setStatus unknown
fi
ph.status "Server Backups - $iTotal servers in backup - $iErrors errors - $iDisable disbled - $iRunning running"
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") "status")
typeset -i iRunning; iRunning=$( grep "STATUS" <<< "$data" | cut -f 2 -d " ") typeset -i iRunning; iRunning=$( grep "STATUS" <<< "$data" | cut -f 2 -d " ")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment