Compare commits

...

3 Commits

Author SHA1 Message Date
8990114eb3
Responses codes 2021-12-27 23:32:47 +01:00
659bbc5c83
Installation instructions 2021-12-27 23:32:30 +01:00
5a0c2a2a4b
License 2021-12-27 19:00:04 +01:00
4 changed files with 105 additions and 2 deletions

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) <year> <copyright holders> Copyright (c) 2021 Antoine Van Elstraete
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -1,3 +1,53 @@
# knot_ # knot_
Knot munin stats Knot munin stats
## Install
### Knot config
Add a "mod-stats" section, e.g. :
mod-stats:
- id: custom-stats
request-protocol: on
server-operation: on
request-bytes: on
response-bytes: on
edns-presence: on
flag-presence: on
response-code: on
request-edns-option: on
response-edns-option: on
reply-nodata: on
query-type: on
query-size: on
reply-size: on
Add a "statistics" section, e.g. :
statistics:
timer: 60
file: /tmp/knot-stats.yaml
append: false
In your zone template, add a "mod-stats", e.g. :
template:
- id: signed
storage: "/var/db/knot"
semantic-checks: on
dnssec-signing: on
dnssec-policy: shared
module: mod-stats/custom-stats
### Munin config
Create "knot" in the plugin-conf.d directory and put :
[knot_*]
user root
env.stats_file_path /tmp/knot-stats.yaml
Please adapt the path of the stats file, according to knot config, statistics section.

52
knot_ Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env python3
import yaml
from sys import argv
from os import getenv
def responses(stats, config):
'''
This will show what knot have responded.
'''
responses_stats = {}
if 'response-code' not in stats['mod-stats']:
responses_stats.update({'NOERROR': 0})
else:
for code in stats['mod-stats']['response-code']:
responses_stats.update(
{
code:
stats['mod-stats']['response-code'][code]
}
)
# Configure the plugin :
if config:
print("graph_title Knot responses")
print("graph_category dns")
print("graph_vlabel responses")
print("graph_args --base 1000 --lower-limit 0")
for code in responses_stats:
print(f"{code}.label {code}")
print(f"{code}.type DERIVE")
print(f"{code}.min 0")
else: # Send the values
for code in responses_stats:
print(f"{code}.value {responses_stats[code]}")
if __name__ == '__main__':
# Retrieve datas :
file = getenv('stats_file_path')
with open(file, "r") as stats_file:
stats = yaml.safe_load(stats_file)
if len(argv) > 1 and argv[1] == "config":
config = True
else:
config = False
if "responses" in argv[0]:
responses(stats, config)
elif "proto" in argv[0]:
pass
else:
pass # Nothing happens if no "munin underscore args"

1
knot_responses Symbolic link
View File

@ -0,0 +1 @@
knot_