mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
46 lines
850 B
Plaintext
46 lines
850 B
Plaintext
|
#!/bin/sh
|
||
|
# Pasha "p01nt" Klets <pasha@klets.name>
|
||
|
|
||
|
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 <<EOF
|
||
|
graph_category haproxy
|
||
|
graph_title ${graph_title}
|
||
|
graph_vlabel ${graph_vlabel}
|
||
|
|
||
|
`labels`
|
||
|
EOF
|
||
|
exit 0
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
values
|
||
|
|
||
|
exit 0
|