3 # _update_every is a special variable - it holds the number of seconds
4 # between the calls of the _update() function
9 export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
11 # _check is called once, to find out if this chart should be enabled or not
13 local ev=$(iw dev | awk '
21 print "ap_devs[" i "]=\"" ssid "\""
28 /^[ \t]+ssid / { ssid = $2; }
29 /^[ \t]+type AP$/ { ap = 1; }
32 print "ap_devs[" i "]=\"" ssid "\""
39 # - 0 to enable the chart
40 # - 1 to disable the chart
42 [ ${#ap_devs[@]} -gt 0 ] && return 0
46 # _create is called once, to create the charts
50 for dev in "${!ap_devs[@]}"
52 ssid="${ap_devs[${dev}]}"
54 # create the chart with 3 dimensions
56 CHART ap_clients.${dev} '' "Connected clients to ${ssid} on ${dev}" "clients" ${dev} ${dev} line 15000 $ap_update_every
57 DIMENSION clients '' absolute 1 1
59 CHART ap_bandwidth.${dev} '' "Bandwidth for ${ssid} on ${dev}" "kilobits/s" ${dev} ${dev} area 15001 $ap_update_every
60 DIMENSION received '' incremental 8 1024
61 DIMENSION sent '' incremental -8 1024
63 CHART ap_packets.${dev} '' "Packets for ${ssid} on ${dev}" "packets/s" ${dev} ${dev} line 15002 $ap_update_every
64 DIMENSION received '' incremental 1 1
65 DIMENSION sent '' incremental -1 1
67 CHART ap_issues.${dev} '' "Transmit Issues for ${ssid} on ${dev}" "issues/s" ${dev} ${dev} line 15003 $ap_update_every
68 DIMENSION retries 'tx retries' incremental 1 1
69 DIMENSION failures 'tx failures' incremental -1 1
71 CHART ap_signal.${dev} '' "Average Signal for ${ssid} on ${dev}" "dBm" ${dev} ${dev} line 15004 $ap_update_every
72 DIMENSION signal 'average signal' absolute 1 1
74 CHART ap_bitrate.${dev} '' "Bitrate for ${ssid} on ${dev}" "Mbps" ${dev} ${dev} line 15005 $ap_update_every
75 DIMENSION receive '' absolute 1 1024
76 DIMENSION transmit '' absolute -1 1024
77 DIMENSION expected 'expected throughput' absolute 1 1024
85 # _update is called continiously, to collect the values
87 # the first argument to this function is the microseconds since last update
88 # pass this parameter to the BEGIN statement (see bellow).
90 # do all the work to collect / calculate the values
92 # remember: KEEP IT SIMPLE AND SHORT
94 for dev in "${!ap_devs[@]}"
96 iw ${dev} station dump |\
113 /^[ \\t]+rx bytes:/ { rb += \$3 }
114 /^[ \\t]+tx bytes:/ { tb += \$3 }
115 /^[ \\t]+rx packets:/ { rp += \$3 }
116 /^[ \\t]+tx packets:/ { tp += \$3 }
117 /^[ \\t]+tx retries:/ { tr += \$3 }
118 /^[ \\t]+tx failed:/ { tf += \$3 }
119 /^[ \\t]+signal:/ { s += \$2; }
120 /^[ \\t]+rx bitrate:/ { x = \$3; rt += x * 1000; }
121 /^[ \\t]+tx bitrate:/ { x = \$3; tt += x * 1000; }
122 /^[ \\t]+expected throughput:(.*)Mbps/ {
124 sub(/Mbps/, \"\", x);
128 print \"BEGIN ap_clients.${dev}\"
129 print \"SET clients = \" c;
131 print \"BEGIN ap_bandwidth.${dev}\"
132 print \"SET received = \" rb;
133 print \"SET sent = \" tb;
135 print \"BEGIN ap_packets.${dev}\"
136 print \"SET received = \" rp;
137 print \"SET sent = \" tp;
139 print \"BEGIN ap_issues.${dev}\"
140 print \"SET retries = \" tr;
141 print \"SET failures = \" tf;
143 print \"BEGIN ap_signal.${dev}\"
144 print \"SET signal = \" s / c;
148 print \"BEGIN ap_bitrate.${dev}\"
149 print \"SET receive = \" rt / c;
150 print \"SET transmit = \" tt / c;
151 print \"SET expected = \" e / c;