root / plugins / network / net_hosts_ @ 8589c6df
Historique | Voir | Annoter | Télécharger (700 octets)
| 1 | 4a6b888d | jon | #!/bin/sh |
|---|---|---|---|
| 2 | # munin plugin to show number of online network hosts on a subnet (needs fping) |
||
| 3 | # link with subnet name as suffix like _192.168.1 |
||
| 4 | 1e6bc858 | jon | # will most likely need a custom timeout setting in /etc/munin/plugin-conf.d/munin-node |
| 5 | # for example: |
||
| 6 | # [net_hosts_*] |
||
| 7 | # timeout 20 |
||
| 8 | # |
||
| 9 | 4a6b888d | jon | # (c) 2011 jon@jon.bpa.nu |
| 10 | 1e6bc858 | jon | #%# family=manual |
| 11 | 4a6b888d | jon | |
| 12 | SUBNET=`echo $0 | cut -d'_' -f3` |
||
| 13 | TIMEOUT=50 # ms |
||
| 14 | RETRIES=0 |
||
| 15 | |||
| 16 | case $1 in |
||
| 17 | config) |
||
| 18 | cat <<CFG |
||
| 19 | 64296bf2 | jon | graph_title hosts on network $SUBNET. |
| 20 | 4a6b888d | jon | graph_vlabel hosts |
| 21 | graph_category network |
||
| 22 | hosts.label hosts |
||
| 23 | CFG |
||
| 24 | exit 0;; |
||
| 25 | esac |
||
| 26 | |||
| 27 | if [ $SUBNET != "" ]; then |
||
| 28 | echo "hosts.value `fping -t $TIMEOUT -r $RETRIES -ga \"$SUBNET.0/24\" 2>/dev/null | wc -l`" |
||
| 29 | else |
||
| 30 | echo "could not get subnet name ($SUBNET)" |
||
| 31 | fi |
