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 814e2395 authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

update project

parent 1b5f00ae
No related branches found
No related tags found
No related merge requests found
[PACKAGE]: ../../raw/master/mkp/unbound-1.2.2-20240521.mkp "unbound-1.2.2-20240521.mkp"
[PACKAGE]: ../../raw/master/mkp/unbound-1.2.3-20240521.mkp "unbound-1.2.3-20240521.mkp"
# unbound
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# License: GNU General Public License v2
#
# Author: thl-cmk[at]outlook[dot]com
# URL : https://thl-cmk.hopto.org
# Date : 2024-05-21
# File : unbound_status.py
from dataclasses import dataclass
from typing import (
Any,
Mapping,
Sequence
)
from cmk.utils import debug
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
CheckResult,
DiscoveryResult,
StringTable,
)
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
Service,
check_levels,
register,
render,
Result,
State,
)
@dataclass(frozen=True)
class UnboundStatus:
version: str
verbosity: int
threads: int
modules: Sequence[str]
uptime: int
options: Sequence[str]
status: str
pid: int
@classmethod
def parse(cls, string_table: StringTable):
for line in string_table:
key, value = line[0].split(' ', 1)
key = key.rstrip(':')
match key:
case 'version':
version = str(value)
case 'verbosity':
verbosity = int(value)
case 'threads':
threads = int(value)
case 'modules':
# 3 [ subnet validator iterator ]
modules = value.split(' [ ')[-1].strip(']').strip(' ').split(' ')
case 'uptime':
# 577 seconds
uptime = int(value.split(' ')[0])
case 'options':
# reuseport control(ssl)
options = value.split(' ')
case 'unbound':
# (pid 520) is running...
pid = int(value.split(') ')[0].replace('(pid ', ''))
status = value.split(') ', -1)[-1].strip('.')
case _:
pass
try:
return cls(
version=version,
verbosity=verbosity,
threads=threads,
modules=modules,
uptime=uptime,
options=options,
pid=pid,
status=status,
)
except NameError as e:
if debug.enabled:
print(f'name error {e}')
return
def parse_unbound_status(string_table: StringTable) -> UnboundStatus | None:
return UnboundStatus.parse(string_table)
register.agent_section(
name="unbound_status",
parse_function=parse_unbound_status,
)
def discover_unbound_status(section: UnboundStatus) -> DiscoveryResult:
yield Service()
# UnboundStatus(
# version='1.13.1',
# verbosity=0,
# threads=1,
# modules=['subnet', 'validator', 'iterator'],
# uptime=1759,
# options=['reuseport', 'control(ssl)'],
# status='(pid 520) is running',
# pid=520
# )
def check_unbound_status(params: Mapping[str, Any], section: UnboundStatus, ) -> CheckResult:
yield Result(state=State.OK, summary=f'Status: {section.status}')
yield from check_levels(
value=section.uptime,
label='Uptime',
metric_name='uptime',
render_func=render.timespan
)
yield Result(state=State.OK, summary=f'Version: {section.version}')
register.check_plugin(
name="unbound_status",
service_name="Unbound",
discovery_function=discover_unbound_status,
check_function=check_unbound_status,
check_default_parameters={},
check_ruleset_name="unbound_status",
)
......@@ -13,4 +13,7 @@ if [ -f "$(which unbound-control)" ]; then
echo '<<<unbound:sep(61)>>>'
unbound-control stats_noreset -c $UNBOUND_CFG
echo '<<<>>>'
echo '<<<unbound_status:sep(0)>>>'
unbound-control status -c $UNBOUND_CFG
echo '<<<>>>'
fi
......@@ -7,7 +7,7 @@
' server:\n'
' extended-statistics: yes\n',
'download_url': 'https://github.com/PLUTEX/checkmk-unbound/',
'files': {'agent_based': ['unbound.py'],
'files': {'agent_based': ['unbound.py', 'unbound_status.py'],
'agents': ['plugins/unbound'],
'gui': ['metrics/unbound.py',
'wato/check_parameters/unbound.py',
......@@ -15,7 +15,7 @@
'lib': ['python3/cmk/base/cee/plugins/bakery/unbound.py']},
'name': 'unbound',
'title': 'Unbound',
'version': '1.2.2-20240521',
'version': '1.2.3-20240521',
'version.min_required': '2.2.0b1',
'version.packaged': '2.2.0p24',
'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