From e9ce5f96335af94f932425e3c7af880c563667e3 Mon Sep 17 00:00:00 2001 From: ricardo Date: Mon, 27 Aug 2012 14:08:54 +0200 Subject: [PATCH 1/6] tomcat access plugin --- plugins/tomcat/tomcat_access | 116 +++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 plugins/tomcat/tomcat_access diff --git a/plugins/tomcat/tomcat_access b/plugins/tomcat/tomcat_access new file mode 100755 index 00000000..12058dd2 --- /dev/null +++ b/plugins/tomcat/tomcat_access @@ -0,0 +1,116 @@ +#!/usr/bin/perl +# -*- perl -*- + +=head1 NAME + +tomcat_access - Plugin to monitor the number of accesses to Tomcat +servers. + +=head1 CONFIGURATION + +The following environment variables are used by this plugin + + timeout - Connection timeout + url - Override default status-url + ports - HTTP port numbers + user - Manager username + password - Manager password + +=head1 USAGE + +Requirements: + +Needs access to +http://:@localhost:8080/manager/status?XML=true (or +modify the address for another host). + +Tomcat 5.0 or higher. + +A munin-user in $CATALINA_HOME/conf/tomcat-users.xml should be set up +for this to work. + +Tip: To see if it's already set up correctly, just run this plugin +with the parameter "autoconf". If you get a "yes", everything should +work like a charm already. + +tomcat-users.xml example: + + +=head1 AUTHOR + +Ricardo Fraile +Rune Nordbøe Skillingstad + +=head1 LICENSE + +Unknown license + +=head1 MAGIC MARKERS + + #%# family=manual + #%# capabilities=autoconf + +=cut + +use strict; + +my $ret = undef; + +if(!eval "require LWP::UserAgent;") { + $ret = "LWP::UserAgent not found"; +} + +if(!eval "require XML::Simple;") { + $ret .= "XML::Simple not found"; +} + +my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://%s:%s\@127.0.0.1:%d/manager/status?XML=true"; +my $PORT = exists $ENV{'ports'} ? $ENV{'ports'} : 8080; +my $PORTAJP = exists $ENV{'portajp'} ? $ENV{'portajp'} : 8009; +my $USER = exists $ENV{'user'} ? $ENV{'user'} : "munin"; +my $PASSWORD = exists $ENV{'password'} ? $ENV{'password'} : "munin"; +my $TIMEOUT = exists $ENV{'timeout'} ? $ENV{'timeout'} : 30; + +my $url = sprintf $URL, $USER, $PASSWORD, $PORT; + +if(exists $ARGV[0] and $ARGV[0] eq "autoconf") { + if($ret) { + print "no ($ret)\n"; + exit 0; + } + my $au = LWP::UserAgent->new(timeout => $TIMEOUT); + my $repsonse = $au->request(HTTP::Request->new('GET',$url)); + if($repsonse->is_success and $repsonse->content =~ /.*<\/status>/im) { + print "yes\n"; + exit 0; + } else { + print "no (no tomcat status)\n"; + exit 0; + } +} + +if(exists $ARGV[0] and $ARGV[0] eq "config") { + print "graph_title Tomcat accesses\n"; + print "graph_args --base 1000\n"; + print "graph_vlabel accesses / \${graph_period}\n"; + print "graph_category tomcat\n"; + print "accesses.label Accesses\n"; + print "accesses.type DERIVE\n"; + print "accesses.max 1000000\n"; + print "accesses.min 0\n"; + exit 0; +} + +my $ua = LWP::UserAgent->new(timeout => $TIMEOUT); +my $xs = new XML::Simple; +my $response = $ua->request(HTTP::Request->new('GET',$url)); +my %options = ( KeyAttr => { connector => 'name' }, ForceArray => 1 ); +my $xml = $xs->XMLin($response->content, %options); + +if($xml->{'connector'}->{"\"".$PORTAJP."\""}->{'requestInfo'}->[0]->{'requestCount'}) { + print "accesses.value " . $xml->{'connector'}->{"\"".$PORTAJP."\""}->{'requestInfo'}->[0]->{'requestCount'} . "\n"; +} else { + print "accesses.value U\n"; +} + +# vim:syntax=perl From 2cbf4a93b690b62bac4768a1c38a7965ce32ead3 Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 28 Aug 2012 11:26:00 +0200 Subject: [PATCH 2/6] tomcat access plugin --- plugins/tomcat/tomcat_access | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/tomcat/tomcat_access b/plugins/tomcat/tomcat_access index 12058dd2..35b3a759 100755 --- a/plugins/tomcat/tomcat_access +++ b/plugins/tomcat/tomcat_access @@ -43,7 +43,7 @@ Rune Nordb =head1 LICENSE -Unknown license +GPL 2. =head1 MAGIC MARKERS @@ -66,7 +66,7 @@ if(!eval "require XML::Simple;") { my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://%s:%s\@127.0.0.1:%d/manager/status?XML=true"; my $PORT = exists $ENV{'ports'} ? $ENV{'ports'} : 8080; -my $PORTAJP = exists $ENV{'portajp'} ? $ENV{'portajp'} : 8009; +my $PNAME = exists $ENV{'pname'} ? $ENV{'pname'} : "http-8080"; my $USER = exists $ENV{'user'} ? $ENV{'user'} : "munin"; my $PASSWORD = exists $ENV{'password'} ? $ENV{'password'} : "munin"; my $TIMEOUT = exists $ENV{'timeout'} ? $ENV{'timeout'} : 30; @@ -107,8 +107,8 @@ my $response = $ua->request(HTTP::Request->new('GET',$url)); my %options = ( KeyAttr => { connector => 'name' }, ForceArray => 1 ); my $xml = $xs->XMLin($response->content, %options); -if($xml->{'connector'}->{"\"".$PORTAJP."\""}->{'requestInfo'}->[0]->{'requestCount'}) { - print "accesses.value " . $xml->{'connector'}->{"\"".$PORTAJP."\""}->{'requestInfo'}->[0]->{'requestCount'} . "\n"; +if($xml->{'connector'}->{"\"".$PNAME."\""}->{'requestInfo'}->[0]->{'requestCount'}) { + print "accesses.value " . $xml->{'connector'}->{"\"".$PNAME."\""}->{'requestInfo'}->[0]->{'requestCount'} . "\n"; } else { print "accesses.value U\n"; } From 68b65c84ba0e4f25d1d58ad9749dbde2a60b452f Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 28 Aug 2012 11:27:43 +0200 Subject: [PATCH 3/6] tomcat access plugin --- plugins/tomcat/tomcat_access | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/tomcat/tomcat_access b/plugins/tomcat/tomcat_access index 35b3a759..bdf401d4 100755 --- a/plugins/tomcat/tomcat_access +++ b/plugins/tomcat/tomcat_access @@ -13,6 +13,7 @@ The following environment variables are used by this plugin timeout - Connection timeout url - Override default status-url ports - HTTP port numbers + pname - Nome of the connector user - Manager username password - Manager password From 706e7e9104cf9465a10281e7488a5444283ecfd6 Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 11 Sep 2012 10:53:58 +0200 Subject: [PATCH 4/6] Haproxy monitoring --- plugins/haproxy/haproxy_abort_backend | 106 ++++++++++++++ plugins/haproxy/haproxy_active_backend | 93 +++++++++++++ plugins/haproxy/haproxy_bytes_backend | 104 ++++++++++++++ plugins/haproxy/haproxy_bytes_frontend | 104 ++++++++++++++ plugins/haproxy/haproxy_denied_backend | 105 ++++++++++++++ plugins/haproxy/haproxy_denied_frontend | 105 ++++++++++++++ plugins/haproxy/haproxy_errors_backend | 113 +++++++++++++++ plugins/haproxy/haproxy_errors_frontend | 113 +++++++++++++++ plugins/haproxy/haproxy_queue_backend | 106 ++++++++++++++ plugins/haproxy/haproxy_rate_backend | 112 +++++++++++++++ plugins/haproxy/haproxy_rate_frontend | 113 +++++++++++++++ plugins/haproxy/haproxy_reqrate_frontend | 106 ++++++++++++++ plugins/haproxy/haproxy_responses_backend | 130 ++++++++++++++++++ plugins/haproxy/haproxy_responses_frontend | 130 ++++++++++++++++++ plugins/haproxy/haproxy_sessions_backend | 112 +++++++++++++++ plugins/haproxy/haproxy_sessions_frontend | 112 +++++++++++++++ .../haproxy/haproxy_sessions_total_backend | 99 +++++++++++++ .../haproxy/haproxy_sessions_total_frontend | 100 ++++++++++++++ plugins/haproxy/haproxy_warnings_backend | 106 ++++++++++++++ 19 files changed, 2069 insertions(+) create mode 100755 plugins/haproxy/haproxy_abort_backend create mode 100755 plugins/haproxy/haproxy_active_backend create mode 100755 plugins/haproxy/haproxy_bytes_backend create mode 100755 plugins/haproxy/haproxy_bytes_frontend create mode 100755 plugins/haproxy/haproxy_denied_backend create mode 100755 plugins/haproxy/haproxy_denied_frontend create mode 100755 plugins/haproxy/haproxy_errors_backend create mode 100755 plugins/haproxy/haproxy_errors_frontend create mode 100755 plugins/haproxy/haproxy_queue_backend create mode 100755 plugins/haproxy/haproxy_rate_backend create mode 100755 plugins/haproxy/haproxy_rate_frontend create mode 100755 plugins/haproxy/haproxy_reqrate_frontend create mode 100755 plugins/haproxy/haproxy_responses_backend create mode 100755 plugins/haproxy/haproxy_responses_frontend create mode 100755 plugins/haproxy/haproxy_sessions_backend create mode 100755 plugins/haproxy/haproxy_sessions_frontend create mode 100755 plugins/haproxy/haproxy_sessions_total_backend create mode 100755 plugins/haproxy/haproxy_sessions_total_frontend create mode 100755 plugins/haproxy/haproxy_warnings_backend diff --git a/plugins/haproxy/haproxy_abort_backend b/plugins/haproxy/haproxy_abort_backend new file mode 100755 index 00000000..54199a2f --- /dev/null +++ b/plugins/haproxy/haproxy_abort_backend @@ -0,0 +1,106 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_aborts_backend -Haproxy Aborts Backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Aborts ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Aborts' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Aborts ${SVNAME}" + + + for i in ${LIST}; do + echo "cli_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Aborted by client $i" + echo "cli_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "cli_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "cli_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Data transfers aborted by the client $i" + + echo "srv_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Aborted by server $i" + echo "srv_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "srv_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "srv_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Data transfers aborted by the server $i" + + done + + exit 0 +fi + for i in ${LIST}; do + CLI=`parse_url ${i} ${SVNAME} cli_abrt` + SRV=`parse_url ${i} ${SVNAME} srv_abrt` + + echo "cli_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $CLI" + echo "srv_abrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $SRV" + done + + diff --git a/plugins/haproxy/haproxy_active_backend b/plugins/haproxy/haproxy_active_backend new file mode 100755 index 00000000..0b93a5ef --- /dev/null +++ b/plugins/haproxy/haproxy_active_backend @@ -0,0 +1,93 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_active_backend -Haproxy servers active backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + 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 Active Servers ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Servers' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Active Servers ${SVNAME}" + + for i in ${LIST}; do + echo "act`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Active Servers $i" + echo "act`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "act`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "act`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Active Servers $i" + done + + exit 0 +fi + for i in ${LIST}; do + ACT=`parse_url ${i} ${SVNAME} act` + echo "act`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $ACT" + done + diff --git a/plugins/haproxy/haproxy_bytes_backend b/plugins/haproxy/haproxy_bytes_backend new file mode 100755 index 00000000..87f421b0 --- /dev/null +++ b/plugins/haproxy/haproxy_bytes_backend @@ -0,0 +1,104 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_bytes_backend -Haproxy Bytes Backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 ${SVNAME}" + echo 'graph_args --base 1000' + echo 'graph_vlabel Bytes in (-) / out (+)' + echo 'graph_category haproxy' + echo "graph_info Bytes ${SVNAME}" + + +for i in ${LIST}; do + + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes $i" + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.graph no" + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.cdef down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`,8,*" + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes $i" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.negative down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.cdef up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`,8,*" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Bytes in $i" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" +done + exit 0 +fi + for i in ${LIST}; do + BIN=`parse_url ${i} ${SVNAME} bin` + BOUT=`parse_url ${i} ${SVNAME} bout` + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BOUT" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BIN" + done + diff --git a/plugins/haproxy/haproxy_bytes_frontend b/plugins/haproxy/haproxy_bytes_frontend new file mode 100755 index 00000000..868566e9 --- /dev/null +++ b/plugins/haproxy/haproxy_bytes_frontend @@ -0,0 +1,104 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_bytes_frontend -Haproxy Bytes Frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 ${SVNAME}" + echo 'graph_args --base 1000' + echo 'graph_vlabel Bytes in (-) / out (+)' + echo 'graph_category haproxy' + echo "graph_info Bytes ${SVNAME}" + + +for i in ${LIST}; do + + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes $i" + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.graph no" + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.cdef down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`,8,*" + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Bytes $i" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.negative down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.cdef up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`,8,*" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Bytes in $i" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" +done + exit 0 +fi + for i in ${LIST}; do + BIN=`parse_url ${i} ${SVNAME} bin` + BOUT=`parse_url ${i} ${SVNAME} bout` + echo "down`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BOUT" + echo "up`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $BIN" + done + diff --git a/plugins/haproxy/haproxy_denied_backend b/plugins/haproxy/haproxy_denied_backend new file mode 100755 index 00000000..f8b35488 --- /dev/null +++ b/plugins/haproxy/haproxy_denied_backend @@ -0,0 +1,105 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_denied_backend -Haproxy Denied Backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Denied Requests / Responses ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Requests and Responses' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Denied Requests / Responses ${SVNAME}" + + + for i in ${LIST}; do + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Denied Requests $i" + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Denied Requests $i" + + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Denied Responses $i" + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Denied Responses $i" + done + + exit 0 +fi + for i in ${LIST}; do + DREQ=`parse_url ${i} ${SVNAME} dreq` + DRESP=`parse_url ${i} ${SVNAME} dresp` + + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $DREQ" + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $DRESP" + done + + diff --git a/plugins/haproxy/haproxy_denied_frontend b/plugins/haproxy/haproxy_denied_frontend new file mode 100755 index 00000000..2c7b7ad1 --- /dev/null +++ b/plugins/haproxy/haproxy_denied_frontend @@ -0,0 +1,105 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_denied_frontend -Haproxy Denied Frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Denied Requests / Responses ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Requests and Responses' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Denied Requests / Responses ${SVNAME}" + + + for i in ${LIST}; do + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Denied Requests $i" + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Denied Requests $i" + + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Denied Responses $i" + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Denied Responses $i" + done + + exit 0 +fi + for i in ${LIST}; do + DREQ=`parse_url ${i} ${SVNAME} dreq` + DRESP=`parse_url ${i} ${SVNAME} dresp` + + echo "dreq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $DREQ" + echo "dresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $DRESP" + done + + diff --git a/plugins/haproxy/haproxy_errors_backend b/plugins/haproxy/haproxy_errors_backend new file mode 100755 index 00000000..a7c22793 --- /dev/null +++ b/plugins/haproxy/haproxy_errors_backend @@ -0,0 +1,113 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_errors_backend -Haproxy Errors Backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Errors ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Errors' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Errors ${SVNAME}" + + + for i in ${LIST}; do + #echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Request Errors $i" + #echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + #echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + #echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Request Errors $i" + + echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Connection Errors $i" + echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Connection Errors $i" + + echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Response Errors $i" + echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Response Errors $i" + + done + + exit 0 +fi + for i in ${LIST}; do + #EREQ=`parse_url ${i} ${SVNAME} ereq` + ECON=`parse_url ${i} ${SVNAME} econ` + ERESP=`parse_url ${i} ${SVNAME} eresp` + + #echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $EREQ" + echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $ECON" + echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $ERESP" + done + + diff --git a/plugins/haproxy/haproxy_errors_frontend b/plugins/haproxy/haproxy_errors_frontend new file mode 100755 index 00000000..c3fd024b --- /dev/null +++ b/plugins/haproxy/haproxy_errors_frontend @@ -0,0 +1,113 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_errors_frontend -Haproxy Errors Frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Errors ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Errors' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Errors ${SVNAME}" + + + for i in ${LIST}; do + echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Request Errors $i" + echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Request Errors $i" + + #echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Connection Errors $i" + #echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + #echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + #echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Connection Errors $i" + + #echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Response Errors $i" + #echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + #echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + #echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Response Errors $i" + + done + + exit 0 +fi + for i in ${LIST}; do + EREQ=`parse_url ${i} ${SVNAME} ereq` + #ECON=`parse_url ${i} ${SVNAME} econ` + #ERESP=`parse_url ${i} ${SVNAME} eresp` + + echo "ereq`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $EREQ" + #echo "econ`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $ECON" + #echo "eresp`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $ERESP" + done + + diff --git a/plugins/haproxy/haproxy_queue_backend b/plugins/haproxy/haproxy_queue_backend new file mode 100755 index 00000000..fad085bf --- /dev/null +++ b/plugins/haproxy/haproxy_queue_backend @@ -0,0 +1,106 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_queue_backend -Haproxy Queued Requests Backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Queued Request ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Queued' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Queue Requests ${SVNAME}" + + + for i in ${LIST}; do + echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Current queued request $i" + echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Current queued request $i" + + #echo "qmax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Max $i" + #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" + done + + exit 0 +fi + for i in ${LIST}; do + QCUR=`parse_url ${i} ${SVNAME} qcur` + #QMAX=`parse_url ${i} ${SVNAME} qmax` + + echo "qcur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $QCUR" + #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 new file mode 100755 index 00000000..a8e07f22 --- /dev/null +++ b/plugins/haproxy/haproxy_rate_backend @@ -0,0 +1,112 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_rate_backend -Haproxy Sessions Per Second Backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Sessions per second ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Sessions' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Sessions per second ${SVNAME}" + + + for i in ${LIST}; do + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Rate $i" + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Number of sessions per second over last elapsed second $i" + + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Limit $i" + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit on new sessions per second $i" + + #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Max $i" + #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + #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" + + done + + exit 0 +fi + for i in ${LIST}; do + RATE=`parse_url ${i} ${SVNAME} rate` + RATEL=`parse_url ${i} ${SVNAME} rate_lim` + #RATEM=`parse_url ${i} ${SVNAME} rate_max` + + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATE" + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATEL" + #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATEM" + done + + diff --git a/plugins/haproxy/haproxy_rate_frontend b/plugins/haproxy/haproxy_rate_frontend new file mode 100755 index 00000000..cd681fe4 --- /dev/null +++ b/plugins/haproxy/haproxy_rate_frontend @@ -0,0 +1,113 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +harpoxy_rate_frontend -Haproxy Sessions Per Second Frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Sessions per sencond ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Sessions' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Sessions per second ${SVNAME}" + + + for i in ${LIST}; do + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Rate $i" + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Number of sessions per second over last elapsed second $i" + + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Limit $i" + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Limit on new sessions per second $i" + + #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Max $i" + #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + #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" + + done + + exit 0 +fi + for i in ${LIST}; do + RATE=`parse_url ${i} ${SVNAME} rate` + RATEL=`parse_url ${i} ${SVNAME} rate_lim` + #RATEM=`parse_url ${i} ${SVNAME} rate_max` + + echo "rate`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATE" + echo "rate_lim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATEL" + #echo "rate_max`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $RATEM" + done + + diff --git a/plugins/haproxy/haproxy_reqrate_frontend b/plugins/haproxy/haproxy_reqrate_frontend new file mode 100755 index 00000000..4da2143a --- /dev/null +++ b/plugins/haproxy/haproxy_reqrate_frontend @@ -0,0 +1,106 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_reqrate_frontend -Haproxy request rate frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Request Rate ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Requests' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Request Rate ${SVNAME}" + + + for i in ${LIST}; do + echo "reqrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Requests per second $i" + echo "reqrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "reqrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "reqrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP requests per second over last elapsed second $i" + + #echo "reqrtm`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Max $i" + #echo "reqrtm`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + #echo "reqrtm`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + #echo "reqrtm`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info max number of HTTP requests per second observed $i" + + done + + exit 0 +fi + for i in ${LIST}; do + REQRT=`parse_url ${i} ${SVNAME} req_rate` + #REQRTM=`parse_url ${i} ${SVNAME} req_rate_max` + + echo "reqrt`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $REQRT" + #echo "reqtm`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $REQRTM" + done + + diff --git a/plugins/haproxy/haproxy_responses_backend b/plugins/haproxy/haproxy_responses_backend new file mode 100755 index 00000000..a0fad86a --- /dev/null +++ b/plugins/haproxy/haproxy_responses_backend @@ -0,0 +1,130 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_responses_backend -Haproxy responses backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + 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 HTTP Responses ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Responses' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info HTTP Responses ${SVNAME}" + + for i in ${LIST}; do + echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 1xx $i" + echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 1xx code $i" + + echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 2xx $i" + echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 2xx code $i" + + echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 3xx $i" + echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 3xx code $i" + + echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 4xx $i" + echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 4xx code $i" + + echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 5xx $i" + echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 5xx code $i" + + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP other $i" + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with other codes $i" + + + done + + exit 0 +fi + for i in ${LIST}; do + H1xx=`parse_url ${i} ${SVNAME} hrsp_1xx` + H2xx=`parse_url ${i} ${SVNAME} hrsp_2xx` + 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` + 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" + done + diff --git a/plugins/haproxy/haproxy_responses_frontend b/plugins/haproxy/haproxy_responses_frontend new file mode 100755 index 00000000..1326dc26 --- /dev/null +++ b/plugins/haproxy/haproxy_responses_frontend @@ -0,0 +1,130 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_responses_frontend -Haproxy responses frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + 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 HTTP Responses ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Responses' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info HTTP Responses ${SVNAME}" + + for i in ${LIST}; do + echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 1xx $i" + echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_1xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 1xx code $i" + + echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 2xx $i" + echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_2xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 2xx code $i" + + echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 3xx $i" + echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_3xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 3xx code $i" + + echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 4xx $i" + echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_4xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 4xx code $i" + + echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP 5xx $i" + echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_5xx`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with 5xx code $i" + + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label HTTP other $i" + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "hrsp_other`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info HTTP responses with other codes $i" + + + done + + exit 0 +fi + for i in ${LIST}; do + H1xx=`parse_url ${i} ${SVNAME} hrsp_1xx` + H2xx=`parse_url ${i} ${SVNAME} hrsp_2xx` + 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` + 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" + done + diff --git a/plugins/haproxy/haproxy_sessions_backend b/plugins/haproxy/haproxy_sessions_backend new file mode 100755 index 00000000..5db4a2b0 --- /dev/null +++ b/plugins/haproxy/haproxy_sessions_backend @@ -0,0 +1,112 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_sessions_backend -Haproxy Sessions Backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Current sessions ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Sessions' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Current sessions ${SVNAME}" + + + for i in ${LIST}; do + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Current Sessions $i" + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Current Sessions $i" + + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Max $i" + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Max sessions $i" + + echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Limit Sessions $i" + 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" + done + + exit 0 +fi + for i in ${LIST}; do + SCUR=`parse_url ${i} ${SVNAME} scur` + #SMAX=`parse_url ${i} ${SVNAME} smax` + SLIM=`parse_url ${i} ${SVNAME} slim` + + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $SCUR" + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $SMAX" + echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $SLIM" + done + + diff --git a/plugins/haproxy/haproxy_sessions_frontend b/plugins/haproxy/haproxy_sessions_frontend new file mode 100755 index 00000000..77be70bc --- /dev/null +++ b/plugins/haproxy/haproxy_sessions_frontend @@ -0,0 +1,112 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_sessions_frontend -Haproxy Sessions Frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Current sessions ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Sessions' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Current sessions ${SVNAME}" + + + for i in ${LIST}; do + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Current Sessions $i" + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Current Sessions $i" + + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Max $i" + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type GAUGE" + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Max Sessions $i" + + echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Limit Sessions $i" + 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" + done + + exit 0 +fi + for i in ${LIST}; do + SCUR=`parse_url ${i} ${SVNAME} scur` + #SMAX=`parse_url ${i} ${SVNAME} smax` + SLIM=`parse_url ${i} ${SVNAME} slim` + + echo "scur`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $SCUR" + #echo "smax`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $SMAX" + echo "slim`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $SLIM" + done + + diff --git a/plugins/haproxy/haproxy_sessions_total_backend b/plugins/haproxy/haproxy_sessions_total_backend new file mode 100755 index 00000000..97f35260 --- /dev/null +++ b/plugins/haproxy/haproxy_sessions_total_backend @@ -0,0 +1,99 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_sessions_total_frontend -Haproxy Sessions Total Frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Total sessions ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Sessions' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Total sessions ${SVNAME}" + + + for i in ${LIST}; do + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Total Sessions $i" + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Total Sessions $i" + + done + + exit 0 +fi + for i in ${LIST}; do + STOT=`parse_url ${i} ${SVNAME} stot` + + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $STOT" + done + + diff --git a/plugins/haproxy/haproxy_sessions_total_frontend b/plugins/haproxy/haproxy_sessions_total_frontend new file mode 100755 index 00000000..a6adb2ea --- /dev/null +++ b/plugins/haproxy/haproxy_sessions_total_frontend @@ -0,0 +1,100 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haprxoy_sessions_total_frontend -Haproxy Sessions Total Frontend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Total sessions ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Sessions' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Total sessions ${SVNAME}" + + + for i in ${LIST}; do + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Total Sessions $i" + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Total Sessions $i" + + done + + exit 0 +fi + for i in ${LIST}; do + STOT=`parse_url ${i} ${SVNAME} stot` + + echo "stot`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $STOT" + done + + diff --git a/plugins/haproxy/haproxy_warnings_backend b/plugins/haproxy/haproxy_warnings_backend new file mode 100755 index 00000000..9207184c --- /dev/null +++ b/plugins/haproxy/haproxy_warnings_backend @@ -0,0 +1,106 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +haproxy_warnings_backend -Haproxy Warnings Backend + +=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 + env.url http://user:passwd@IP:port/admin?stats;csv + +=head1 AUTHOR + +Ricardo Fraile + +=head1 LICENSE + +GNU + +=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" + LINE1=`curl -s "$url" | head -1 | sed 's/# //'` + LINE2=`curl -s "$url" | grep "$PXNAME,$SVNAME"` + + + 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 Warnings ${SVNAME}" + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel Warnings' + echo 'graph_scale no' + echo 'graph_category haproxy' + echo "graph_info Warnings ${SVNAME}" + + + for i in ${LIST}; do + echo "wretr`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Warning Retries $i" + echo "wretr`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "wretr`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "wretr`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Warning Retries $i" + + echo "wredis`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.label Warning Redispatches $i" + echo "wredis`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.type DERIVE" + echo "wredis`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.min 0" + echo "wredis`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.info Warning Redispatches $i" + + done + + exit 0 +fi + for i in ${LIST}; do + WRETR=`parse_url ${i} ${SVNAME} wretr` + WREDIS=`parse_url ${i} ${SVNAME} wredis` + + echo "wretr`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $WRETR" + echo "wredis`echo $i | md5sum | cut -d - -f1 | sed 's/ //g'`.value $WREDIS" + done + + From 0541fdd14551e88cf97d622489b809db804716a2 Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 11 Sep 2012 13:49:33 +0200 Subject: [PATCH 5/6] Repair bug in other responses --- plugins/haproxy/haproxy_responses_backend | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/haproxy/haproxy_responses_backend b/plugins/haproxy/haproxy_responses_backend index a0fad86a..69c0db9c 100755 --- a/plugins/haproxy/haproxy_responses_backend +++ b/plugins/haproxy/haproxy_responses_backend @@ -17,7 +17,7 @@ haproxy_responses_backend -Haproxy responses backend =head1 AUTHOR -Ricardo Fraile +Ricardo Fraile =head1 LICENSE @@ -33,7 +33,7 @@ GNU . $MUNIN_LIBDIR/plugins/plugin.sh function parse_url { - # Modify ifs variable + # Modificamos la variable if, al final se vuelve a dejar igual OIFS=$IFS; IFS=","; PXNAME="$1" @@ -44,10 +44,10 @@ function parse_url { ARRAY1=($LINE1); - # Find values + # Recorremos el array buscando los valores esperados for ((i=0; i<${#ARRAY1[@]}; ++i)); do - # Get data + # Si coincide con el valor, sacar el dato if [[ "${ARRAY1[$i]}" == "${VALUE}" ]]; then o=$i; o=`expr $o + 1` @@ -55,7 +55,7 @@ function parse_url { fi done - # Reset ifs + # se deja la variable igual IFS=$OIFS; } @@ -125,6 +125,6 @@ fi 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 $Hoxx" done From a717a9134470a36563671f0db98a1154a357ce5c Mon Sep 17 00:00:00 2001 From: rfrail3 Date: Fri, 14 Sep 2012 09:27:38 +0200 Subject: [PATCH 6/6] change license --- plugins/haproxy/haproxy_abort_backend | 2 +- plugins/haproxy/haproxy_active_backend | 2 +- plugins/haproxy/haproxy_bytes_backend | 2 +- plugins/haproxy/haproxy_bytes_frontend | 2 +- plugins/haproxy/haproxy_denied_backend | 2 +- plugins/haproxy/haproxy_denied_frontend | 2 +- plugins/haproxy/haproxy_errors_backend | 2 +- plugins/haproxy/haproxy_errors_frontend | 2 +- plugins/haproxy/haproxy_queue_backend | 2 +- plugins/haproxy/haproxy_rate_backend | 2 +- plugins/haproxy/haproxy_rate_frontend | 2 +- plugins/haproxy/haproxy_reqrate_frontend | 2 +- plugins/haproxy/haproxy_responses_backend | 2 +- plugins/haproxy/haproxy_responses_frontend | 2 +- plugins/haproxy/haproxy_sessions_backend | 2 +- plugins/haproxy/haproxy_sessions_frontend | 2 +- plugins/haproxy/haproxy_sessions_total_backend | 2 +- plugins/haproxy/haproxy_sessions_total_frontend | 2 +- plugins/haproxy/haproxy_warnings_backend | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/haproxy/haproxy_abort_backend b/plugins/haproxy/haproxy_abort_backend index 54199a2f..5f0c4fa0 100755 --- a/plugins/haproxy/haproxy_abort_backend +++ b/plugins/haproxy/haproxy_abort_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_active_backend b/plugins/haproxy/haproxy_active_backend index 0b93a5ef..bf3b365e 100755 --- a/plugins/haproxy/haproxy_active_backend +++ b/plugins/haproxy/haproxy_active_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_bytes_backend b/plugins/haproxy/haproxy_bytes_backend index 87f421b0..6ea61850 100755 --- a/plugins/haproxy/haproxy_bytes_backend +++ b/plugins/haproxy/haproxy_bytes_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_bytes_frontend b/plugins/haproxy/haproxy_bytes_frontend index 868566e9..accad05d 100755 --- a/plugins/haproxy/haproxy_bytes_frontend +++ b/plugins/haproxy/haproxy_bytes_frontend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_denied_backend b/plugins/haproxy/haproxy_denied_backend index f8b35488..31629d66 100755 --- a/plugins/haproxy/haproxy_denied_backend +++ b/plugins/haproxy/haproxy_denied_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_denied_frontend b/plugins/haproxy/haproxy_denied_frontend index 2c7b7ad1..fd785e7e 100755 --- a/plugins/haproxy/haproxy_denied_frontend +++ b/plugins/haproxy/haproxy_denied_frontend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_errors_backend b/plugins/haproxy/haproxy_errors_backend index a7c22793..efe4d6ef 100755 --- a/plugins/haproxy/haproxy_errors_backend +++ b/plugins/haproxy/haproxy_errors_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_errors_frontend b/plugins/haproxy/haproxy_errors_frontend index c3fd024b..735ded15 100755 --- a/plugins/haproxy/haproxy_errors_frontend +++ b/plugins/haproxy/haproxy_errors_frontend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_queue_backend b/plugins/haproxy/haproxy_queue_backend index fad085bf..c49e410d 100755 --- a/plugins/haproxy/haproxy_queue_backend +++ b/plugins/haproxy/haproxy_queue_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_rate_backend b/plugins/haproxy/haproxy_rate_backend index a8e07f22..7d2b161a 100755 --- a/plugins/haproxy/haproxy_rate_backend +++ b/plugins/haproxy/haproxy_rate_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_rate_frontend b/plugins/haproxy/haproxy_rate_frontend index cd681fe4..ee1b21e2 100755 --- a/plugins/haproxy/haproxy_rate_frontend +++ b/plugins/haproxy/haproxy_rate_frontend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_reqrate_frontend b/plugins/haproxy/haproxy_reqrate_frontend index 4da2143a..ecc160a7 100755 --- a/plugins/haproxy/haproxy_reqrate_frontend +++ b/plugins/haproxy/haproxy_reqrate_frontend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_responses_backend b/plugins/haproxy/haproxy_responses_backend index 69c0db9c..5998929d 100755 --- a/plugins/haproxy/haproxy_responses_backend +++ b/plugins/haproxy/haproxy_responses_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_responses_frontend b/plugins/haproxy/haproxy_responses_frontend index 1326dc26..ba993ceb 100755 --- a/plugins/haproxy/haproxy_responses_frontend +++ b/plugins/haproxy/haproxy_responses_frontend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_sessions_backend b/plugins/haproxy/haproxy_sessions_backend index 5db4a2b0..12e5172f 100755 --- a/plugins/haproxy/haproxy_sessions_backend +++ b/plugins/haproxy/haproxy_sessions_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_sessions_frontend b/plugins/haproxy/haproxy_sessions_frontend index 77be70bc..528ecd19 100755 --- a/plugins/haproxy/haproxy_sessions_frontend +++ b/plugins/haproxy/haproxy_sessions_frontend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_sessions_total_backend b/plugins/haproxy/haproxy_sessions_total_backend index 97f35260..2b277b24 100755 --- a/plugins/haproxy/haproxy_sessions_total_backend +++ b/plugins/haproxy/haproxy_sessions_total_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_sessions_total_frontend b/plugins/haproxy/haproxy_sessions_total_frontend index a6adb2ea..d2fc2996 100755 --- a/plugins/haproxy/haproxy_sessions_total_frontend +++ b/plugins/haproxy/haproxy_sessions_total_frontend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS diff --git a/plugins/haproxy/haproxy_warnings_backend b/plugins/haproxy/haproxy_warnings_backend index 9207184c..53130ab2 100755 --- a/plugins/haproxy/haproxy_warnings_backend +++ b/plugins/haproxy/haproxy_warnings_backend @@ -21,7 +21,7 @@ Ricardo Fraile =head1 LICENSE -GNU +GPLv2 =head1 MAGICK MARKERS