-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbatman-metrics-collectd
executable file
·29 lines (26 loc) · 1.2 KB
/
batman-metrics-collectd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
HOSTNAME="${COLLECTD_HOSTNAME:-$(hostname --fqdn)}"
INTERVAL="${COLLECTD_INTERVAL:-60}"
BATCTL="$(which batctl)"
PERFVALLIST="neighbors originators translocal transglobal claimtable dat_cache transglobal-size transglobal-unicast transglobal-multicast"
while sleep "$INTERVAL"; do
for BATIF in $(ip link show | grep ": bat_" | cut -d: -f2 | sed "s| ||g"); do
for METRIC in $PERFVALLIST; do
if [ "$METRIC" = "transglobal-size" ]; then
VALUE="$(sudo $BATCTL meshif $BATIF transglobal -H -n | wc -c)"
elif [ "$METRIC" = "transglobal-unicast" ]; then
VALUE="$(sudo $BATCTL meshif $BATIF transglobal -u -H -n | wc -l)"
elif [ "$METRIC" = "transglobal-multicast" ]; then
VALUE="$(sudo $BATCTL meshif $BATIF transglobal -m -H -n | wc -l)"
else
VALUE="$(sudo $BATCTL meshif $BATIF $METRIC -H -n | wc -l)"
fi
echo "PUTVAL \"$HOSTNAME/exec-batman-metrics/gauge-${METRIC}-${BATIF}\" interval=$INTERVAL N:$VALUE"
done
while read stat; do
METRIC="statistics_${stat%:*}"
VALUE="${stat#*:}"
echo "PUTVAL \"$HOSTNAME/exec-batman-metrics/gauge-${METRIC}-${BATIF}\" interval=$INTERVAL N:$VALUE"
done < <(sudo $BATCTL meshif $BATIF statistics | awk '{ print $1 $2 }')
done
done