diff --git a/plugins/wifi/ath9k_ b/plugins/wifi/ath9k_ index 405b93c2..a43d844d 100755 --- a/plugins/wifi/ath9k_ +++ b/plugins/wifi/ath9k_ @@ -5,6 +5,7 @@ # * rate control statistics ("rc_stats") # * events (dropped, transmitted, beacon loss, ...) # * traffic (packets, bytes) +# * DFS events (processed patterns, approved signals) # # All data is collected for each separate station (in case of multiple # connected peers). Combined graphs are provided as a summary. @@ -15,7 +16,19 @@ # * micropython # # -# Copyright (C) 2015 Lars Kruse +# The following graphs are generated for each physical ath9k interface: +# phy0_wifi0_traffic +# phy0_wifi0_traffic.station0 +# ... +# pyh0_wifi0_events +# phy0_wifi0_events.station0 +# ... +# pyh0_wifi0_rc_stats +# phy0_wifi0_rc_stats.station0 +# ... +# +# +# Copyright (C) 2015-2018 Lars Kruse # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,8 +44,8 @@ # along with this program. If not, see . # # Magic markers -#%# capabilities=autoconf suggest -#%# family=auto +# #%# capabilities=autoconf suggest +# #%# family=auto """true" # ****************** Interpreter Selection *************** @@ -41,14 +54,16 @@ # # This "execution hack" works as follows: # * the script is executed by busybox ash or another shell -# * the above line (three quotes before and one quote after 'true') evaluates differently for shell and python: -# * shell: run "true" (i.e. nothing happens) -# * python: ignore everything up to the next three consecutive quotes +# * the above line (three quotes before and one quote after 'true') evaluates differently for +# shell and python: +# * shell: run "true" (i.e. nothing happens) +# * python: ignore everything up to the next three consecutive quotes # Thus we may place shell code here that will take care for selecting an interpreter. -# prefer micropython if it is available - otherwise fall back to any python (2 or 3) -if which micropython >/dev/null; then - /usr/bin/micropython "$0" "$@" +# prefer micropython if it is available - otherwise fall back to python 3 +MICROPYTHON_BIN=$(which micropython || true) +if [ -n "$MICROPYTHON_BIN" ]; then + "$MICROPYTHON_BIN" "$0" "$@" else python3 "$0" "$@" fi @@ -59,26 +74,20 @@ exit $? true < 0 def _get_up_down_pair(unit, key_up, key_down, factor=None, divider=None, use_negative=True): @@ -407,8 +544,9 @@ def get_scope(): name_prefix = "ath9k_" if called_name.startswith(name_prefix): scope = called_name[len(name_prefix):] - if not scope in PLUGIN_SCOPES: - print_error("Invalid scope requested: {0} (expected: {1})".format(scope, PLUGIN_SCOPES)) + if scope not in PLUGIN_SCOPES: + print_error("Invalid scope requested: {0} (expected: {1})" + .format(scope, PLUGIN_SCOPES)) sys.exit(2) else: print_error("Invalid filename - failed to discover plugin scope") @@ -422,23 +560,37 @@ def print_error(message): sys.stderr.write(message + linesep) +def do_fetch(ath9k): + for item in ath9k.get_values(get_scope()): + print(item) + + +def do_config(ath9k): + for item in ath9k.get_config(get_scope()): + print(item) + + if __name__ == "__main__": ath9k = Ath9kDriver(SYS_BASE_DIR, GRAPH_BASE_NAME) # parse arguments if len(sys.argv) > 1: - if sys.argv[1]=="config": - for item in ath9k.get_config(get_scope()): - print(item) + if sys.argv[1] == "config": + do_config(ath9k) + if os.getenv("MUNIN_CAP_DIRTYCONFIG") == "1": + do_fetch(ath9k) sys.exit(0) elif sys.argv[1] == "autoconf": - if os.path.exists(SYS_BASE_PATH): + if os.path.exists(SYS_BASE_DIR): print('yes') else: - print('no') + print('no (missing ath9k driver sysfs directory: {})'.format(SYS_BASE_DIR)) sys.exit(0) elif sys.argv[1] == "suggest": - for scope in PLUGIN_SCOPES: - print(scope) + if ath9k.has_devices(): + for scope in PLUGIN_SCOPES: + # skip the "dfs_events" scope if there is not DFS support + if (scope != "dfs_events") or ath9k.has_dfs_support(): + print(scope) sys.exit(0) elif sys.argv[1] == "version": print_error('olsrd Munin plugin, version %s' % plugin_version) @@ -451,9 +603,7 @@ if __name__ == "__main__": print_error("Unknown argument") sys.exit(1) - # output values - for item in ath9k.get_values(get_scope()): - print(item) + do_fetch(ath9k) # final marker for shell / python hybrid script (see "Interpreter Selection") EOF = True