Projet

Général

Profil

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

root / plugins / haproxy / haproxy_bytes_frontend @ a717a913

Historique | Voir | Annoter | Télécharger (2,73 ko)

1
#!/bin/bash
2
# -*- bash -*-
3

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
haproxy_bytes_frontend -Haproxy Bytes Frontend
9

    
10
=head1 CONFIGURATION
11

    
12
[haproxy*]
13
  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
  env.url  http://user:passwd@IP:port/admin?stats;csv
17

    
18
=head1 AUTHOR
19

    
20
Ricardo Fraile <rfrail3@yahoo.es>
21

    
22
=head1 LICENSE
23

    
24
GPLv2
25

    
26
=head1 MAGICK MARKERS
27

    
28
 #%# family=auto
29
 #%# capabilities=autoconf
30

    
31
=cut
32

    
33
. $MUNIN_LIBDIR/plugins/plugin.sh
34

    
35
function parse_url {
36
        # Modify ifs variable
37
        OIFS=$IFS;
38
        IFS=",";
39
        PXNAME="$1"
40
        SVNAME="$2"
41
        VALUE="$3"
42
        LINE1=`curl -s "$url" | head -1 | sed 's/# //'`
43
        LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"`
44
        
45
        
46
        ARRAY1=($LINE1);
47

    
48
        # Find values
49
        for ((i=0; i<${#ARRAY1[@]}; ++i));
50
        do
51
                # Get data
52
                if [[ "${ARRAY1[$i]}" == "${VALUE}" ]]; then
53
                        o=$i;
54
                        o=`expr $o + 1`
55
                        echo ${LINE2} | cut -d" " -f $o
56
                fi
57
        done
58

    
59
        # Reset ifs
60
        IFS=$OIFS;
61
}
62

    
63
SVNAME='FRONTEND'
64
LIST=$frontend
65

    
66

    
67
if [ "$1" = "autoconf" ]; then
68
	echo yes 
69
	exit 0
70
fi
71

    
72
if [ "$1" = "config" ]; then
73

    
74
	echo "graph_title Bytes ${SVNAME}"
75
	echo 'graph_args --base 1000'
76
	echo 'graph_vlabel Bytes in (-) / out (+)'
77
	echo 'graph_category haproxy'
78
	echo "graph_info Bytes ${SVNAME}"
79

    
80

    
81
for i in ${LIST}; do
82

    
83
	        echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes $i"
84
        	echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
85
        	echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.graph no"
86
	       	echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.cdef down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`,8,*"
87
	       	echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
88

    
89
	        echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes $i"
90
        	echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
91
        	echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.negative down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`"
92
	       	echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.cdef up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`,8,*"
93
        	echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Bytes in $i"
94
	       	echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
95
done
96
	exit 0
97
fi
98
	for i in ${LIST}; do
99
		BIN=`parse_url ${i} ${SVNAME} bin`
100
		BOUT=`parse_url ${i} ${SVNAME} bout`
101
	        echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BOUT"
102
	        echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BIN"
103
	done	
104