Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / haproxy / haproxy-downtime @ c3660c2a

Historique | Voir | Annoter | Télécharger (850 octets)

1 b42dd266 Pasha Klets
#!/bin/sh
2
# Pasha "p01nt" Klets <pasha@klets.name>
3
4
name=`basename $0`
5
title=`echo ${name} | awk -F_ '{print $NF}'`
6
7
hp_stat() {
8
	echo "show stat" | socat unix-connect:/tmp/haproxy stdio
9
}
10
11
servers_section() {
12
	hp_stat | grep '^'${title}',' |  egrep -v '^'${title}',(FRONTEND|BACKEND)'
13
}
14
15
servers() {
16
	servers_section | awk -F, '{print $2}'
17
}
18
19
labels() {
20
	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" }'
21
}
22
23
values() {
24
	servers_section | awk -F, '{print $2"_dwn.value "$23"\n"$2"_dwntime.value "$25}'
25
}
26
27
graph_title="${title} downtime"
28
graph_vlabel=${title}
29
30
case $1 in
31
   config)
32
		cat <<EOF
33
graph_category haproxy
34
graph_title  ${graph_title}
35
graph_vlabel ${graph_vlabel}
36
37
`labels`
38
EOF
39
		exit 0
40
	;;
41
esac
42
43
values
44
45
exit 0