Projet

Général

Profil

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

root / plugins / network / brc_rssi @ dd4afac8

Historique | Voir | Annoter | Télécharger (2,45 ko)

1 7d9312a0 Nicolai Langfeldt
#!/bin/sh
2
#
3
# Munin plugin for WiFi access points with Broadcom chipset such as found
4
# on hardware supported by OpenWRT.
5
#
6
# NOTE: NEEDS NON FREE UTILITY "wl"
7
# Configuration:
8
# [brc_rssi]
9
#    env.WIFISIDE eth0   # Set the WiFi side interface. Used to filter arp entries. 
10
#                        # On a openwrt box defaults to "nvram get lan_ifname" otherwise
11
#                        # no default.
12
#
13
# Written by Nicolai Langfeldt (janl@linpro.no) 2007/02/18
14
#
15
# Bugs:
16
# - Should have a persistent list of macs ever seen
17
#
18
# License: GPL v.2
19
#
20
#%# family=contrib
21
#%# capabilities=autoconf
22
#
23
24
PATH=/usr/bin:/usr/sbin:/bin:/sbin
25
export PATH
26
27
AL="$(wl assoclist 2>&1)"
28
WLERR=$?
29
case $WLERR in
30
    0) MACS="$(echo "$AL" | cut -d' ' -f2)";;
31
esac
32
33
do_ () {
34
    # Fetch
35
    for M in $MACS; do
36
	RSSI=$(wl rssi $M | cut -d' ' -f3)
37
        m=$(echo $M | tr -d ':')
38
	echo rssi$m.value $RSSI
39
    done
40
}
41
42
do_config () {
43
    cat <<'EOF'
44
graph_title WiFi AP RSSI
45
graph_vlabel dB(?)
46
graph_category network
47
graph_info This plugin shows the RSSI (Received Signal Strength Indication) as reported by the Access Point (AP) driver. The plugin is specific to broadcom wireless chipsets such as used on WRT hardware. We're not <em>quite</em> sure about the units the RSSI is measured in as this is not documented. Both dB and dBm are apparently candidates.  Higher is better.
48
EOF
49
    # Atempt to find default. "Set default" and "assign default" syntax is
50
    # not available in busybox (which is used in openwrt firmware) it seems.
51
    # So work around it with case.
52
    : ${WIFISIDE:=$(nvram get lan_ifname 2>/dev/null)}
53
    : ${WIFISIDE:=$(awk '/:/ { gsub(/^ */,""); gsub(/:/," "); print $1; exit 0; }' /proc/net/wireless)}
54
55
    HOSTS="$(cat /etc/hosts)"
56
    ETHERS="$( ( cat /etc/etherss 2>/dev/null; awk '/'$WIFISIDE'$/ { print $4" "$1 }' /proc/net/arp ) | sort -u)"
57
    for M in $MACS; do
58
	m=$(echo $M | tr -d ':')
59
	LABEL=$M
60
        NAME=''
61
	
62
        IP=$(echo "$ETHERS" | awk '/^'$M'/ { print $2; }')
63
	case $IP in
64
		'') :;;
65
		*)  LABEL=$IP
66
		    # Make IP "RE safe"
67
		    IP="$(echo $IP | sed 's/\./\\./g')"
68
		    NAME=$(echo "$HOSTS" | awk '/^'$IP'/ { print $2; }')
69
	esac
70
	case $NAME in
71
		'') :;;
72
		*)  LABEL=$NAME;;
73
	esac
74
	echo rssi$m.label $LABEL
75
    done
76
}
77
78
do_autoconf () {
79
    case $WLERR in
80
	0) echo yes; exit 0;;
81
	127) echo "no ($AL)"; exit 1;;
82
	*)   echo "no (wl error: $AL)"; exit 1;;
83
        *) echo "no (no wl executable, or error)"; exit 1;;
84
    esac
85
}
86
87
case $1 in
88
     ''|config|autoconf)
89
	eval do_$1;;
90
esac