Compare commits

...

2 Commits

Author SHA1 Message Date
ae7ad63d52 Bandwith 2021-12-28 00:45:36 +01:00
cac3225224 Remove the unecesseray time thing 2021-12-28 00:18:47 +01:00
2 changed files with 41 additions and 3 deletions

43
knot_
View File

@ -64,10 +64,45 @@ def proto(stats, config):
print(f"{proto}.value {proto_stats[proto]}") 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__': if __name__ == '__main__':
# Retrieve datas : # Retrieve datas :
file = getenv('stats_file_path') file = getenv('stats_file_path')
munin_time = getenv('munin_time', 300)
with open(file, "r") as stats_file: with open(file, "r") as stats_file:
stats = yaml.safe_load(stats_file) stats = yaml.safe_load(stats_file)
if "mod-stats" not in stats: if "mod-stats" not in stats:
@ -77,8 +112,10 @@ if __name__ == '__main__':
else: else:
config = False config = False
if "responses" in argv[0]: if "responses" in argv[0]:
responses(stats, config, munin_time) responses(stats, config)
elif "proto" in argv[0]: elif "proto" in argv[0]:
proto(stats, config, munin_time) proto(stats, config)
elif "bandwith" in argv[0]:
bandwith(stats, config)
else: else:
pass # Nothing happens if no "munin underscore args" pass # Nothing happens if no "munin underscore args"

1
knot_bandwith Symbolic link
View File

@ -0,0 +1 @@
knot_