2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/haproxy/haproxy_queue_backend

134 lines
3.9 KiB
Plaintext
Raw Normal View History

2012-09-11 10:53:58 +02:00
#!/bin/bash
# -*- bash -*-
: << =cut
=head1 NAME
haproxy_queue_backend -Haproxy Queued Requests Backend
=head1 CONFIGURATION
[haproxy*]
user root
env.backend backend_name_1 backend_name_2 backend_name_3
env.frontend frontend_name_1 frontend_name_2 frontend_name_3
2012-09-17 10:49:02 +02:00
# 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
2012-09-11 10:53:58 +02:00
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
2012-09-14 09:27:38 +02:00
GPLv2
2012-09-11 10:53:58 +02:00
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
function parse_url {
# Modify ifs variable
OIFS=$IFS;
IFS=",";
PXNAME="$1"
SVNAME="$2"
VALUE="$3"
2012-09-17 10:49:02 +02:00
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
2012-09-11 10:53:58 +02:00
ARRAY1=($LINE1);
# Find values
for ((i=0; i<${#ARRAY1[@]}; ++i));
do
# Get data
if [[ "${ARRAY1[$i]}" == "${VALUE}" ]]; then
o=$i;
o=`expr $o + 1`
echo ${LINE2} | cut -d" " -f $o
fi
done
# Reset ifs
IFS=$OIFS;
}
SVNAME='BACKEND'
LIST=$backend
2012-09-17 10:49:02 +02:00
WARN_PERCENT="80"
2012-09-11 10:53:58 +02:00
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Queued Request ${SVNAME}"
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Queued'
echo 'graph_scale no'
echo 'graph_category haproxy'
echo "graph_info Queue Requests ${SVNAME}"
for i in ${LIST}; do
echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Current queued request $i"
echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE"
echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Current queued request $i"
#echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Max $i"
#echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE"
#echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
#echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Max queued request $i"
2012-09-17 10:49:02 +02:00
echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Limit request `echo $i | awk -F. '{print $NF}'`"
echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE"
echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit request `echo $i | awk -F. '{print $NF}'`"
QLIM=`parse_url ${i} ${SVNAME} qlimit`
if [[ "$QLIM" =~ ^[0-9]+$ ]] && [[ "$QLIM" != 0 ]]; then
echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $QLIM"
fi
if [[ "$QLIM" =~ ^[0-9]+$ ]] && [[ "$QLIM" != 0 ]]; then
echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${QLIM}*${WARN_PERCENT}/100))"
fi
2012-09-11 10:53:58 +02:00
done
exit 0
fi
for i in ${LIST}; do
QCUR=`parse_url ${i} ${SVNAME} qcur`
#QMAX=`parse_url ${i} ${SVNAME} qmax`
2012-09-17 10:49:02 +02:00
QLIM=`parse_url ${i} ${SVNAME} qlimit`
2012-09-11 10:53:58 +02:00
echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $QCUR"
2012-09-17 10:49:02 +02:00
echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $QLIM"
2012-09-11 10:53:58 +02:00
#echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $QMAX"
done