check_clientbackup 2.16 KB
Newer Older
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
1
2
3
4
5
6
7
8
9
10
#!/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
11
# 2022-02-17  v1.4  <axel.hahn@iml.unibe.ch> no tmpfile; show more output to see backed up dirs
12
# 2022-03-07  v1.5  <axel.hahn@iml.unibe.ch> update scan for results in transfer
13
# 2022-03-18  v1.6  <axel.hahn@iml.unibe.ch> show dumped databases
14
# 2022-03-21  v1.7  <axel.hahn@iml.unibe.ch> show databases infos for couchdb2 too
15
# 2022-03-23  v1.8  <axel.hahn@iml.unibe.ch> FIX: exit with error if backup error occured
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
16
# 2022-08-10  v1.9  <axel.hahn@iml.unibe.ch> FIX: mask the dot in .log
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
17
18
# ======================================================================

19
. $( dirname $0 )/inc_pluginfunctions
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
20
21

sInstalldir=/opt/imlbackup/client/
22
sChecker=$sInstalldir/check_clientbackup.sh
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
23
24
25
26
27
28


if [ ! -x $sChecker ]; then
  ph.abort "$sChecker not found - maybe clientbackup is not installed."
fi

29
result=$( $sChecker )
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
30
rc=$?
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
31
32
33
34

# remove ascii colors
result=${result//\[[0-9]m/ }
result=${result//\[[0-9][0-9]m/ }
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
35
36
37
38

if [ $rc -eq 0 ]; then
  ph.setStatus "ok"
else
39
40
  if echo "$result" | grep "Backup was never executed" 2>/dev/null  
  then
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
41
42
43
44
45
46
    ph.setStatus "unknown"
  else
    ph.setStatus "critical"
  fi
fi

47
48
49
ph.status
echo "$result" | grep -F "MONITORINFO:" | cut -f 2- -d ':'
echo
50
51
52

# show lines __DB__ of backed up databases and skip al database types
# that do not have a line "__DB__[type] backup"
53
for dbtype in $( echo "$result" | grep -o '__DB__[a-z][a-z0-9]*' | sort -u )
54
55
56
do
        echo "$result" | grep "$dbtype\ backup" >/dev/null \
                && echo --- local dumps "${dbtype//__DB__/}" \
57
                && echo "$result" | grep "$dbtype" | grep -v "\.log" \
58
59
60
                && echo
done

61
echo "--- transfer:"
62
echo "$result" | grep "__[A-Z][A-Z]*__\ "
63

Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) committed
64
65
66
ph.exit

# ----------------------------------------------------------------------