3 # _update_every is a special variable - it holds the number of seconds
4 # between the calls of the _update() function
10 export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin"
12 # _check is called once, to find out if this chart should be enabled or not
14 local ev=$(iw dev | awk '
22 print "ap_devs[" i "]=\"" ssid "\""
29 /^[ \t]+ssid / { ssid = $2; }
30 /^[ \t]+type AP$/ { ap = 1; }
33 print "ap_devs[" i "]=\"" ssid "\""
40 # - 0 to enable the chart
41 # - 1 to disable the chart
43 [ ${#ap_devs[@]} -gt 0 ] && return 0
47 # _create is called once, to create the charts
51 for dev in "${!ap_devs[@]}"
53 ssid="${ap_devs[${dev}]}"
55 # create the chart with 3 dimensions
57 CHART ap_clients.${dev} '' "Connected clients to ${ssid} on ${dev}" "clients" ${dev} ap.clients line $[ap_priority + 1] $ap_update_every
58 DIMENSION clients '' absolute 1 1
60 CHART ap_bandwidth.${dev} '' "Bandwidth for ${ssid} on ${dev}" "kilobits/s" ${dev} ap.net area $[ap_priority + 2] $ap_update_every
61 DIMENSION received '' incremental 8 1024
62 DIMENSION sent '' incremental -8 1024
64 CHART ap_packets.${dev} '' "Packets for ${ssid} on ${dev}" "packets/s" ${dev} ap.packets line $[ap_priority + 3] $ap_update_every
65 DIMENSION received '' incremental 1 1
66 DIMENSION sent '' incremental -1 1
68 CHART ap_issues.${dev} '' "Transmit Issues for ${ssid} on ${dev}" "issues/s" ${dev} ap.issues line $[ap_priority + 4] $ap_update_every
69 DIMENSION retries 'tx retries' incremental 1 1
70 DIMENSION failures 'tx failures' incremental -1 1
72 CHART ap_signal.${dev} '' "Average Signal for ${ssid} on ${dev}" "dBm" ${dev} ap.signal line $[ap_priority + 5] $ap_update_every
73 DIMENSION signal 'average signal' absolute 1 1
75 CHART ap_bitrate.${dev} '' "Bitrate for ${ssid} on ${dev}" "Mbps" ${dev} ap.bitrate line $[ap_priority + 6] $ap_update_every
76 DIMENSION receive '' absolute 1 1000
77 DIMENSION transmit '' absolute -1 1000
78 DIMENSION expected 'expected throughput' absolute 1 1000
86 # _update is called continiously, to collect the values
88 # the first argument to this function is the microseconds since last update
89 # pass this parameter to the BEGIN statement (see bellow).
91 # do all the work to collect / calculate the values
93 # remember: KEEP IT SIMPLE AND SHORT
95 for dev in "${!ap_devs[@]}"
97 iw ${dev} station dump |\
114 /^[ \\t]+rx bytes:/ { rb += \$3 }
115 /^[ \\t]+tx bytes:/ { tb += \$3 }
116 /^[ \\t]+rx packets:/ { rp += \$3 }
117 /^[ \\t]+tx packets:/ { tp += \$3 }
118 /^[ \\t]+tx retries:/ { tr += \$3 }
119 /^[ \\t]+tx failed:/ { tf += \$3 }
120 /^[ \\t]+signal:/ { s += \$2; }
121 /^[ \\t]+rx bitrate:/ { x = \$3; rt += x * 1000; }
122 /^[ \\t]+tx bitrate:/ { x = \$3; tt += x * 1000; }
123 /^[ \\t]+expected throughput:(.*)Mbps/ {
125 sub(/Mbps/, \"\", x);
129 print \"BEGIN ap_clients.${dev}\"
130 print \"SET clients = \" c;
132 print \"BEGIN ap_bandwidth.${dev}\"
133 print \"SET received = \" rb;
134 print \"SET sent = \" tb;
136 print \"BEGIN ap_packets.${dev}\"
137 print \"SET received = \" rp;
138 print \"SET sent = \" tp;
140 print \"BEGIN ap_issues.${dev}\"
141 print \"SET retries = \" tr;
142 print \"SET failures = \" tf;
144 print \"BEGIN ap_signal.${dev}\"
145 print \"SET signal = \" s / c;
149 print \"BEGIN ap_bitrate.${dev}\"
150 print \"SET receive = \" rt / c;
151 print \"SET transmit = \" tt / c;
152 print \"SET expected = \" e / c;