#!/bin/sh printbytes(){ echo -n " " (if [ "$1" -lt 100000 ] ; then printf "%'d" $1 elif [ "$1" -lt 10000000 ] ; then VAL=`expr $1 / 1024` printf "%'dk" $VAL else VAL=`expr $1 / 1048576` printf "%'dm" $VAL fi) | sed 's/ /,/g' } conproxy_stats(){ echo -n " bytes transfered :" REC=`conproxy-control -p $1 status | grep total_bytes_received | (read a b; echo $b)` printbytes $REC SNT=`conproxy-control -p $1 status | grep total_bytes_sent | (read a b; echo $b)` printbytes $SNT echo } echo blackhole-control status | ( total=0 lastcon= PROBLEM=" PROBLEM *** " one= while read name a b c d e f g h i j k l do case $name in started=*) started=`echo $name | sed 's/started=//'` echo " Blackhole started :" $started ;; reloaded=*) reloaded=`echo $name | sed 's/reloaded=//'` echo " Config. reloaded :" $reloaded ;; Horizon) name=$a fd=`echo $b | sed 's/fd=//'` retry=`echo $c | sed 's/nbretry=//'` nbping=`echo $d | sed 's/nbping=//'` intruder=`echo $g | sed 's/intruder=//'` error=`echo $h | sed 's/lasterror=//'` if [ "$fd" = "-1" ] ; then one=true echo "$PROBLEM" horizon $name is not connected: tried $retry times fi if [ "$nbping" -gt "1" ] ; then one=true echo "$PROBLEM" horizon $name is not responding: tried $nbping times fi if [ "$intruder" != "----/--/--_--:--:--" ] ; then one=true echo "$PROBLEM" horizon $name reporting an intruder at $intruder fi if [ "$error" != "" ] ; then one=true echo "$PROBLEM" horizon $name reporting an error: $error fi ;; rule) nbcon=`echo $i | sed 's/nbcon=//'` total=`expr $total + $nbcon` last=`echo $j | sed 's/last=//'` if [ "$last" \> "$lastcon" ] ; then lastcon=$last fi ;; esac done if [ "$one" = "true" ] ; then echo fi echo " Last connection :" $lastcon echo -n " Connection count : " printf "%'d\n" $total | sed 's/ /,/g' echo -n " Conproxy status : " conproxy-control status | grep "active connections" conproxy_stats /var/run/blackhole/conproxy.sock for ((N=0; N<10; N++)) do OLDCONSOCK=/var/run/blackhole/old/conproxy.sock.old$N if conproxy-control -p $OLDCONSOCK status 2>/dev/null >/dev/null then echo -n " Old conproxy status : " echo -n `conproxy-control -p $OLDCONSOCK status | grep "active connections"` echo " " $OLDCONSOCK conproxy_stats $OLDCONSOCK fi done ) echo blackhole-control rejects | while read line do echo " Rejects :" $line done blackhole-control statuserr | while read line do echo " Error :" $line done echo