Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit a8fb2ec4 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent 3a2e5ea2
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/unbound-1.2.3-20240521.mkp "unbound-1.2.3-20240521.mkp" [PACKAGE]: ../../raw/master/mkp/unbound-1.2.4-20240522.mkp "unbound-1.2.4-20240522.mkp"
# unbound # unbound
This agent plugin cheks the state of the unbound dns daemon. For more information about unbound see: https://nlnetlabs.nl/projects/unbound/about/ This agent plugin cheks the state of the unbound dns daemon. For more information about unbound see: https://nlnetlabs.nl/projects/unbound/about/
......
File added
...@@ -21,11 +21,16 @@ ...@@ -21,11 +21,16 @@
# changes by thl-cmk[at]outlook[dot]com # changes by thl-cmk[at]outlook[dot]com
# 2024-04-21: removed Union -> no need "int | float" should do # 2024-04-21: removed Union -> no need "int | float" should do
# added levels_upper_NOERROR to default parameters -> show up in info line # added levels_upper_NOERROR to default parameters -> show up in info line
# 2024-05-22: changed time for get_rate from section to system time
# added output in case get_rate is initialising (unknown state in discovery)
# removed default levels for unbound_answers
# added params for unwanted replies
from time import time as now_time
from typing import ( from typing import (
Any, Any,
Mapping, Mapping,
# Union,
) )
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
...@@ -36,7 +41,9 @@ from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import ( ...@@ -36,7 +41,9 @@ from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
from cmk.base.plugins.agent_based.agent_based_api.v1 import ( from cmk.base.plugins.agent_based.agent_based_api.v1 import (
GetRateError, GetRateError,
Result,
Service, Service,
State,
check_levels, check_levels,
get_rate, get_rate,
get_value_store, get_value_store,
...@@ -44,8 +51,6 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import ( ...@@ -44,8 +51,6 @@ from cmk.base.plugins.agent_based.agent_based_api.v1 import (
render, render,
) )
# UnboundSection = Mapping[str, Union[int, float, "UnboundSection"]]
UnboundSection = Mapping[str, int | float] UnboundSection = Mapping[str, int | float]
...@@ -64,7 +69,7 @@ def parse_unbound(string_table: StringTable) -> UnboundSection: ...@@ -64,7 +69,7 @@ def parse_unbound(string_table: StringTable) -> UnboundSection:
register.agent_section( register.agent_section(
name="unbound", name='unbound',
parse_function=parse_unbound, parse_function=parse_unbound,
) )
...@@ -75,12 +80,12 @@ def discover_unbound_cache(section: UnboundSection) -> DiscoveryResult: ...@@ -75,12 +80,12 @@ def discover_unbound_cache(section: UnboundSection) -> DiscoveryResult:
def check_unbound_cache( def check_unbound_cache(
params: Mapping[str, Any], params: Mapping[str, Any],
section: UnboundSection, section: UnboundSection,
) -> CheckResult: ) -> CheckResult:
cumulative_cache_hits = section.get('total.num.cachehits') cumulative_cache_hits = section.get('total.num.cachehits')
cumulative_cache_miss = section.get('total.num.cachemiss') cumulative_cache_miss = section.get('total.num.cachemiss')
now = section.get('time.now') now = now_time()
if None in (cumulative_cache_hits, cumulative_cache_miss, now): if None in (cumulative_cache_hits, cumulative_cache_miss, now):
return return
...@@ -104,8 +109,8 @@ def check_unbound_cache( ...@@ -104,8 +109,8 @@ def check_unbound_cache(
yield from check_levels( yield from check_levels(
value=cache_miss, value=cache_miss,
metric_name="cache_misses_rate", metric_name='cache_misses_rate',
levels_upper=params.get("cache_misses"), levels_upper=params.get('cache_misses'),
render_func=render_qps, render_func=render_qps,
label='Cache Misses', label='Cache Misses',
notice_only=True, notice_only=True,
...@@ -113,7 +118,7 @@ def check_unbound_cache( ...@@ -113,7 +118,7 @@ def check_unbound_cache(
yield from check_levels( yield from check_levels(
value=cache_hits, value=cache_hits,
metric_name="cache_hit_rate", metric_name='cache_hit_rate',
render_func=render_qps, render_func=render_qps,
label='Cache Hits', label='Cache Hits',
notice_only=True, notice_only=True,
...@@ -121,41 +126,39 @@ def check_unbound_cache( ...@@ -121,41 +126,39 @@ def check_unbound_cache(
yield from check_levels( yield from check_levels(
value=hit_perc, value=hit_perc,
metric_name="cache_hit_ratio", metric_name='cache_hit_ratio',
levels_lower=params.get("cache_hits"), levels_lower=params.get('cache_hits'),
render_func=render.percent, render_func=render.percent,
label='Cache Hit Ratio', label='Cache Hit Ratio',
) )
register.check_plugin( register.check_plugin(
name="unbound_cache", name='unbound_cache',
service_name="Unbound Cache", service_name='Unbound Cache',
sections=["unbound"], sections=['unbound'],
discovery_function=discover_unbound_cache, discovery_function=discover_unbound_cache,
check_function=check_unbound_cache, check_function=check_unbound_cache,
check_default_parameters={}, check_default_parameters={},
check_ruleset_name="unbound_cache", check_ruleset_name='unbound_cache',
) )
def discover_unbound_answers(section: UnboundSection) -> DiscoveryResult: def discover_unbound_answers(section: UnboundSection) -> DiscoveryResult:
if 'time.now' in section and 'num.answer.rcode.SERVFAIL' in section: if 'num.answer.rcode.SERVFAIL' in section:
yield Service() yield Service()
def check_unbound_answers(params: Mapping, section: UnboundSection) -> CheckResult: def check_unbound_answers(params: Mapping, section: UnboundSection) -> CheckResult:
key_prefix = 'num.answer.rcode.' key_prefix = 'num.answer.rcode.'
if 'time.now' not in section: now = now_time()
return
now = section['time.now']
total = sum( total = sum(
value for key, value in section.items() value for key, value in section.items()
if key.startswith(key_prefix) if key.startswith(key_prefix)
) )
init_counters = False
for key, value in section.items(): for key, value in section.items():
if not key.startswith(key_prefix): if not key.startswith(key_prefix):
continue continue
...@@ -169,8 +172,10 @@ def check_unbound_answers(params: Mapping, section: UnboundSection) -> CheckResu ...@@ -169,8 +172,10 @@ def check_unbound_answers(params: Mapping, section: UnboundSection) -> CheckResu
value, value,
raise_overflow=True, raise_overflow=True,
) )
except GetRateError: except GetRateError as e:
pass if not init_counters:
yield Result(state=State.OK, summary=str(e))
init_counters = True
else: else:
levels_upper = params.get(f'levels_upper_{answer}') levels_upper = params.get(f'levels_upper_{answer}')
if levels_upper is not None and len(levels_upper) == 3: if levels_upper is not None and len(levels_upper) == 3:
...@@ -190,40 +195,40 @@ def check_unbound_answers(params: Mapping, section: UnboundSection) -> CheckResu ...@@ -190,40 +195,40 @@ def check_unbound_answers(params: Mapping, section: UnboundSection) -> CheckResu
register.check_plugin( register.check_plugin(
name="unbound_answers", name='unbound_answers',
service_name="Unbound Answers", service_name='Unbound Answers',
sections=["unbound"], sections=['unbound'],
discovery_function=discover_unbound_answers, discovery_function=discover_unbound_answers,
check_function=check_unbound_answers, check_function=check_unbound_answers,
check_default_parameters={ check_default_parameters={
'levels_upper_NOERROR': (101,101), # 'levels_upper_NOERROR': (101, 101),
'levels_upper_SERVFAIL': (10, 100), # 'levels_upper_SERVFAIL': (10, 100),
'levels_upper_REFUSED': (10, 100), # 'levels_upper_REFUSED': (10, 100),
}, },
check_ruleset_name="unbound_answers", check_ruleset_name='unbound_answers',
) )
def discover_unbound_unwanted_replies(section: UnboundSection) -> DiscoveryResult: def discover_unbound_unwanted_replies(section: UnboundSection) -> DiscoveryResult:
if 'time.now' in section and 'unwanted.replies' in section: if 'unwanted.replies' in section:
yield Service() yield Service()
def check_unbound_unwanted_replies(section: UnboundSection) -> CheckResult: def check_unbound_unwanted_replies(params, section: UnboundSection) -> CheckResult:
if 'time.now' not in section or 'unwanted.replies' not in section: if 'unwanted.replies' not in section:
return return
rate = get_rate( rate = get_rate(
get_value_store(), get_value_store(),
'unbound_unwanted_replies', 'unbound_unwanted_replies',
section['time.now'], now_time(),
section['unwanted.replies'], section['unwanted.replies'],
raise_overflow=True, raise_overflow=True,
) )
yield from check_levels( yield from check_levels(
value=rate, value=rate,
levels_upper=(10, 100), levels_upper=params.get('unwanted_replies'),
metric_name='unbound_unwanted_replies', metric_name='unbound_unwanted_replies',
render_func=render_qps, render_func=render_qps,
label='Unwanted Replies', label='Unwanted Replies',
...@@ -231,9 +236,11 @@ def check_unbound_unwanted_replies(section: UnboundSection) -> CheckResult: ...@@ -231,9 +236,11 @@ def check_unbound_unwanted_replies(section: UnboundSection) -> CheckResult:
register.check_plugin( register.check_plugin(
name="unbound_unwanted_replies", name='unbound_unwanted_replies',
service_name="Unbound Unwanted Replies", service_name='Unbound Unwanted Replies',
sections=["unbound"], sections=['unbound'],
discovery_function=discover_unbound_unwanted_replies, discovery_function=discover_unbound_unwanted_replies,
check_function=check_unbound_unwanted_replies, check_function=check_unbound_unwanted_replies,
check_default_parameters={},
check_ruleset_name='unbound_replies',
) )
...@@ -132,5 +132,3 @@ register.check_plugin( ...@@ -132,5 +132,3 @@ register.check_plugin(
check_default_parameters={}, check_default_parameters={},
check_ruleset_name="unbound_status", check_ruleset_name="unbound_status",
) )
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# renamed to unbound.py (from unbound_parameters.py) # renamed to unbound.py (from unbound_parameters.py)
# moved to ~/local/lib/check_mk/gui/plugins/wato/check_parameters (from local/share/check_mk/web/plugins/wato) # moved to ~/local/lib/check_mk/gui/plugins/wato/check_parameters (from local/share/check_mk/web/plugins/wato)
# 2024-05-14: separated WATO for bakery and check in two files # 2024-05-14: separated WATO for bakery and check in two files
# 2024-05-22: added ruleset for unwanted replies
from cmk.gui.i18n import _ from cmk.gui.i18n import _
from cmk.gui.plugins.wato.utils import ( from cmk.gui.plugins.wato.utils import (
...@@ -34,7 +34,6 @@ from cmk.gui.plugins.wato.utils import ( ...@@ -34,7 +34,6 @@ from cmk.gui.plugins.wato.utils import (
rulespec_registry, rulespec_registry,
) )
from cmk.gui.valuespec import ( from cmk.gui.valuespec import (
Alternative, Alternative,
Dictionary, Dictionary,
...@@ -47,78 +46,61 @@ from cmk.gui.valuespec import ( ...@@ -47,78 +46,61 @@ from cmk.gui.valuespec import (
def _parameter_valuespec_unbound_cache(): def _parameter_valuespec_unbound_cache():
return Dictionary( return Dictionary(
title=_("Unbound: Cache"), title=_('Unbound: Cache'),
elements=[ elements=[
( ('cache_misses',
"cache_misses", Tuple(
Tuple( title='Levels on cache misses per second',
title="Levels on cache misses per second", elements=[
elements=[ Float(title='warn', ),
Float( Float(title='crit', ),
title="warn", ])),
), ('cache_hits',
Float( Tuple(
title="crit", title='Lower levels for hits in %',
), elements=[
], Percentage(title='warn', ),
), Percentage(title='crit', ),
), ])),
( ])
"cache_hits",
Tuple(
title="Lower levels for hits in %",
elements=[
Percentage(
title="warn",
),
Percentage(
title="crit",
),
],
),
),
],
)
rulespec_registry.register( rulespec_registry.register(
CheckParameterRulespecWithoutItem( CheckParameterRulespecWithoutItem(
check_group_name="unbound_cache", check_group_name='unbound_cache',
group=RulespecGroupCheckParametersApplications, group=RulespecGroupCheckParametersApplications,
match_type="dict", match_type='dict',
parameter_valuespec=_parameter_valuespec_unbound_cache, parameter_valuespec=_parameter_valuespec_unbound_cache,
title=lambda: _("Unbound Cache"), title=lambda: _('Unbound Cache'),
) )
) )
def _parameter_valuespec_unbound_answers(): def _parameter_valuespec_unbound_answers():
return Dictionary( return Dictionary(
title=_('Unbound answers'),
elements=[ elements=[
( (f'levels_upper_{answer}',
f"levels_upper_{answer}", Alternative(
Alternative( title=f'Upper levels for {answer} answers',
title=f'Upper levels for {answer} answers', show_alternative_title=True,
show_alternative_title=True, elements=[
elements=[ Tuple(
Tuple( elements=[
elements=[ Float(title=_('Warning at'), unit=_('qps')),
Float(title=_("Warning at"), unit=_("qps")), Float(title=_('Critical at'), unit=_('qps')),
Float(title=_("Critical at"), unit=_("qps")), ],
], title=_('Upper levels in qps'),
title=f'Upper levels in qps', ),
), Tuple(
Tuple( elements=[
elements=[ Percentage(title=_('Warning at'), unit=_('%')),
Percentage(title=_("Warning at"), unit=_("%")), Percentage(title=_('Critical at'), unit=_('%')),
Percentage(title=_("Critical at"), unit=_("%")), FixedValue(value='%', totext=''), # needed to decide between both variants
FixedValue(value="%", totext=""), # need to decide between both variants ],
], title=_('Upper levels in %'),
title=f'Upper levels in %', ),
), ]))
]
)
)
for answer in ( for answer in (
'NOERROR', 'NOERROR',
'FORMERR', 'FORMERR',
...@@ -134,10 +116,35 @@ def _parameter_valuespec_unbound_answers(): ...@@ -134,10 +116,35 @@ def _parameter_valuespec_unbound_answers():
rulespec_registry.register( rulespec_registry.register(
CheckParameterRulespecWithoutItem( CheckParameterRulespecWithoutItem(
check_group_name="unbound_answers", check_group_name='unbound_answers',
group=RulespecGroupCheckParametersApplications, group=RulespecGroupCheckParametersApplications,
match_type="dict", match_type='dict',
parameter_valuespec=_parameter_valuespec_unbound_answers, parameter_valuespec=_parameter_valuespec_unbound_answers,
title=lambda: _("Unbound Answers"), title=lambda: _('Unbound Answers'),
)
)
def _parameter_valuespec_unbound_replies():
return Dictionary(
title=_('Unbound: Replies'),
elements=[
('unwanted_replies',
Tuple(
title='Levels on unwanted replies per second',
elements=[
Float(title='warn', ),
Float(title='crit', ),
])),
])
rulespec_registry.register(
CheckParameterRulespecWithoutItem(
check_group_name='unbound_replies',
group=RulespecGroupCheckParametersApplications,
match_type='dict',
parameter_valuespec=_parameter_valuespec_unbound_replies,
title=lambda: _('Unbound Replies'),
) )
) )
{'author': 'Jan-Philipp Litza <jpl@plutex.de>', {'author': 'Th.L. (thl-cmk[at]outlook[dot]com)',
'description': 'Plugin to gather statistics from unbound caching DNS resolver ' 'description': 'Plugin to gather statistics from unbound caching DNS resolver '
'via agent plugin. It monitors answer types, cache hit ratio ' 'via agent plugin. It monitors answer types, cache hit ratio '
'and miss rate as well as unwanted reply rate.\n' 'and miss rate as well as unwanted reply rate.\n'
'\n' '\n'
'needs in server config:\n' 'needs in server config:\n'
' server:\n' ' server:\n'
' extended-statistics: yes\n', ' extended-statistics: yes\n'
'download_url': 'https://github.com/PLUTEX/checkmk-unbound/', '\n'
'Acnowlegement\n'
'This plugin is based on the work of Jan-Philipp Litza '
'(PLUTEX) jpl[at]plutex[dor]de.\n'
'See: https://exchange.checkmk.com/p/unbound for more '
'details.\n',
'download_url': 'https://thl-cmk.hopto.org',
'files': {'agent_based': ['unbound.py', 'unbound_status.py'], 'files': {'agent_based': ['unbound.py', 'unbound_status.py'],
'agents': ['plugins/unbound'], 'agents': ['plugins/unbound'],
'gui': ['metrics/unbound.py', 'gui': ['metrics/unbound.py',
...@@ -15,7 +21,7 @@ ...@@ -15,7 +21,7 @@
'lib': ['python3/cmk/base/cee/plugins/bakery/unbound.py']}, 'lib': ['python3/cmk/base/cee/plugins/bakery/unbound.py']},
'name': 'unbound', 'name': 'unbound',
'title': 'Unbound', 'title': 'Unbound',
'version': '1.2.3-20240521', 'version': '1.2.4-20240522',
'version.min_required': '2.2.0b1', 'version.min_required': '2.2.0b1',
'version.packaged': '2.2.0p24', 'version.packaged': '2.2.0p24',
'version.usable_until': None} 'version.usable_until': None}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment