monitors:xymon-duplicity

no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


monitors:xymon-duplicity [2020/05/17 09:02] (current) – created doktoil_makresh
Line 1: Line 1:
 +====== xymon-duplicity ======
 +
 +^ Author | [[ damien@makelofine.org | Damien ]] |
 +^ Compatibility | Xymon 4.2 / 4.3 |
 +^ Requirements | Basic unix tools |
 +^ Download | Part of https://github.com/doktoil-makresh/xymon-plugins/ |
 +^ Last Update | 2020-05-17 |
 +
 +===== Description =====
 +This script will connect to your duplicity server to check the status of backups (see xymon-duplicity.cfg)
 +===== Installation =====
 +=== Client side ===
 +Add this entry in /etc/sudoers.d/xymon
 +Adapt the name (root) to the user launching the backups
 +Adapt the path to duplicity
 +xymon ALL=(root) NOPASSWD: /usr/local/bin/duplicity
 +
 +=== Server side ===
 +Nothing
 +===== Source =====
 +==== xymon-duplicity.sh ====
 +
 +<hidden onHidden="Show Code ⇲" onVisible="Hide Code ⇱">
 +<code>
 +#!/bin/bash                                                                                                                                                                      
 +#Verifying if the backup plan is working or not                                                                                                                                  
 +#Heavily inspired by https://camille.wordpress.com/2017/09/20/incremental-backups-with-duplicity-plus-nagios-monitoring/
 +TEST=duplicity
 +INTERVAL=12h
 +export LANG=en_US
 +CONFIG_FILE=${XYMONCLIENTHOME}/etc/xymon/xymon-duplicity.cfg
 +BACKUP_BASE_DIR=${DUPLICITY_PROTOCOL}://${DUPLICITY_USER}@${DUPLICITY_SERVER}
 +
 +#Debug
 +if [ "$1" == "debug" ] ; then
 +        echo "Debug ON"
 +        XYMON=echo
 +        XYMONCLIENTHOME="/usr/lib/xymon/client"
 +        XYMONTMP="$PWD"
 +        XYMONDISP=your_xymon_server
 +        MACHINE=$(hostname)
 +fi
 +
 +STATUS_FILE=${XYMONTMP}/xymon-duplicity.tmp
 +#Load configuration file
 +source $CONFIG_FILE
 +
 +#Check each folders defined in Xymon_duplicity_config_file
 +TODAY=$(LANG=en_US date +%c | awk '{print $1,$2,$3}')
 +YESTERDAY=$(LANG=en_US date +"%c" -d yesterday | awk '{print $1,$2,$3}')
 +
 +for FOLDER in $FOLDERS ; do
 + COLLECTION_STATUS=$(sudo duplicity collection-status $BACKUP_BASE_DIR/$HOST/$FOLDER 2 > /dev/null)
 + exitcode=$?
 + LATEST=$(echo $COLLECTION_STATUS | egrep "^Chain end time:" | tail -n 1 | awk '{print $4,$5,$6}' | sed  s/\ \/\ /)
 +
 +#Check backup status
 + echo "Checks for $FOLDER backup:" >> $STATUS_FILE
 + if [[ $exitcode != 0 ]] ; then
 + red=1
 + echo "&red Critical - Unable to perform the check command"
 + fi
 + if [[ $LATEST == "" ]] ; then
 + red=1
 + echo "&red Critical - No backup found at $BACKUP_BASE_DIR/$HOST/$FOLDER" >> $STATUS_FILE
 + fi
 + if [[ $LATEST == *$TODAY* ]] ; then
 + echo "&green OK - $LATEST" >> $STATUS_FILE
 + elif [[ $LATEST == *$YESTERDAY* ]] ; then
 + yellow=1
 + echo "&yellow Warning - $LATEST" >> $STATUS_FILE
 + else
 + red=1
 + echo "&red Critical - $LATEST" >> $STATUS_FILE
 + fi
 +done
 +
 +#Define global status
 +if [ "$red" == 1 ] ; then
 + global_color=red
 +elif [ "$yellow" == 1 ] ; then
 + global_color=yellow
 +else
 + global_color=green
 +fi
 +
 +#Send Xymon the results
 +"$XYMON" "$XYMSRV" "status+"$INTERVAL" "$MACHINE"."$TEST" "$global_color" $(date)
 +
 +$(cat $STATUS_FILE)
 +"
 +</code>
 +</hidden>
 +
 +===== Known  Bugs and Issues =====
 +None
 +===== To Do =====
 +Monitor backups on several duplicity servers
 +===== Credits =====
 +https://camille.wordpress.com/2017/09/20/incremental-backups-with-duplicity-plus-nagios-monitoring/
 +===== Changelog =====
 +
 +  * **2020-05-17**
 +    * Initial release
  
  • monitors/xymon-duplicity.txt
  • Last modified: 2020/05/17 09:02
  • by doktoil_makresh