From 9ce153ce7167c11adba8ac225edc7a707e97c6eb Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Wed, 30 Mar 2016 22:40:42 +0100 Subject: Imported Upstream version 1.0.0 --- charts.d/ap.chart.sh | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100755 charts.d/ap.chart.sh (limited to 'charts.d/ap.chart.sh') diff --git a/charts.d/ap.chart.sh b/charts.d/ap.chart.sh new file mode 100755 index 000000000..4704b89de --- /dev/null +++ b/charts.d/ap.chart.sh @@ -0,0 +1,160 @@ +#!/bin/sh + +# _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=() + +export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/sbin" + +# _check is called once, to find out if this chart should be enabled or not +ap_check() { + local ev=$(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 + 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 <