X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=dsa-nagios-checks%2Fchecks%2Fdsa-check-dabackup-server;h=906505bc71d0cee3841afadef294259b0e10a28f;hb=82ef7b493cfb8e47151e97d33ae08f397e2372b4;hp=8dba0c0089462c3d8a8ccdb0730d2ad8f0a4f5f7;hpb=08275064a9658cc5efde9976917f897c1a775cb1;p=mirror%2Fdsa-nagios.git diff --git a/dsa-nagios-checks/checks/dsa-check-dabackup-server b/dsa-nagios-checks/checks/dsa-check-dabackup-server index 8dba0c0..906505b 100755 --- a/dsa-nagios-checks/checks/dsa-check-dabackup-server +++ b/dsa-nagios-checks/checks/dsa-check-dabackup-server @@ -26,14 +26,17 @@ set -e set -u +AUTHKEYSFILE=/etc/ssh/userkeys/root +BASE=/srv/backups/da-backup + err=0 log() { - if [ "$1" == "warn" ] && [ "$err" -lt 1 ]; then + if [ "$1" = "warn" ] && [ "$err" -lt 1 ]; then err=1 - elif [ "$1" == "critical" ] && [ "$err" -lt 2 ]; then + elif [ "$1" = "critical" ] && [ "$err" -lt 2 ]; then err=2 - elif [ "$1" == "unknown" ] && [ "$err" == 0 ]; then + elif [ "$1" = "unknown" ] && [ "$err" = 0 ]; then err=3 fi } @@ -67,14 +70,14 @@ done rsync_targets=`tempfile` backup_manager_sources=`tempfile` trap "rm -f '$rsync_targets' '$backup_manager_sources'" 0 1 2 5 15 -cat /root/.ssh/authorized_keys | +cat "$AUTHKEYSFILE" | grep '^command=' | - sed -e 's/",no-por.*//' -e 's/.*--ignore-errors . //' -e 's#/org/backup.debian.org/staging/##' | + sed -e 's/",no-por.*//' -e 's/.*--ignore-errors . //' -e "s#${BASE}/staging/##" | grep -v 'command="/usr/lib/da-backup/da-backup-ssh-wrap ' | sort > "$rsync_targets" -wildcard_hosts=`cat /root/.ssh/authorized_keys | grep 'command="/usr/lib/da-backup/da-backup-ssh-wrap ' | sed -e 's/.*da-backup-ssh-wrap \([a-z0-9.]*\)".*/\1/' | tr '\n' '|' | sed 's/|$//'` -grep -h source /etc/da-backup-manager/* | +wildcard_hosts=`cat "$AUTHKEYSFILE" | grep 'command="/usr/lib/da-backup/da-backup-ssh-wrap ' | sed -e 's/.*da-backup-ssh-wrap \([a-z0-9.]*\)".*/\1/' | tr '\n' '|' | sed 's/|$//'` +grep -h '^source' /etc/da-backup-manager/* | sed -e 's/source=//' | egrep -v "^($wildcard_hosts)/" | sort > "$backup_manager_sources" @@ -86,20 +89,20 @@ fi # check that everything listed as either source or destination by da-backup-manager does exist - if stuff is new it might still be missing tho for i in `awk -F = '$1=="source" {print $2}' /etc/da-backup-manager/* `; do - if ! [ -d "/org/backup.debian.org/staging/$i" ]; then + if ! [ -d "${BASE}/staging/$i" ]; then log warn echo "Warning: source $i does not exist" fi done for i in ` awk -F = '$1=="destination"{print $2}' /etc/da-backup-manager/* `; do - if ! [ -d "/org/backup.debian.org/backups/$i" ]; then + if ! [ -d "${BASE}/backups/$i" ]; then log warn echo "Warning: destination $i does not exist (if it is new, it takes a day)" fi done # check that everything that does exist has an entry in da-backup-manager -cd /org/backup.debian.org/staging +cd "${BASE}/staging" for i in */*; do if ! [ -d "$i" ]; then log warn @@ -111,7 +114,7 @@ for i in */*; do echo "staging/$i is not listed anywhere in /etc/da-backup-manager" fi done -cd /org/backup.debian.org/backups +cd "${BASE}/backups" for i in */*; do if ! [ -d "$i" ]; then log warn