mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
113 lines
3.0 KiB
Plaintext
113 lines
3.0 KiB
Plaintext
|
#!/bin/bash
|
||
|
# -*- bash -*-
|
||
|
|
||
|
: << =cut
|
||
|
|
||
|
=head1 NAME
|
||
|
|
||
|
haproxy_rate_backend -Haproxy Sessions Per Second 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
|
||
|
env.url http://user:passwd@IP:port/admin?stats;csv
|
||
|
|
||
|
=head1 AUTHOR
|
||
|
|
||
|
Ricardo Fraile <rfrail3@yahoo.es>
|
||
|
|
||
|
=head1 LICENSE
|
||
|
|
||
|
GNU
|
||
|
|
||
|
=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"
|
||
|
LINE1=`curl -s "$url" | head -1 | sed 's/# //'`
|
||
|
LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"`
|
||
|
|
||
|
|
||
|
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
|
||
|
|
||
|
if [ "$1" = "autoconf" ]; then
|
||
|
echo yes
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
if [ "$1" = "config" ]; then
|
||
|
|
||
|
echo "graph_title Sessions per second ${SVNAME}"
|
||
|
echo 'graph_args --base 1000 -l 0 '
|
||
|
echo 'graph_vlabel Sessions'
|
||
|
echo 'graph_scale no'
|
||
|
echo 'graph_category haproxy'
|
||
|
echo "graph_info Sessions per second ${SVNAME}"
|
||
|
|
||
|
|
||
|
for i in ${LIST}; do
|
||
|
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Rate $i"
|
||
|
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE"
|
||
|
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
|
||
|
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Number of sessions per second over last elapsed second $i"
|
||
|
|
||
|
echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Limit $i"
|
||
|
echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE"
|
||
|
echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
|
||
|
echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit on new sessions per second $i"
|
||
|
|
||
|
#echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Max $i"
|
||
|
#echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE"
|
||
|
#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"
|
||
|
|
||
|
done
|
||
|
|
||
|
exit 0
|
||
|
fi
|
||
|
for i in ${LIST}; do
|
||
|
RATE=`parse_url ${i} ${SVNAME} rate`
|
||
|
RATEL=`parse_url ${i} ${SVNAME} rate_lim`
|
||
|
#RATEM=`parse_url ${i} ${SVNAME} rate_max`
|
||
|
|
||
|
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATE"
|
||
|
echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATEL"
|
||
|
#echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATEM"
|
||
|
done
|
||
|
|
||
|
|