Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / haproxy / haproxy_bytes_compressor_frontend @ 09b88141

Historique | Voir | Annoter | Télécharger (3,44 ko)

1 433f1a69 rfrail3
#!/bin/bash
2
# -*- bash -*-
3
4
: << =cut
5
6
=head1 NAME
7
8
haproxy_bytes_compressor_backend -Haproxy Bytes Compressor
9
10
=head1 CONFIGURATION
11
12 09b88141 Lars Kruse
  [haproxy*]
13 433f1a69 rfrail3
  user root
14
  env.backend backend_name_1 backend_name_2 backend_name_3
15
  env.frontend frontend_name_1 frontend_name_2 frontend_name_3
16
  # You can use url o socket option, use one of them, not both!
17
    env.url  http://user:passwd@IP:port/admin?stats;csv
18
  #  or
19
    env.socket /var/lib/haproxy/stats.socket
20
21
=head1 AUTHOR
22
23
Ricardo Fraile <rfrail3@yahoo.es>
24
25
=head1 LICENSE
26
27
GPLv2
28
29
=head1 MAGICK MARKERS
30
31
 #%# family=auto
32
 #%# capabilities=autoconf
33
34
=cut
35
36
. $MUNIN_LIBDIR/plugins/plugin.sh
37
38
function parse_url {
39
        # Modify ifs variable
40
        OIFS=$IFS;
41
        IFS=",";
42
        PXNAME="$1"
43
        SVNAME="$2"
44
        VALUE="$3"
45
46
	if [ ! -z "$url" ]; then
47
		LINE1=`curl -s "$url" | head -1 | sed 's/# //'`
48
	        LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"`
49
        fi
50
51
	if [ ! -z "$socket" ]; then
52
                LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'`
53 17f78427 Lars Kruse
                LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"`
54 433f1a69 rfrail3
        fi
55 17f78427 Lars Kruse
56 433f1a69 rfrail3
        ARRAY1=($LINE1);
57
58
        # Find values
59
        for ((i=0; i<${#ARRAY1[@]}; ++i));
60
        do
61
                # Get data
62
                if [[ "${ARRAY1[$i]}" == "${VALUE}" ]]; then
63
                        o=$i;
64
                        o=`expr $o + 1`
65
                        echo ${LINE2} | cut -d" " -f $o
66
                fi
67
        done
68
69
        # Reset ifs
70
        IFS=$OIFS;
71
}
72
73
74
SVNAME='FRONTEND'
75
LIST="$frontend"
76
77
78
if [ "$1" = "autoconf" ]; then
79 17f78427 Lars Kruse
	echo yes
80 433f1a69 rfrail3
	exit 0
81
fi
82
83
if [ "$1" = "config" ]; then
84
85
	echo "graph_title Bytes compressor ${SVNAME}"
86
	echo 'graph_args --base 1000 -l 0 '
87
	echo 'graph_vlabel Bytes'
88
	echo 'graph_scale no'
89 a3c2338b dipohl
	echo 'graph_category loadbalancer'
90 433f1a69 rfrail3
	echo "graph_info Bytes compressor ${SVNAME}"
91
92
93
	for i in ${LIST}; do
94
	        echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes to compressor $i"
95
        	echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
96
	        echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
97
        	echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP response bytes fed to the compressor $i"
98
99
	        echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes out compressor $i"
100
        	echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
101
	        echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
102
        	echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP response bytes emitted by the compressor $i"
103
104
	        echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes bypass compressor $i"
105
        	echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
106
	        echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
107
        	echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Bytes that bypassed the HTTP compressor $i"
108
109
	done
110
111
	exit 0
112
fi
113
	for i in ${LIST}; do
114
		IN=`parse_url ${i} ${SVNAME} comp_in`
115
		OUT=`parse_url ${i} ${SVNAME} comp_out`
116
		BY=`parse_url ${i} ${SVNAME} comp_byp`
117
118
	        echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $IN"
119
	        echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $OUT"
120
	        echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BY"
121
	done
122 17f78427 Lars Kruse