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

rewrite backup_one check

parent 2b06c47c
No related branches found
No related tags found
1 merge request!213rewrite backup_one check
...@@ -11,33 +11,105 @@ ...@@ -11,33 +11,105 @@
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 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>
# ====================================================================== # ======================================================================
. `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 # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
if [ ! -x $myscript ]; then # --- check param -h
ph.abort "UNKNOWN: $myscript is not available / executable." 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 fi
# --- read data # --- read data
tmpfile=$( mktemp ) data=$( "$myscript" "$sMode" )
$myscript status > $tmpfile
typeset -i iRunning=`cat $tmpfile | grep "STATUS" | cut -f 2 -d " "` case "$sMode" in
typeset -i iMax=` cat $tmpfile | grep "STATUS" | cut -f 8 -d " " | tr -d '.'` "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.perfadd "running" "${iRunning}" "" "" 0 $iMax
ph.status "Backups running: $iRunning (max $iMax)" ;;
cat $tmpfile esac
rm -f $tmpfile
ph.perfadd "running" "${iRunning}" "" "" 0 $iMax
ph.exit ph.exit
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -49,7 +49,7 @@ esac; done ...@@ -49,7 +49,7 @@ esac; done
sChecker=$sInstalldir/check_deployment.sh sChecker=$sInstalldir/check_deployment.sh
if [ ! -x $sChecker ]; then if [ ! -x "$sChecker" ]; then
ph.abort "$sChecker not found - maybe deployment is not installed here. Use param -d to set the install directory." ph.abort "$sChecker not found - maybe deployment is not installed here. Use param -d to set the install directory."
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment