uptime_switch 771 Bytes
Newer Older
1
#!/bin/zsh
2 3 4 5 6 7 8 9 10 11 12
#
# Plugin to measure uptime. Especially the average and max values on the
# bigger graphs (yearly) can be interesting.
#
# Contributed by Antoine Durand-Gasselin

if [ "$1" = "autoconf" ]; then
	echo yes
	exit 0
fi

13 14
switchs=(multiprise backbone\
         `host -l adm.crans.org | sed -ne 's/\(bat[a-u]-[0-9]\).*$/\1/p'`)
15

16
if [ "$1" = "config" ]; then
17 18 19 20
        echo "host_name uptime.switchs.crans.org"
	echo 'graph_title Uptime'
	echo 'graph_args --base 1000 -l 0 '
	echo 'graph_vlabel uptime in days'
21
	for i in $switchs; do echo "${i/-/}.label uptime $i"; done
22 23 24
	exit 0
fi

25 26
for i in $switchs; do
  snmpget -t 0.05 -O v -v 1 -c public $i.adm sysUpTimeInstance 2> /dev/null | \
27
  perl -nle "{ /\d+/; print sprintf(\"${i/-/}.value %.2f\", ($&/8640000));}"&
28 29
done