Compare commits

...

4 Commits

2 changed files with 36 additions and 3 deletions

38
knot_
View File

@ -24,7 +24,7 @@ def responses(stats, config):
if config: if config:
print("graph_title Knot responses") print("graph_title Knot responses")
print("graph_category dns") print("graph_category dns")
print("graph_vlabel responses") print("graph_vlabel responses / ${graph_period}")
print("graph_args --base 1000 --lower-limit 0") print("graph_args --base 1000 --lower-limit 0")
for code in responses_stats: for code in responses_stats:
print(f"{code}.label {code}") print(f"{code}.label {code}")
@ -35,18 +35,50 @@ def responses(stats, config):
print(f"{code}.value {responses_stats[code]}") 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 / ${graph_period}")
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__': 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:
raise Exception("Please configure knot with mod-stats")
if len(argv) > 1 and argv[1] == "config": if len(argv) > 1 and argv[1] == "config":
config = True config = True
else: else:
config = False config = False
if "responses" in argv[0]: if "responses" in argv[0]:
responses(stats, config) responses(stats, config, munin_time)
elif "proto" in argv[0]: elif "proto" in argv[0]:
pass proto(stats, config, munin_time)
else: else:
pass # Nothing happens if no "munin underscore args" pass # Nothing happens if no "munin underscore args"

1
knot_proto Symbolic link
View File

@ -0,0 +1 @@
knot_