From 26b6c4c3db1372f74b5c52d24bbe7df829d3aa73 Mon Sep 17 00:00:00 2001 From: Pasha Klets Date: Fri, 24 Jun 2011 11:58:36 +0200 Subject: [PATCH] Initial version --- plugins/other/haproxy-bytes | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 plugins/other/haproxy-bytes diff --git a/plugins/other/haproxy-bytes b/plugins/other/haproxy-bytes new file mode 100755 index 00000000..b719c95e --- /dev/null +++ b/plugins/other/haproxy-bytes @@ -0,0 +1,46 @@ +#!/bin/sh +# Pasha "p01nt" Klets + +name=`basename $0` +title=`echo ${name} | awk -F_ '{print $NF}'` + +hp_stat() { + echo "show stat" | socat unix-connect:/tmp/haproxy stdio +} + +servers_section() { + hp_stat | grep '^'${title}',' | egrep -v '^'${title}',(FRONTEND|BACKEND)' +} + +servers() { + servers_section | awk -F, '{print $2}' +} + +labels() { + servers_section | awk -F, '{print $2"_out.label "$2" out\n"$2"_in.label "$2" in\n"$2"_out.type COUNTER\n"$2"_in.type COUNTER\n"$2"_in.negative "$2"_out" }' +} + +values() { + servers_section | awk -F, '{print $2"_out.value "$10"\n"$2"_in.value "$9}' +} + +graph_title="${title} bytes" +graph_vlabel=${title} + +case $1 in + config) + cat <