#!/bin/bash # ====================================================================== # # NAGIOS CLIENT CHECK :: check client backup # # ---------------------------------------------------------------------- # 2016-12-09 v1.0 first lines # 2016-12-23 v1.1 added readable exitcode from shared functions file # 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 2020-04-04 v1.3 <axel.hahn@iml.unibe.ch> set status unknown if never executed # 2022-02-17 v1.4 <axel.hahn@iml.unibe.ch> no tmpfile; show more output to see backed up dirs # 2022-03-07 v1.5 <axel.hahn@iml.unibe.ch> update scan for results in transfer # 2022-03-18 v1.6 <axel.hahn@iml.unibe.ch> show dumped databases # 2022-03-21 v1.7 <axel.hahn@iml.unibe.ch> show databases infos for couchdb2 too # 2022-03-23 v1.8 <axel.hahn@iml.unibe.ch> FIX: exit with error if backup error occured # ====================================================================== . $( dirname $0 )/inc_pluginfunctions sInstalldir=/opt/imlbackup/client/ sChecker=$sInstalldir/check_clientbackup.sh if [ ! -x $sChecker ]; then ph.abort "$sChecker not found - maybe clientbackup is not installed." fi result=$( $sChecker ) rc=$? # remove ascii colors result=${result//\[[0-9]m/ } result=${result//\[[0-9][0-9]m/ } if [ $rc -eq 0 ]; then ph.setStatus "ok" else if echo "$result" | grep "Backup was never executed" 2>/dev/null then ph.setStatus "unknown" else ph.setStatus "critical" fi fi ph.status echo "$result" | grep -F "MONITORINFO:" | cut -f 2- -d ':' echo # show lines __DB__ of backed up databases and skip al database types # that do not have a line "__DB__[type] backup" for dbtype in $( echo "$result" | grep -o '__DB__[a-z][a-z0-9]*' | sort -u ) do echo "$result" | grep "$dbtype\ backup" >/dev/null \ && echo --- local dumps "${dbtype//__DB__/}" \ && echo "$result" | grep "$dbtype" | grep -v ".log" \ && echo done echo "--- transfer:" echo "$result" | grep "__[A-Z][A-Z]*__\ " ph.exit # ----------------------------------------------------------------------