From ae7ad63d5261e0da6fcf7481f6a69b8f539b4197 Mon Sep 17 00:00:00 2001 From: Antoine Van Elstraete Date: Tue, 28 Dec 2021 00:45:36 +0100 Subject: [PATCH] Bandwith --- knot_ | 38 ++++++++++++++++++++++++++++++++++++++ knot_bandwith | 1 + 2 files changed, 39 insertions(+) create mode 120000 knot_bandwith diff --git a/knot_ b/knot_ index 3322d45..b1f299c 100755 --- a/knot_ +++ b/knot_ @@ -64,6 +64,42 @@ def proto(stats, config): print(f"{proto}.value {proto_stats[proto]}") +def bandwith(stats, config): + ''' + This will show query and responses used bandwith. + ''' + bandwith_stats = {} + if 'request-bytes' not in stats['mod-stats']: + bandwith_stats.update({'received': 0}) + else: + bandwith_stats.update({'received': + stats['mod-stats']['request-bytes']['query']}) + if 'response-bytes' not in stats['mod-stats']: + bandwith_stats.update({'sent': 0}) + else: + bandwith_stats.update({'sent': + stats['mod-stats']['response-bytes']['reply']}) + if config: # Configure the plugin + print("graph_title Knot bandwith") + print("graph_category dns") + print("graph_vlabel bits in (-) / out (+) per ${graph_period}") + print("graph_args --base 1000") + print("graph_order down up") + print("down.label received") + print("down.type DERIVE") + print("down.min 0") + print("down.graph no") + print("down.cdef down,8,*") + print("up.label bps") + print("up.type DERIVE") + print("up.min 0") + print("up.negative down") + print("up.cdef up,8,*") + else: # Send the values + print(f"down.value {bandwith_stats['received']}") + print(f"up.value {bandwith_stats['sent']}") + + if __name__ == '__main__': # Retrieve datas : file = getenv('stats_file_path') @@ -79,5 +115,7 @@ if __name__ == '__main__': responses(stats, config) elif "proto" in argv[0]: proto(stats, config) + elif "bandwith" in argv[0]: + bandwith(stats, config) else: pass # Nothing happens if no "munin underscore args" diff --git a/knot_bandwith b/knot_bandwith new file mode 120000 index 0000000..22ba831 --- /dev/null +++ b/knot_bandwith @@ -0,0 +1 @@ +knot_ \ No newline at end of file