Projet

Général

Profil

Révision 4f29ff59

ID4f29ff59b13c0fae4c46eb7d9ee8f03256661965
Parent a717a913
Enfant 73bf794a, 4771fd2b

Ajouté par rfrail3 il y a environ 13 ans

Add support for sockets

Voir les différences:

plugins/haproxy/haproxy_sessions_frontend
13 13
  user root
14 14
  env.backend backend_name_1 backend_name_2 backend_name_3
15 15
  env.frontend frontend_name_1 frontend_name_2 frontend_name_3
16
  env.url  http://user:passwd@IP:port/admin?stats;csv
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
17 20

  
18 21
=head1 AUTHOR
19 22

  
......
39 42
        PXNAME="$1"
40 43
        SVNAME="$2"
41 44
        VALUE="$3"
42
        LINE1=`curl -s "$url" | head -1 | sed 's/# //'`
43
        LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"`
44 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
                LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"`
54
        fi
45 55
        
46 56
        ARRAY1=($LINE1);
47 57

  
......
63 73

  
64 74
SVNAME='FRONTEND'
65 75
LIST="$frontend"
76
WARN_PERCENT="80"
66 77

  
67 78

  
68 79
if [ "$1" = "autoconf" ]; then
......
95 106
        	echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE"
96 107
	        echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0"
97 108
        	echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit Sessions $i"
109

  
110
		SLIM=`parse_url ${i} ${SVNAME} slim`
111
                if [[ "$SLIM" =~ ^[0-9]+$ ]] && [[ "$SLIM" != 0 ]]; then
112
                   echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $SLIM"
113
                fi
114
                if [[ "$SLIM" =~ ^[0-9]+$ ]] && [[ "$SLIM" != 0 ]]; then
115
                        echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${SLIM}*${WARN_PERCENT}/100))"
116
                fi
98 117
	done
99 118

  
100 119
	exit 0

Formats disponibles : Unified diff