From a64a253794ac64cb40befee54db53bde17dd0d49 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 7 Nov 2018 13:19:29 +0100 Subject: New upstream version 1.11.0+dfsg Signed-off-by: Daniel Baumann --- collectors/charts.d.plugin/ap/Makefile.inc | 13 +++ collectors/charts.d.plugin/ap/README.md | 84 +++++++++++++ collectors/charts.d.plugin/ap/ap.chart.sh | 182 +++++++++++++++++++++++++++++ collectors/charts.d.plugin/ap/ap.conf | 23 ++++ 4 files changed, 302 insertions(+) create mode 100644 collectors/charts.d.plugin/ap/Makefile.inc create mode 100644 collectors/charts.d.plugin/ap/README.md create mode 100644 collectors/charts.d.plugin/ap/ap.chart.sh create mode 100644 collectors/charts.d.plugin/ap/ap.conf (limited to 'collectors/charts.d.plugin/ap') diff --git a/collectors/charts.d.plugin/ap/Makefile.inc b/collectors/charts.d.plugin/ap/Makefile.inc new file mode 100644 index 000000000..a2dd375ac --- /dev/null +++ b/collectors/charts.d.plugin/ap/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += ap/ap.chart.sh +dist_chartsconfig_DATA += ap/ap.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += ap/README.md ap/Makefile.inc + diff --git a/collectors/charts.d.plugin/ap/README.md b/collectors/charts.d.plugin/ap/README.md new file mode 100644 index 000000000..eb4e80707 --- /dev/null +++ b/collectors/charts.d.plugin/ap/README.md @@ -0,0 +1,84 @@ +# Access Point Plugin (ap) + +The `ap` collector visualizes data related to access points. + +## Example netdata charts + +![image](https://cloud.githubusercontent.com/assets/2662304/12377654/9f566e88-bd2d-11e5-855a-e0ba96b8fd98.png) + +## How it works + +It does the following: + +1. Runs `iw dev` searching for interfaces that have `type AP`. + + From the same output it collects the SSIDs each AP supports by looking for lines `ssid NAME`. + + Example: +```sh +# iw dev +phy#0 + Interface wlan0 + ifindex 3 + wdev 0x1 + addr 7c:dd:90:77:34:2a + ssid TSAOUSIS + type AP + channel 7 (2442 MHz), width: 20 MHz, center1: 2442 MHz +``` + + +2. For each interface found, it runs `iw INTERFACE station dump`. + + From the output is collects: + + - rx/tx bytes + - rx/tx packets + - tx retries + - tx failed + - signal strength + - rx/tx bitrate + - expected throughput + + Example: + +```sh +# iw wlan0 station dump +Station 40:b8:37:5a:ed:5e (on wlan0) + inactive time: 910 ms + rx bytes: 15588897 + rx packets: 127772 + tx bytes: 52257763 + tx packets: 95802 + tx retries: 2162 + tx failed: 28 + signal: -43 dBm + signal avg: -43 dBm + tx bitrate: 65.0 MBit/s MCS 7 + rx bitrate: 1.0 MBit/s + expected throughput: 32.125Mbps + authorized: yes + authenticated: yes + preamble: long + WMM/WME: yes + MFP: no + TDLS peer: no +``` + +3. For each interface found, it creates 6 charts: + + - Number of Connected clients + - Bandwidth for all clients + - Packets for all clients + - Transmit Issues for all clients + - Average Signal among all clients + - Average Bitrate (including average expected throughput) among all clients + +## Configuration + +You can only set `ap_update_every=NUMBER` to `/etc/netdata/charts.d/ap.conf`, to give the data collection frequency. +To edit this file on your system run `/etc/netdata/edit-config charts.d/ap.conf`. + +## Auto-detection + +The plugin is able to auto-detect if you are running access points on your linux box. diff --git a/collectors/charts.d.plugin/ap/ap.chart.sh b/collectors/charts.d.plugin/ap/ap.chart.sh new file mode 100644 index 000000000..ccc36120c --- /dev/null +++ b/collectors/charts.d.plugin/ap/ap.chart.sh @@ -0,0 +1,182 @@ +# shellcheck shell=bash +# no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later + +# netdata +# real-time performance and health monitoring, done right! +# (C) 2016 Costa Tsaousis +# + +# _update_every is a special variable - it holds the number of seconds +# between the calls of the _update() function +ap_update_every= +ap_priority=6900 + +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 + ev=$(run iw dev | awk ' + BEGIN { + i = ""; + ssid = ""; + ap = 0; + } + /^[ \t]+Interface / { + if( ap == 1 ) { + print "ap_devs[" i "]=\"" ssid "\"" + } + + i = $2; + ssid = ""; + ap = 0; + } + /^[ \t]+ssid / { ssid = $2; } + /^[ \t]+type AP$/ { ap = 1; } + END { + if( ap == 1 ) { + print "ap_devs[" i "]=\"" ssid "\"" + } + } + ') + eval "${ev}" + + # this should return: + # - 0 to enable the chart + # - 1 to disable the chart + + [ ${#ap_devs[@]} -gt 0 ] && return 0 + error "no devices found in AP mode, with 'iw dev'" + return 1 +} + +# _create is called once, to create the charts +ap_create() { + local ssid dev + + for dev in "${!ap_devs[@]}" + do + ssid="${ap_devs[${dev}]}" + + # create the chart with 3 dimensions + cat < 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 +} + diff --git a/collectors/charts.d.plugin/ap/ap.conf b/collectors/charts.d.plugin/ap/ap.conf new file mode 100644 index 000000000..38fc157ce --- /dev/null +++ b/collectors/charts.d.plugin/ap/ap.conf @@ -0,0 +1,23 @@ +# no need for shebang - this file is loaded from charts.d.plugin + +# netdata +# real-time performance and health monitoring, done right! +# (C) 2018 Costa Tsaousis +# GPL v3+ + +# nothing fancy to configure. +# this module will run +# iw dev - to find wireless devices in AP mode +# iw ${dev} station dump - to get connected clients +# based on the above, it generates several charts + +# the data collection frequency +# if unset, will inherit the netdata update frequency +#ap_update_every= + +# the charts priority on the dashboard +#ap_priority=6900 + +# the number of retries to do in case of failure +# before disabling the module +#ap_retries=10 -- cgit v1.2.3