1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

Add support for sockets

This commit is contained in:
rfrail3 2012-09-17 10:49:02 +02:00
parent a717a91344
commit 4f29ff59b1
19 changed files with 306 additions and 60 deletions

View file

@ -13,7 +13,10 @@ haproxy_rate_backend -Haproxy Sessions Per Second Backend
user root
env.backend backend_name_1 backend_name_2 backend_name_3
env.frontend frontend_name_1 frontend_name_2 frontend_name_3
env.url http://user:passwd@IP:port/admin?stats;csv
# You can use url o socket option, use one of them, not both!
env.url http://user:passwd@IP:port/admin?stats;csv
# or
env.socket /var/lib/haproxy/stats.socket
=head1 AUTHOR
@ -39,9 +42,16 @@ function parse_url {
PXNAME="$1"
SVNAME="$2"
VALUE="$3"
LINE1=`curl -s "$url" | head -1 | sed 's/# //'`
LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"`
if [ ! -z "$url" ]; then
LINE1=`curl -s "$url" | head -1 | sed 's/# //'`
LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"`
fi
if [ ! -z "$socket" ]; then
LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'`
LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"`
fi
ARRAY1=($LINE1);
@ -63,6 +73,7 @@ function parse_url {
SVNAME='BACKEND'
LIST=$backend
WARN_PERCENT="80"
if [ "$1" = "autoconf" ]; then
echo yes
@ -95,6 +106,15 @@ if [ "$1" = "config" ]; then
#echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
#echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Max number of new sessions per second $i"
RATEL=`parse_url ${i} ${SVNAME} rate_lim`
if [[ "$RATEL" =~ ^[0-9]+$ ]] && [[ "$RATEL" != 0 ]]; then
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $RATEL"
fi
if [[ "$RATEL" =~ ^[0-9]+$ ]] && [[ "$RATEL" != 0 ]]; then
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${RATEL}*${WARN_PERCENT}/100))"
fi
done
exit 0