Révision 4f29ff59
Add support for sockets
| plugins/haproxy/haproxy_rate_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 |
| ... | ... | |
| 96 | 107 |
#echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" |
| 97 | 108 |
#echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Max number of new sessions per second $i" |
| 98 | 109 |
|
| 110 |
RATEL=`parse_url ${i} ${SVNAME} rate_lim`
|
|
| 111 |
if [[ "$RATEL" =~ ^[0-9]+$ ]] && [[ "$RATEL" != 0 ]]; then |
|
| 112 |
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $RATEL" |
|
| 113 |
fi |
|
| 114 |
|
|
| 115 |
if [[ "$RATEL" =~ ^[0-9]+$ ]] && [[ "$RATEL" != 0 ]]; then |
|
| 116 |
echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${RATEL}*${WARN_PERCENT}/100))"
|
|
| 117 |
fi |
|
| 99 | 118 |
done |
| 100 | 119 |
|
| 101 | 120 |
exit 0 |
Formats disponibles : Unified diff