summaryrefslogtreecommitdiffstats
path: root/charts.d/ap.chart.sh
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2017-04-30 16:09:37 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2017-04-30 18:09:45 +0000
commitbed7e5b6a0b9ea0ddfc76c6f77eb91df81b92521 (patch)
tree519e5945ec0db75bfb50583539caa408a5819e87 /charts.d/ap.chart.sh
parentTemporarily disable signature checking (diff)
downloadnetdata-bed7e5b6a0b9ea0ddfc76c6f77eb91df81b92521.tar.xz
netdata-bed7e5b6a0b9ea0ddfc76c6f77eb91df81b92521.zip
New upstream version 1.6.0+dfsg
Diffstat (limited to 'charts.d/ap.chart.sh')
-rw-r--r--[-rwxr-xr-x]charts.d/ap.chart.sh142
1 files changed, 78 insertions, 64 deletions
diff --git a/charts.d/ap.chart.sh b/charts.d/ap.chart.sh
index 0e85c486d..ce2eefc9f 100755..100644
--- a/charts.d/ap.chart.sh
+++ b/charts.d/ap.chart.sh
@@ -16,7 +16,7 @@ declare -A ap_devs=()
# _check is called once, to find out if this chart should be enabled or not
ap_check() {
require_cmd iw || return 1
-
+
local ev=$(run iw dev | awk '
BEGIN {
i = "";
@@ -77,20 +77,19 @@ DIMENSION retries 'tx retries' incremental 1 1
DIMENSION failures 'tx failures' incremental -1 1
CHART ap_signal.${dev} '' "Average Signal for ${ssid} on ${dev}" "dBm" ${dev} ap.signal line $((ap_priority + 5)) $ap_update_every
-DIMENSION signal 'average signal' absolute 1 1
+DIMENSION signal 'average signal' absolute 1 1000
CHART ap_bitrate.${dev} '' "Bitrate for ${ssid} on ${dev}" "Mbps" ${dev} ap.bitrate line $((ap_priority + 6)) $ap_update_every
DIMENSION receive '' absolute 1 1000
DIMENSION transmit '' absolute -1 1000
DIMENSION expected 'expected throughput' absolute 1 1000
EOF
-
done
return 0
}
-# _update is called continiously, to collect the values
+# _update is called continuously, to collect the values
ap_update() {
# the first argument to this function is the microseconds since last update
# pass this parameter to the BEGIN statement (see bellow).
@@ -101,66 +100,81 @@ ap_update() {
for dev in "${!ap_devs[@]}"
do
- iw ${dev} station dump |\
- awk "
- BEGIN {
- c = 0;
- rb = 0;
- tb = 0;
- rp = 0;
- tp = 0;
- tr = 0;
- tf = 0;
- tt = 0;
- rt = 0;
- s = 0;
- g = 0;
- e = 0;
- }
- /^Station/ { c++; }
- /^[ \\t]+rx bytes:/ { rb += \$3 }
- /^[ \\t]+tx bytes:/ { tb += \$3 }
- /^[ \\t]+rx packets:/ { rp += \$3 }
- /^[ \\t]+tx packets:/ { tp += \$3 }
- /^[ \\t]+tx retries:/ { tr += \$3 }
- /^[ \\t]+tx failed:/ { tf += \$3 }
- /^[ \\t]+signal:/ { s += \$2; }
- /^[ \\t]+rx bitrate:/ { x = \$3; rt += x * 1000; }
- /^[ \\t]+tx bitrate:/ { x = \$3; tt += x * 1000; }
- /^[ \\t]+expected throughput:(.*)Mbps/ {
- x=\$3;
- sub(/Mbps/, \"\", x);
- e += x * 1000;
- }
- END {
- print \"BEGIN ap_clients.${dev}\"
- print \"SET clients = \" c;
- print \"END\"
- print \"BEGIN ap_bandwidth.${dev}\"
- print \"SET received = \" rb;
- print \"SET sent = \" tb;
- print \"END\"
- print \"BEGIN ap_packets.${dev}\"
- print \"SET received = \" rp;
- print \"SET sent = \" tp;
- print \"END\"
- print \"BEGIN ap_issues.${dev}\"
- print \"SET retries = \" tr;
- print \"SET failures = \" tf;
- print \"END\"
- print \"BEGIN ap_signal.${dev}\"
- print \"SET signal = \" s / c;
- print \"END\"
-
- if( c == 0 ) c = 1;
- print \"BEGIN ap_bitrate.${dev}\"
- print \"SET receive = \" rt / c;
- print \"SET transmit = \" tt / c;
- print \"SET expected = \" e / c;
- print \"END\"
- }
- "
- done
+ echo
+ echo "DEVICE ${dev}"
+ iw ${dev} station dump
+ done | awk "
+ function zero_data() {
+ dev = \"\";
+ c = 0;
+ rb = 0;
+ tb = 0;
+ rp = 0;
+ tp = 0;
+ tr = 0;
+ tf = 0;
+ tt = 0;
+ rt = 0;
+ s = 0;
+ g = 0;
+ e = 0;
+ }
+ function print_device() {
+ if(dev != \"\" && length(dev) > 0) {
+ print \"BEGIN ap_clients.\" dev;
+ print \"SET clients = \" c;
+ print \"END\";
+ print \"BEGIN ap_bandwidth.\" dev;
+ print \"SET received = \" rb;
+ print \"SET sent = \" tb;
+ print \"END\";
+ print \"BEGIN ap_packets.\" dev;
+ print \"SET received = \" rp;
+ print \"SET sent = \" tp;
+ print \"END\";
+ print \"BEGIN ap_issues.\" dev;
+ print \"SET retries = \" tr;
+ print \"SET failures = \" tf;
+ print \"END\";
+
+ if( c == 0 ) c = 1;
+ print \"BEGIN ap_signal.\" dev;
+ print \"SET signal = \" int(s / c);
+ print \"END\";
+ print \"BEGIN ap_bitrate.\" dev;
+ print \"SET receive = \" int(rt / c);
+ print \"SET transmit = \" int(tt / c);
+ print \"SET expected = \" int(e / c);
+ print \"END\";
+ }
+ zero_data();
+ }
+ BEGIN {
+ zero_data();
+ }
+ /^DEVICE / {
+ print_device();
+ dev = \$2;
+ }
+ /^Station/ { c++; }
+ /^[ \\t]+rx bytes:/ { rb += \$3; }
+ /^[ \\t]+tx bytes:/ { tb += \$3; }
+ /^[ \\t]+rx packets:/ { rp += \$3; }
+ /^[ \\t]+tx packets:/ { tp += \$3; }
+ /^[ \\t]+tx retries:/ { tr += \$3; }
+ /^[ \\t]+tx failed:/ { tf += \$3; }
+ /^[ \\t]+signal:/ { x = \$2; s += x * 1000; }
+ /^[ \\t]+rx bitrate:/ { x = \$3; rt += x * 1000; }
+ /^[ \\t]+tx bitrate:/ { x = \$3; tt += x * 1000; }
+ /^[ \\t]+expected throughput:(.*)Mbps/ {
+ x=\$3;
+ sub(/Mbps/, \"\", x);
+ e += x * 1000;
+ }
+ END {
+ print_device();
+ }
+ "
return 0
}