I configured everything as in these posts and got it partly to working. Problem is that it seems even in CheckMk 2.3 the discovery still does not use the specified SNMP context for the detection of the system description.
Without the system descripten checkmk wont detect the printer snmp sections, wich is the information we want to monitor.
Maybe I read the the code at some point wrong but the snmpv3 context defined in the rule should be used even for the system description OID in the service discovery scan.
Anyone got an idea how I get it to work, or do I really have to create custom snmp check for the HP printer?
I would say - no - the context is only used if a section name is provided. The call for system description OID is without any section name and so the context rules defined will not match.
This is a really old bug - something for @martin.hirschvogel
You are absolutely right. I am pretty new to python and did not know that python considers None as a boolean false. Now the behaviour makes sense.
I already have some Ideas how to make it work, but that would require some minor changes to the context rule, the _snmpscan.py and snmplib/_typedef.py.
But it all is based on the assumption that the SectionName passed to “get_single_oid” in can be just a string.
Yeah, I guess I am the right people. Unfortunately I’m the right people for a lot of stuff .
This bug is quite old indeed – I think it was already quite old when I joined the “Mathias Kettner GmbH” back in the days. But was never really aware of it.
I’ve added in internal ticket for this (link for colleagues: CMK-19986).
But don’t get your hopes up…
If it helps to fix the problem in an official build. I have managed to adjust everything so that a SNMPv3 context can also be stored for the system description OID and it works. However, there are probably still optimization and improvement possibilities.
data = get_snmp_table(
section_name=None,
tree=BackendSNMPTree(
base=“.1.3.6.1.2.1.1”,
oids=[BackendOIDSpec(c, “string”, False) for c in “1456”],
),
walk_cache={},
backend=make_snmp_backend(snmp_config, log.logger),
)
to
data = get_snmp_table(
section_name=SectionName(“sys_descr”),
tree=BackendSNMPTree(
base=“.1.3.6.1.2.1.1”,
oids=[BackendOIDSpec(c, “string”, False) for c in “1456”],
),
walk_cache={},
backend=make_snmp_backend(snmp_config, log.logger),
)
if ctx.section is None or ctx.section == section_name:
to
if (ctx.section is None and section_name != var_sysoid_section) or (ctx.section is not None and ctx.section == section_name):
I tried to change the condition in snmpv3_contexts_of in a way, that will not break the old behavior of the context rules that use “All SNMP Sections”. This way a context for the system description oid will only be used if a rule for that section is present like this:
These changes have no effect on SNMPv1 or SNMPv2 since they dont use context. And for SNMP3 it only adds the option to define a context for the system description but the rest should still work the same way. At least on my system i can not find any problems with the systems that use snmpv3 without a context.