Compare commits
9 Commits
36312cb6d2
...
master
Author | SHA1 | Date | |
---|---|---|---|
ae7ad63d52
|
|||
cac3225224
|
|||
0f1ac76bcc
|
|||
3e3608960f
|
|||
3a1845d8cd
|
|||
d7f2926222
|
|||
8990114eb3
|
|||
659bbc5c83
|
|||
5a0c2a2a4b
|
2
LICENSE
2
LICENSE
@ -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:
|
||||||
|
|
||||||
|
50
README.md
50
README.md
@ -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.
|
||||||
|
121
knot_
Executable file
121
knot_
Executable file
@ -0,0 +1,121 @@
|
|||||||
|
#!/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 / ${graph_period}")
|
||||||
|
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]}")
|
||||||
|
|
||||||
|
|
||||||
|
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]}")
|
||||||
|
|
||||||
|
|
||||||
|
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')
|
||||||
|
with open(file, "r") as 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":
|
||||||
|
config = True
|
||||||
|
else:
|
||||||
|
config = False
|
||||||
|
if "responses" in argv[0]:
|
||||||
|
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"
|
1
knot_bandwith
Symbolic link
1
knot_bandwith
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
knot_
|
1
knot_proto
Symbolic link
1
knot_proto
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
knot_
|
1
knot_responses
Symbolic link
1
knot_responses
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
knot_
|
Reference in New Issue
Block a user