Nagios:svnsync

De Lowgeek wiki

Monitoring.png

Monitorer la syncro svn

#!/bin/bash
# Ecrit par erreur404
 
# Récupération des paramètres
URL_SOURCE=${1} #url du svn source
DEPOT_SOURCE=${2} #dépot svn source
URL_TARGET=${3} #url du svn de backup
DEPOT_TARGET=${4} #dépot svn backup
USER=${5} #login
PASSWORD=${6} #password
PROTOCOL=${7} #http ou https
 
# Définition des URLs
SOURCE=${PROTOCOL}://${USER}:${PASSWORD}@${URL_SOURCE}/${DEPOT_SOURCE}/
TARGET=${PROTOCOL}://${USER}:${PASSWORD}@${URL_TARGET}/${DEPOT_TARGET}/
 
# Récupération de la révision source
REV_SOURCE=$(curl -s ${SOURCE} | grep Revision | tail -1)
REV_SOURCE_SMALL_TMP=${REV_SOURCE%%: /</h2>}
REV_SOURCE_SMALL=$(echo "${REV_SOURCE_SMALL_TMP}" | awk '{ print $NF }')
 
 
# Récupération de la révision destination
REV_TARGET=$(curl -s ${TARGET} | grep Revision | tail -1)
REV_TARGET_SMALL_TMP=${REV_TARGET%%: /</h2>}
REV_TARGET_SMALL=$(echo "${REV_TARGET_SMALL_TMP}" | awk '{ print $NF }')
 
case "${REV_TARGET_SMALL}" in
     "${REV_SOURCE_SMALL}")
           echo "OK: ${PROTOCOL}://${URL_SOURCE}/${DEPOT_SOURCE} et ${PROTOCOL}://${URL_TARGET}/${DEPOT_TARGET} synchro: Revision ${REV_TARGET_SMALL}"
           exit 0
     ;;
     *)   
           echo "CRITICAL: ${PROTOCOL}://${URL_SOURCE}/${DEPOT_SOURCE} rev ${REV_SOURCE_SMALL} / ${PROTOCOL}://${URL_TARGET}/${DEPOT_TARGET} rev ${REV_TARGET_SMALL}"
           exit 2
     ;;
esac