From 433f1a69aa18e80e35ac50cec83c20d6c6801577 Mon Sep 17 00:00:00 2001 From: rfrail3 Date: Tue, 27 Aug 2013 09:05:12 +0200 Subject: [PATCH 1/2] Adding new plugins for 1.5 version --- .../haproxy/haproxy_bytes_compressor_backend | 123 ++++++++++++++++++ .../haproxy/haproxy_bytes_compressor_frontend | 123 ++++++++++++++++++ .../haproxy_response_compressor_backend | 109 ++++++++++++++++ .../haproxy_response_compressor_frontend | 109 ++++++++++++++++ 4 files changed, 464 insertions(+) create mode 100755 plugins/haproxy/haproxy_bytes_compressor_backend create mode 100755 plugins/haproxy/haproxy_bytes_compressor_frontend create mode 100755 plugins/haproxy/haproxy_response_compressor_backend create mode 100755 plugins/haproxy/haproxy_response_compressor_frontend diff --git a/plugins/haproxy/haproxy_bytes_compressor_backend b/plugins/haproxy/haproxy_bytes_compressor_backend new file mode 100755 index 00000000..e8ea51ec --- /dev/null +++ b/plugins/haproxy/haproxy_bytes_compressor_backend @@ -0,0 +1,123 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_bytes_compressor_backend -Haproxy Bytes Compressor + +=head1 CONFIGURATION + +[haproxy*] + user root + env.backend backend_name_1 backend_name_2 backend_name_3 + env.frontend frontend_name_1 frontend_name_2 frontend_name_3 + # 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 + +Ricardo Fraile + +=head1 LICENSE + +GPLv2 + +=head1 MAGICK MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=cut + +. $MUNIN_LIBDIR/plugins/plugin.sh + +function parse_url { + # Modify ifs variable + OIFS=$IFS; + IFS=","; + PXNAME="$1" + SVNAME="$2" + VALUE="$3" + + 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 + for ((i=0; i<${#ARRAY1[@]}; ++i)); + do + # Get data + if [[ "${ARRAY1[$i]}" == "${VALUE}" ]]; then + o=$i; + o=`expr $o + 1` + echo ${LINE2} | cut -d" " -f $o + fi + done + + # Reset ifs + IFS=$OIFS; +} + + +SVNAME='BACKEND' +LIST="$backend" + + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo "graph_title Bytes compressor ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Bytes' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Bytes compressor ${SVNAME}" + + + for i in ${LIST}; do + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes to compressor $i" + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP response bytes fed to the compressor $i" + + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes out compressor $i" + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP response bytes emitted by the compressor $i" + + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes bypass compressor $i" + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Bytes that bypassed the HTTP compressor $i" + + done + + exit 0 +fi + for i in ${LIST}; do + IN=`parse_url ${i} ${SVNAME} comp_in` + OUT=`parse_url ${i} ${SVNAME} comp_out` + BY=`parse_url ${i} ${SVNAME} comp_byp` + + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $IN" + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $OUT" + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BY" + done + + diff --git a/plugins/haproxy/haproxy_bytes_compressor_frontend b/plugins/haproxy/haproxy_bytes_compressor_frontend new file mode 100755 index 00000000..e99fdfbe --- /dev/null +++ b/plugins/haproxy/haproxy_bytes_compressor_frontend @@ -0,0 +1,123 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_bytes_compressor_backend -Haproxy Bytes Compressor + +=head1 CONFIGURATION + +[haproxy*] + user root + env.backend backend_name_1 backend_name_2 backend_name_3 + env.frontend frontend_name_1 frontend_name_2 frontend_name_3 + # 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 + +Ricardo Fraile + +=head1 LICENSE + +GPLv2 + +=head1 MAGICK MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=cut + +. $MUNIN_LIBDIR/plugins/plugin.sh + +function parse_url { + # Modify ifs variable + OIFS=$IFS; + IFS=","; + PXNAME="$1" + SVNAME="$2" + VALUE="$3" + + 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 + for ((i=0; i<${#ARRAY1[@]}; ++i)); + do + # Get data + if [[ "${ARRAY1[$i]}" == "${VALUE}" ]]; then + o=$i; + o=`expr $o + 1` + echo ${LINE2} | cut -d" " -f $o + fi + done + + # Reset ifs + IFS=$OIFS; +} + + +SVNAME='FRONTEND' +LIST="$frontend" + + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo "graph_title Bytes compressor ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Bytes' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Bytes compressor ${SVNAME}" + + + for i in ${LIST}; do + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes to compressor $i" + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP response bytes fed to the compressor $i" + + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes out compressor $i" + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP response bytes emitted by the compressor $i" + + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes bypass compressor $i" + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Bytes that bypassed the HTTP compressor $i" + + done + + exit 0 +fi + for i in ${LIST}; do + IN=`parse_url ${i} ${SVNAME} comp_in` + OUT=`parse_url ${i} ${SVNAME} comp_out` + BY=`parse_url ${i} ${SVNAME} comp_byp` + + echo "comp_in`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $IN" + echo "comp_out`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $OUT" + echo "comp_byp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BY" + done + + diff --git a/plugins/haproxy/haproxy_response_compressor_backend b/plugins/haproxy/haproxy_response_compressor_backend new file mode 100755 index 00000000..b457dbed --- /dev/null +++ b/plugins/haproxy/haproxy_response_compressor_backend @@ -0,0 +1,109 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_response_compressor_backend -Haproxy Response Compressed + +=head1 CONFIGURATION + +[haproxy*] + user root + env.backend backend_name_1 backend_name_2 backend_name_3 + env.frontend frontend_name_1 frontend_name_2 frontend_name_3 + # 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 + +Ricardo Fraile + +=head1 LICENSE + +GPLv2 + +=head1 MAGICK MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=cut + +. $MUNIN_LIBDIR/plugins/plugin.sh + +function parse_url { + # Modify ifs variable + OIFS=$IFS; + IFS=","; + PXNAME="$1" + SVNAME="$2" + VALUE="$3" + + 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 + for ((i=0; i<${#ARRAY1[@]}; ++i)); + do + # Get data + if [[ "${ARRAY1[$i]}" == "${VALUE}" ]]; then + o=$i; + o=`expr $o + 1` + echo ${LINE2} | cut -d" " -f $o + fi + done + + # Reset ifs + IFS=$OIFS; +} + + +SVNAME='BACKEND' +LIST="$backend" + + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo "graph_title Responses compressed ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Bytes' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info HTTP responses that were compressed ${SVNAME}" + + + for i in ${LIST}; do + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Responses compressed$i" + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses that were compressed $i" + + done + + exit 0 +fi + for i in ${LIST}; do + RSP=`parse_url ${i} ${SVNAME} comp_rsp` + + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RSP" + done + + diff --git a/plugins/haproxy/haproxy_response_compressor_frontend b/plugins/haproxy/haproxy_response_compressor_frontend new file mode 100755 index 00000000..ab657853 --- /dev/null +++ b/plugins/haproxy/haproxy_response_compressor_frontend @@ -0,0 +1,109 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_response_compressor_backend -Haproxy Response Compressed + +=head1 CONFIGURATION + +[haproxy*] + user root + env.backend backend_name_1 backend_name_2 backend_name_3 + env.frontend frontend_name_1 frontend_name_2 frontend_name_3 + # 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 + +Ricardo Fraile + +=head1 LICENSE + +GPLv2 + +=head1 MAGICK MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=cut + +. $MUNIN_LIBDIR/plugins/plugin.sh + +function parse_url { + # Modify ifs variable + OIFS=$IFS; + IFS=","; + PXNAME="$1" + SVNAME="$2" + VALUE="$3" + + 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 + for ((i=0; i<${#ARRAY1[@]}; ++i)); + do + # Get data + if [[ "${ARRAY1[$i]}" == "${VALUE}" ]]; then + o=$i; + o=`expr $o + 1` + echo ${LINE2} | cut -d" " -f $o + fi + done + + # Reset ifs + IFS=$OIFS; +} + + +SVNAME='FRONTEND' +LIST="$frontend" + + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo "graph_title Responses compressed ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Bytes' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info HTTP responses that were compressed ${SVNAME}" + + + for i in ${LIST}; do + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Responses compressed$i" + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses that were compressed $i" + + done + + exit 0 +fi + for i in ${LIST}; do + RSP=`parse_url ${i} ${SVNAME} comp_rsp` + + echo "comp_rsp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RSP" + done + + From ef018d3dd16c700cdf01ef2d08fe9829c24e0db8 Mon Sep 17 00:00:00 2001 From: rfrail3 Date: Tue, 27 Aug 2013 09:08:21 +0200 Subject: [PATCH 2/2] Fix response name --- plugins/haproxy/haproxy_response_compressor_backend | 2 +- plugins/haproxy/haproxy_response_compressor_frontend | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/haproxy/haproxy_response_compressor_backend b/plugins/haproxy/haproxy_response_compressor_backend index b457dbed..b311f13a 100755 --- a/plugins/haproxy/haproxy_response_compressor_backend +++ b/plugins/haproxy/haproxy_response_compressor_backend @@ -84,7 +84,7 @@ if [ "$1" = "config" ]; then echo "graph_title Responses compressed ${SVNAME}" echo 'graph_args --base 1000 -l 0 ' - echo 'graph_vlabel Bytes' + echo 'graph_vlabel Responses' echo 'graph_scale no' echo 'graph_category haproxy' echo "graph_info HTTP responses that were compressed ${SVNAME}" diff --git a/plugins/haproxy/haproxy_response_compressor_frontend b/plugins/haproxy/haproxy_response_compressor_frontend index ab657853..62540ac0 100755 --- a/plugins/haproxy/haproxy_response_compressor_frontend +++ b/plugins/haproxy/haproxy_response_compressor_frontend @@ -84,7 +84,7 @@ if [ "$1" = "config" ]; then echo "graph_title Responses compressed ${SVNAME}" echo 'graph_args --base 1000 -l 0 ' - echo 'graph_vlabel Bytes' + echo 'graph_vlabel Responses' echo 'graph_scale no' echo 'graph_category haproxy' echo "graph_info HTTP responses that were compressed ${SVNAME}"