2011-04-01 17:46:44 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# munin plugin to show number of online network hosts on a subnet (needs fping)
|
|
|
|
# link with subnet name as suffix like _192.168.1
|
2011-04-01 18:20:46 +02:00
|
|
|
# will most likely need a custom timeout setting in /etc/munin/plugin-conf.d/munin-node
|
|
|
|
# for example:
|
|
|
|
# [net_hosts_*]
|
|
|
|
# timeout 20
|
|
|
|
#
|
2011-04-01 17:46:44 +02:00
|
|
|
# (c) 2011 jon@jon.bpa.nu
|
2011-04-01 18:20:46 +02:00
|
|
|
#%# family=manual
|
2011-04-01 17:46:44 +02:00
|
|
|
|
|
|
|
SUBNET=`echo $0 | cut -d'_' -f3`
|
|
|
|
TIMEOUT=50 # ms
|
|
|
|
RETRIES=0
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
config)
|
|
|
|
cat <<CFG
|
2011-04-01 18:28:53 +02:00
|
|
|
graph_title hosts on network $SUBNET.
|
2011-04-01 17:46:44 +02:00
|
|
|
graph_vlabel hosts
|
|
|
|
graph_category network
|
|
|
|
hosts.label hosts
|
|
|
|
CFG
|
|
|
|
exit 0;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ $SUBNET != "" ]; then
|
|
|
|
echo "hosts.value `fping -t $TIMEOUT -r $RETRIES -ga \"$SUBNET.0/24\" 2>/dev/null | wc -l`"
|
|
|
|
else
|
|
|
|
echo "could not get subnet name ($SUBNET)"
|
|
|
|
fi
|