From b42dd266c93992c051fe55567e965f282fe5e777 Mon Sep 17 00:00:00 2001 From: Pasha Klets Date: Fri, 24 Jun 2011 12:02:51 +0200 Subject: [PATCH] Initial version --- plugins/other/haproxy-downtime | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 plugins/other/haproxy-downtime diff --git a/plugins/other/haproxy-downtime b/plugins/other/haproxy-downtime new file mode 100755 index 00000000..cf4f7318 --- /dev/null +++ b/plugins/other/haproxy-downtime @@ -0,0 +1,45 @@ +#!/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"_dwn.label "$2" down\n"$2"_dwntime.label "$2" downtime\n"$2"_dwn.type COUNTER\n"$2"_dwntime.type COUNTER\n"$2"_dwntime.negative "$2"_dwn" }' +} + +values() { + servers_section | awk -F, '{print $2"_dwn.value "$23"\n"$2"_dwntime.value "$25}' +} + +graph_title="${title} downtime" +graph_vlabel=${title} + +case $1 in + config) + cat <