/
haproxy_errors_frontend
executable file
·113 lines (80 loc) · 2.91 KB
/
haproxy_errors_frontend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# -*- bash -*-
: << =cut
=head1 NAME
haproxy_errors_frontend -Haproxy Errors Frontend
=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
GPLv2
=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='FRONTEND'
LIST="$frontend"
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo "graph_title Errors ${SVNAME}"
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Errors'
echo 'graph_scale no'
echo 'graph_category haproxy'
echo "graph_info Errors ${SVNAME}"
for i in ${LIST}; do
echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Request Errors $i"
echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Request Errors $i"
#echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Connection Errors $i"
#echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
#echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
#echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Connection Errors $i"
#echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Response Errors $i"
#echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
#echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
#echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Response Errors $i"
done
exit 0
fi
for i in ${LIST}; do
EREQ=`parse_url ${i} ${SVNAME} ereq`
#ECON=`parse_url ${i} ${SVNAME} econ`
#ERESP=`parse_url ${i} ${SVNAME} eresp`
echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $EREQ"
#echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $ECON"
#echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $ERESP"
done