Configuring SNMPv3 for HP Printer

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.

I changed the following things

/omd/sites/[site]/lib/python3/cmk/fetchers/_snmpscan.py

_prefetch_description_object

get_single_oid(
oid,
single_oid_cache=snmp_cache.single_oid_cache(),
backend=backend,
)

to

get_single_oid(
oid,
single_oid_cache=snmp_cache.single_oid_cache(),
section_name=SectionName(“sys_descr”),
backend=backend,
)

/omd/sites/[site]/lib/python3/cmk/base/automations/check_mk.py

_execute_snmp

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),
)

/omd/sites/[site]/lib/python3/cmk/gui/wato/_check_mk_configuration.py

_valuespec_snmpv3_contexts

choices=lambda: [(None, _(“All SNMP sections”))] + get_snmp_section_names()

to

choices=lambda: [(None, _(“All SNMP sections”))] + [(“sys_descr”, _(“System Description OID”))] + get_snmp_section_names()

/omd/sites/[site]/lib/python3/cmk/snmplib/_typedefs.py

snmpv3_contexts_of

inserted additional variable

var_sysoid_section=SectionName(“sys_descr”)

and changed

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.

In order for the HP printers to monitor reliably with snmpv3, I had to create the rules from this answer
https://forum.checkmk.com/t/bug-snmp-v3-with-hp-printer-any-update-or-even-better-a-solution/20372/12