Projet

Général

Profil

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

root / plugins / network / brc_rssi @ cd053638

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

1
#!/bin/sh
2

    
3
: <<=cut
4

    
5
=head1 NAME
6

    
7
brc_rssi - monitor RSSI (Received Signal Strength Indication) of wireless accesspoints
8

    
9
=head1 APPLICABLE SYSTEMS
10

    
11
Wireless accesspoints with Broadcom chipset such as found on hardware supported by OpenWRT.
12
The utility "wl" is required.
13

    
14

    
15
=head1 CONFIGURATION
16

    
17
 [brc_rssi]
18
 env.WIFISIDE eth0   # Set the WiFi side interface. Used to filter arp entries.
19
                     # On a openwrt box defaults to "nvram get lan_ifname" otherwise
20
                     # no default.
21

    
22

    
23
=head1 BUGS
24

    
25
=over 4
26

    
27
=item Should have a persistent list of macs ever seen.
28

    
29
=back
30

    
31

    
32
=head1 AUTHORS
33

    
34
Copyright (C) 2007 Nicolai Langfeldt <janl@linpro.no>
35

    
36

    
37
=head1 LICENSE
38

    
39
GNU General Public License v2.0 only
40

    
41
SPDX-License-Identifier: GPL-2.0-only
42

    
43

    
44
=head1 MAGIC MARKERS
45

    
46
 #%# family=contrib
47
 #%# capabilities=autoconf
48

    
49
=cut
50

    
51

    
52
PATH=/usr/bin:/usr/sbin:/bin:/sbin
53
export PATH
54

    
55
AL="$(wl assoclist 2>&1)"
56
WLERR=$?
57
case $WLERR in
58
    0) MACS="$(echo "$AL" | cut -d' ' -f2)";;
59
esac
60

    
61
do_ () {
62
    # Fetch
63
    for M in $MACS; do
64
	RSSI=$(wl rssi $M | cut -d' ' -f3)
65
        m=$(echo $M | tr -d ':')
66
	echo rssi$m.value $RSSI
67
    done
68
}
69

    
70
do_config () {
71
    cat <<'EOF'
72
graph_title WiFi AP RSSI
73
graph_vlabel dB(?)
74
graph_category network
75
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.
76
EOF
77
    # Attempt to find default. "Set default" and "assign default" syntax is
78
    # not available in busybox (which is used in openwrt firmware) it seems.
79
    # So work around it with case.
80
    : ${WIFISIDE:=$(nvram get lan_ifname 2>/dev/null)}
81
    : ${WIFISIDE:=$(awk '/:/ { gsub(/^ */,""); gsub(/:/," "); print $1; exit 0; }' /proc/net/wireless)}
82

    
83
    HOSTS="$(cat /etc/hosts)"
84
    ETHERS="$( ( cat /etc/etherss 2>/dev/null; awk '/'$WIFISIDE'$/ { print $4" "$1 }' /proc/net/arp ) | sort -u)"
85
    for M in $MACS; do
86
	m=$(echo $M | tr -d ':')
87
	LABEL=$M
88
        NAME=''
89

    
90
        IP=$(echo "$ETHERS" | awk '/^'$M'/ { print $2; }')
91
	case $IP in
92
		'') :;;
93
		*)  LABEL=$IP
94
		    # Make IP "RE safe"
95
		    IP="$(echo $IP | sed 's/\./\\./g')"
96
		    NAME=$(echo "$HOSTS" | awk '/^'$IP'/ { print $2; }')
97
	esac
98
	case $NAME in
99
		'') :;;
100
		*)  LABEL=$NAME;;
101
	esac
102
	echo rssi$m.label $LABEL
103
    done
104
}
105

    
106
do_autoconf () {
107
    case $WLERR in
108
        0) echo yes;;
109
        127) echo "no ($AL)";;
110
        *) echo "no (wl error: $AL)";;
111
    esac
112
    exit 0
113
}
114

    
115
case $1 in
116
     ''|config|autoconf)
117
	eval do_$1;;
118
esac