2011-06-24 11:58:36 +02:00
|
|
|
#!/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"_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 <<EOF
|
2018-08-02 02:03:42 +02:00
|
|
|
graph_category loadbalancer
|
2011-06-24 11:58:36 +02:00
|
|
|
graph_args --base 1000
|
|
|
|
graph_title ${graph_title}
|
|
|
|
graph_vlabel ${graph_vlabel}
|
|
|
|
|
|
|
|
`labels`
|
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
values
|
|
|
|
|
|
|
|
exit 0
|