diff --git a/knot_ b/knot_ index 1a4f5cb..bc21c4c 100755 --- a/knot_ +++ b/knot_ @@ -34,6 +34,34 @@ def responses(stats, config): for code in responses_stats: print(f"{code}.value {responses_stats[code]}") +def proto(stats, config): + ''' + This will show if ipv4 or ipv6 and if tcp or udp are used. + ''' + proto_stats = {} + if 'request-protocol' not in stats['mod-stats']: + proto_stats.update({'udp4': 0}) + else: + for proto in stats['mod-stats']['request-protocol']: + proto_stats.update( + { + proto: + stats['mod-stats']['request-protocol'][proto] + } + ) + if config: # Configure the plugin + print("graph_title Knot protocols") + print("graph_category dns") + print("graph_vlabel numbers of requests") + print("graph_args --base 1000 --lower-limit 0") + for proto in proto_stats: + print(f"{proto}.label {proto}") + print(f"{proto}.type DERIVE") + print(f"{proto}.min 0") + else: # Send the values + for proto in proto_stats: + print(f"{proto}.value {proto_stats[proto]}") + if __name__ == '__main__': # Retrieve datas : @@ -49,6 +77,6 @@ if __name__ == '__main__': if "responses" in argv[0]: responses(stats, config) elif "proto" in argv[0]: - pass + proto(stats, config) else: pass # Nothing happens if no "munin underscore args" diff --git a/knot_proto b/knot_proto new file mode 120000 index 0000000..22ba831 --- /dev/null +++ b/knot_proto @@ -0,0 +1 @@ +knot_ \ No newline at end of file