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_sessions_frontend -Haproxy Sessions Frontend
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='FRONTEND'
LIST="$frontend"
WARN_PERCENT="80"
if [ "$1" = "autoconf" ]; then
@ -95,6 +106,14 @@ if [ "$1" = "config" ]; then
echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE"
echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit Sessions $i"
SLIM=`parse_url ${i} ${SVNAME} slim`
if [[ "$SLIM" =~ ^[0-9]+$ ]] && [[ "$SLIM" != 0 ]]; then
echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $SLIM"
fi
if [[ "$SLIM" =~ ^[0-9]+$ ]] && [[ "$SLIM" != 0 ]]; then
echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${SLIM}*${WARN_PERCENT}/100))"
fi
done
exit 0