Projet

Général

Profil

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

root / plugins / haproxy / haproxy_sessions_total_frontend @ a717a913

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

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

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
haprxoy_sessions_total_frontend -Haproxy Sessions Total 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

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

    
67

    
68

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

    
74
if [ "$1" = "config" ]; then
75

    
76
	echo "graph_title Total sessions ${SVNAME}"
77
	echo 'graph_args --base 1000 -l 0 '
78
	echo 'graph_vlabel Sessions'
79
	echo 'graph_scale no'
80
	echo 'graph_category haproxy'
81
	echo "graph_info Total sessions ${SVNAME}"
82

    
83

    
84
	for i in ${LIST}; do
85
	        echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Total Sessions $i"
86
        	echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE"
87
	        echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
88
        	echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Total Sessions $i"
89

    
90
	done
91

    
92
	exit 0
93
fi
94
	for i in ${LIST}; do
95
		STOT=`parse_url ${i} ${SVNAME} stot`
96

    
97
	        echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $STOT"
98
	done
99
	
100