From 4f29ff59b13c0fae4c46eb7d9ee8f03256661965 Mon Sep 17 00:00:00 2001 From: rfrail3 Date: Mon, 17 Sep 2012 10:49:02 +0200 Subject: [PATCH] Add support for sockets --- plugins/haproxy/haproxy_abort_backend | 18 +++++++--- plugins/haproxy/haproxy_active_backend | 16 +++++++-- plugins/haproxy/haproxy_bytes_backend | 16 +++++++-- plugins/haproxy/haproxy_bytes_frontend | 16 +++++++-- plugins/haproxy/haproxy_denied_backend | 16 +++++++-- plugins/haproxy/haproxy_denied_frontend | 16 +++++++-- plugins/haproxy/haproxy_errors_backend | 16 +++++++-- plugins/haproxy/haproxy_errors_frontend | 16 +++++++-- plugins/haproxy/haproxy_queue_backend | 33 +++++++++++++++++-- plugins/haproxy/haproxy_rate_backend | 26 +++++++++++++-- plugins/haproxy/haproxy_rate_frontend | 25 ++++++++++++-- plugins/haproxy/haproxy_reqrate_frontend | 16 +++++++-- plugins/haproxy/haproxy_responses_backend | 17 ++++++++-- plugins/haproxy/haproxy_responses_frontend | 21 +++++++++--- plugins/haproxy/haproxy_sessions_backend | 25 ++++++++++++-- plugins/haproxy/haproxy_sessions_frontend | 25 ++++++++++++-- .../haproxy/haproxy_sessions_total_backend | 16 +++++++-- .../haproxy/haproxy_sessions_total_frontend | 16 +++++++-- plugins/haproxy/haproxy_warnings_backend | 16 +++++++-- 19 files changed, 306 insertions(+), 60 deletions(-) diff --git a/plugins/haproxy/haproxy_abort_backend b/plugins/haproxy/haproxy_abort_backend index 5f0c4fa0..68fc33f2 100755 --- a/plugins/haproxy/haproxy_abort_backend +++ b/plugins/haproxy/haproxy_abort_backend @@ -13,7 +13,10 @@ haproxy_aborts_backend -Haproxy Aborts Backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` - + + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_active_backend b/plugins/haproxy/haproxy_active_backend index bf3b365e..70fce73b 100755 --- a/plugins/haproxy/haproxy_active_backend +++ b/plugins/haproxy/haproxy_active_backend @@ -13,7 +13,10 @@ haproxy_active_backend -Haproxy servers active backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); # Find values diff --git a/plugins/haproxy/haproxy_bytes_backend b/plugins/haproxy/haproxy_bytes_backend index 6ea61850..c5d45d81 100755 --- a/plugins/haproxy/haproxy_bytes_backend +++ b/plugins/haproxy/haproxy_bytes_backend @@ -13,7 +13,10 @@ haproxy_bytes_backend -Haproxy Bytes Backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_bytes_frontend b/plugins/haproxy/haproxy_bytes_frontend index accad05d..fb78bc1c 100755 --- a/plugins/haproxy/haproxy_bytes_frontend +++ b/plugins/haproxy/haproxy_bytes_frontend @@ -13,7 +13,10 @@ haproxy_bytes_frontend -Haproxy Bytes Frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_denied_backend b/plugins/haproxy/haproxy_denied_backend index 31629d66..5ff8cbe4 100755 --- a/plugins/haproxy/haproxy_denied_backend +++ b/plugins/haproxy/haproxy_denied_backend @@ -13,7 +13,10 @@ haproxy_denied_backend -Haproxy Denied Backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_denied_frontend b/plugins/haproxy/haproxy_denied_frontend index fd785e7e..3a5bde42 100755 --- a/plugins/haproxy/haproxy_denied_frontend +++ b/plugins/haproxy/haproxy_denied_frontend @@ -13,7 +13,10 @@ haproxy_denied_frontend -Haproxy Denied Frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_errors_backend b/plugins/haproxy/haproxy_errors_backend index efe4d6ef..36303309 100755 --- a/plugins/haproxy/haproxy_errors_backend +++ b/plugins/haproxy/haproxy_errors_backend @@ -13,7 +13,10 @@ haproxy_errors_backend -Haproxy Errors Backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_errors_frontend b/plugins/haproxy/haproxy_errors_frontend index 735ded15..d01005d5 100755 --- a/plugins/haproxy/haproxy_errors_frontend +++ b/plugins/haproxy/haproxy_errors_frontend @@ -13,7 +13,10 @@ haproxy_errors_frontend -Haproxy Errors Frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_queue_backend b/plugins/haproxy/haproxy_queue_backend index c49e410d..9b2ef1b5 100755 --- a/plugins/haproxy/haproxy_queue_backend +++ b/plugins/haproxy/haproxy_queue_backend @@ -13,7 +13,10 @@ haproxy_queue_backend -Haproxy Queued Requests Backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); @@ -63,6 +73,7 @@ function parse_url { SVNAME='BACKEND' LIST=$backend +WARN_PERCENT="80" @@ -91,6 +102,20 @@ if [ "$1" = "config" ]; then #echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" #echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" #echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Max queued request $i" + + echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Limit request `echo $i | awk -F. '{print $NF}'`" + echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit request `echo $i | awk -F. '{print $NF}'`" + + QLIM=`parse_url ${i} ${SVNAME} qlimit` + if [[ "$QLIM" =~ ^[0-9]+$ ]] && [[ "$QLIM" != 0 ]]; then + echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $QLIM" + fi + + if [[ "$QLIM" =~ ^[0-9]+$ ]] && [[ "$QLIM" != 0 ]]; then + echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${QLIM}*${WARN_PERCENT}/100))" + fi done exit 0 @@ -98,8 +123,10 @@ fi for i in ${LIST}; do QCUR=`parse_url ${i} ${SVNAME} qcur` #QMAX=`parse_url ${i} ${SVNAME} qmax` + QLIM=`parse_url ${i} ${SVNAME} qlimit` echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $QCUR" + echo "qlim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $QLIM" #echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $QMAX" done diff --git a/plugins/haproxy/haproxy_rate_backend b/plugins/haproxy/haproxy_rate_backend index 7d2b161a..e369ebe4 100755 --- a/plugins/haproxy/haproxy_rate_backend +++ b/plugins/haproxy/haproxy_rate_backend @@ -13,7 +13,10 @@ haproxy_rate_backend -Haproxy Sessions Per Second Backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); @@ -63,6 +73,7 @@ function parse_url { SVNAME='BACKEND' LIST=$backend +WARN_PERCENT="80" if [ "$1" = "autoconf" ]; then echo yes @@ -95,6 +106,15 @@ if [ "$1" = "config" ]; then #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Max number of new sessions per second $i" + RATEL=`parse_url ${i} ${SVNAME} rate_lim` + if [[ "$RATEL" =~ ^[0-9]+$ ]] && [[ "$RATEL" != 0 ]]; then + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $RATEL" + fi + + if [[ "$RATEL" =~ ^[0-9]+$ ]] && [[ "$RATEL" != 0 ]]; then + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${RATEL}*${WARN_PERCENT}/100))" + fi + done exit 0 diff --git a/plugins/haproxy/haproxy_rate_frontend b/plugins/haproxy/haproxy_rate_frontend index ee1b21e2..6701b0d1 100755 --- a/plugins/haproxy/haproxy_rate_frontend +++ b/plugins/haproxy/haproxy_rate_frontend @@ -13,7 +13,10 @@ harpoxy_rate_frontend -Haproxy Sessions Per Second Frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); @@ -63,6 +73,7 @@ function parse_url { SVNAME='FRONTEND' LIST=$frontend +WARN_PERCENT="80" if [ "$1" = "autoconf" ]; then @@ -96,6 +107,14 @@ if [ "$1" = "config" ]; then #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Max number of new sessions per second $i" + RATEL=`parse_url ${i} ${SVNAME} rate_lim` + if [[ "$RATEL" =~ ^[0-9]+$ ]] && [[ "$RATEL" != 0 ]]; then + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $RATEL" + fi + + if [[ "$RATEL" =~ ^[0-9]+$ ]] && [[ "$RATEL" != 0 ]]; then + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${RATEL}*${WARN_PERCENT}/100))" + fi done exit 0 diff --git a/plugins/haproxy/haproxy_reqrate_frontend b/plugins/haproxy/haproxy_reqrate_frontend index ecc160a7..c1cf9bb5 100755 --- a/plugins/haproxy/haproxy_reqrate_frontend +++ b/plugins/haproxy/haproxy_reqrate_frontend @@ -13,7 +13,10 @@ haproxy_reqrate_frontend -Haproxy request rate frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_responses_backend b/plugins/haproxy/haproxy_responses_backend index 5998929d..2191e449 100755 --- a/plugins/haproxy/haproxy_responses_backend +++ b/plugins/haproxy/haproxy_responses_backend @@ -13,7 +13,10 @@ haproxy_responses_backend -Haproxy responses backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,8 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_responses_frontend b/plugins/haproxy/haproxy_responses_frontend index ba993ceb..e4f6537f 100755 --- a/plugins/haproxy/haproxy_responses_frontend +++ b/plugins/haproxy/haproxy_responses_frontend @@ -13,7 +13,10 @@ haproxy_responses_frontend -Haproxy responses frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,8 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); @@ -119,12 +130,12 @@ fi H3xx=`parse_url ${i} ${SVNAME} hrsp_3xx` H4xx=`parse_url ${i} ${SVNAME} hrsp_4xx` H5xx=`parse_url ${i} ${SVNAME} hrsp_5xx` - Hoxx=`parse_url ${i} ${SVNAME} hrsp_other` + Hother=`parse_url ${i} ${SVNAME} hrsp_other` echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $H1xx" echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $H2xx" echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $H3xx" echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $H4xx" echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $H5xx" - echo "hrsp_oxx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $Hoxx" + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $Hother" done diff --git a/plugins/haproxy/haproxy_sessions_backend b/plugins/haproxy/haproxy_sessions_backend index 12e5172f..e4a23e60 100755 --- a/plugins/haproxy/haproxy_sessions_backend +++ b/plugins/haproxy/haproxy_sessions_backend @@ -13,7 +13,10 @@ haproxy_sessions_backend -Haproxy Sessions Backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); @@ -63,6 +73,7 @@ function parse_url { SVNAME='BACKEND' LIST="$backend" +WARN_PERCENT="80" if [ "$1" = "autoconf" ]; then @@ -95,6 +106,14 @@ if [ "$1" = "config" ]; then echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit Sessions $i" + + SLIM=`parse_url ${i} ${SVNAME} slim` + if [[ "$SLIM" =~ ^[0-9]+$ ]] && [[ "$SLIM" != 0 ]]; then + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $SLIM" + fi + if [[ "$SLIM" =~ ^[0-9]+$ ]] && [[ "$SLIM" != 0 ]]; then + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${SLIM}*${WARN_PERCENT}/100))" + fi done exit 0 diff --git a/plugins/haproxy/haproxy_sessions_frontend b/plugins/haproxy/haproxy_sessions_frontend index 528ecd19..d41e26a3 100755 --- a/plugins/haproxy/haproxy_sessions_frontend +++ b/plugins/haproxy/haproxy_sessions_frontend @@ -13,7 +13,10 @@ haproxy_sessions_frontend -Haproxy Sessions Frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); @@ -63,6 +73,7 @@ function parse_url { SVNAME='FRONTEND' LIST="$frontend" +WARN_PERCENT="80" if [ "$1" = "autoconf" ]; then @@ -95,6 +106,14 @@ if [ "$1" = "config" ]; then echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit Sessions $i" + + SLIM=`parse_url ${i} ${SVNAME} slim` + if [[ "$SLIM" =~ ^[0-9]+$ ]] && [[ "$SLIM" != 0 ]]; then + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.critical $SLIM" + fi + if [[ "$SLIM" =~ ^[0-9]+$ ]] && [[ "$SLIM" != 0 ]]; then + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.warning $((${SLIM}*${WARN_PERCENT}/100))" + fi done exit 0 diff --git a/plugins/haproxy/haproxy_sessions_total_backend b/plugins/haproxy/haproxy_sessions_total_backend index 2b277b24..629eec4f 100755 --- a/plugins/haproxy/haproxy_sessions_total_backend +++ b/plugins/haproxy/haproxy_sessions_total_backend @@ -13,7 +13,10 @@ haproxy_sessions_total_frontend -Haproxy Sessions Total Frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_sessions_total_frontend b/plugins/haproxy/haproxy_sessions_total_frontend index d2fc2996..cce846a2 100755 --- a/plugins/haproxy/haproxy_sessions_total_frontend +++ b/plugins/haproxy/haproxy_sessions_total_frontend @@ -13,7 +13,10 @@ haprxoy_sessions_total_frontend -Haproxy Sessions Total Frontend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1); diff --git a/plugins/haproxy/haproxy_warnings_backend b/plugins/haproxy/haproxy_warnings_backend index 53130ab2..0af79282 100755 --- a/plugins/haproxy/haproxy_warnings_backend +++ b/plugins/haproxy/haproxy_warnings_backend @@ -13,7 +13,10 @@ haproxy_warnings_backend -Haproxy Warnings Backend user root env.backend backend_name_1 backend_name_2 backend_name_3 env.frontend frontend_name_1 frontend_name_2 frontend_name_3 - env.url http://user:passwd@IP:port/admin?stats;csv + # You can use url o socket option, use one of them, not both! + env.url http://user:passwd@IP:port/admin?stats;csv + # or + env.socket /var/lib/haproxy/stats.socket =head1 AUTHOR @@ -39,9 +42,16 @@ function parse_url { PXNAME="$1" SVNAME="$2" VALUE="$3" - LINE1=`curl -s "$url" | head -1 | sed 's/# //'` - LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + if [ ! -z "$url" ]; then + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + fi + + if [ ! -z "$socket" ]; then + LINE1=`echo 'show stat' | socat unix-connect:"$socket" stdio | head -1 | sed 's/# //'` + LINE2=`echo 'show stat' | socat unix-connect:"$socket" stdio | grep "$PXNAME,$SVNAME"` + fi ARRAY1=($LINE1);