#!/bin/bash ## Neuronnexion - www.neuronnexion.coop - tech@nnx.com ## Released under the terms of GNU/GPL conf="/etc/check_mk/bgp.conf" script_expect="/usr/local/bin/bgp_summary localhost bgpd DISABLEPWD ENABLEPWD" # Var NAGIOS STATE_OK="0" STATE_WARNING="1" STATE_CRITICAL="2" STATE_UNKNOWN="3" STATE_DEPENDENT="4" # Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd ( $script_expect |grep -A 9999999 "^Neighbor"|grep -B 999999 "^Total"|egrep "^[0-9]" | sed -e 's/\r//' | \ while read Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ UpDown StatePfxRcd sup ; do # Status ItemName PerformanceData CheckOutput if [[ $(grep -i "^exclude:as$AS:" "$conf") ]] ; then continue # skip when exclude fi infos="$StatePfxRcd" [ "x" != "x$sup" ] && infos="$infos $sup" # Gestion des cas ou l'info est en deux mots count=0 val=$STATE_UNKNOWN if [[ $StatePfxRcd =~ [0-9]+ ]] ; then val=$STATE_OK count=$StatePfxRcd else # Erreur, donc warning val=$STATE_WARNING # Si CRITIQUE, alors on hurle if [[ $(grep -i "^critical:as$AS:" "$conf") ]] ; then val=$STATE_CRITICAL fi # Si c'est volontaire, shut if [[ "$infos" =~ \(Admin\) ]] ; then val=$STATE_OK fi fi echo "$val BGP_AS"$AS"_$Neighbor count=$count Duration: $UpDown - Status: $infos" done )|sort -k 2