# no need for shebang - this file is loaded from charts.d.plugin # _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() { require_cmd iw || return 1 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 <