Sample SNMP plugin

Hello, everyone,

I am relatively new to Check_MK and would now like to query a device via SNMP.

The device is a very simple thermometer.

Unfortunately, the description is only partially correct.

Is there a “pattern” somewhere that you can use?

I tried to look at a normal AgentPlugin:

register.snmp_section(
     name="snmp_iptermo",
     detect = startswith(".1.3.6.1.2.1.1.1.0", "TH"),
     fetch = SNMPTree(
         base = '.1.3.6.1.4.1.3444.1.14.1.2.1.10',
         oids = [
             '1', #temperature
             '2', #Humidity
             '3', #Dew point
         ],
     ),
     check_function=check_snmp_iptermo,
     discovery_function=discover_snmp_iptermo,
)

Unfortunately there is an error message

TypeError: snmp_section() got an unexpected keyword argument 'check_function'

Does anyone have a pattern for a very simple SNMP query?

Many Thanks

The check_function is not part of the rister.snmp_section part, but goes to the register.check_plugin part. Here a basic example from on of my last plugins.

register.snmp_section(
    name='juniper_led',
    parse_function=parse_juniper_led,
    supersedes=['juniper_alarm'],
    fetch=
    SNMPTree(
        base='.1.3.6.1.4.1.2636.3.1.10.1',  # JUNIPER-MIB::jnxLEDEntry
        oids=[
            '7',  # jnxLEDDescr
            '9',  # jnxLEDStateOrdered
        ]
    ),
    detect=startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.2636.1.1.1'),
)

register.check_plugin(
    name='juniper_led',
    service_name='Alarm LED %s',
    discovery_function=discovery_juniper_led,
    check_function=check_juniper_led,
    check_ruleset_name='juniper_led',
    check_default_parameters={
    }
)

1 Like