Nagios:svnsync

De Lowgeek wiki

Monitoring.png

Monitorer la syncro svn

<syntaxhighlight lang="bash">

  1. !/bin/bash
  2. Ecrit par erreur404
  1. 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

  1. Définition des URLs

SOURCE=${PROTOCOL}://${USER}:${PASSWORD}@${URL_SOURCE}/${DEPOT_SOURCE}/ TARGET=${PROTOCOL}://${USER}:${PASSWORD}@${URL_TARGET}/${DEPOT_TARGET}/

  1. 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 }')


  1. 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 </syntaxhighlight>