Service discovered with UNKNOWN status

I have made a small check plugin for checking the status of a remote device using SNMP. I have added debugging to check that I am getting data, it is working well, except that the Service always shows up as a vanished service with status “UNKN”.

The following file I “install” in cmk using the command install -m755 /tmp/ ~/local/lib/python3/cmk/base/plugins/agent_based/ without any issue. The name device_info is just a placeholder name, I use a unique name in reality.

from .agent_based_api.v1 import (
    register, SNMPTree, contains, Service, Result, State
from cmk.utils import debug
from pprint import pprint

def parse_device_info(string_table):
    if debug.enabled():

    return string_table[0]

    detect=contains(".", "."),

def discovery_device_info(section):
    if debug.enabled():
    yield Service()

def check_device_info(section):
    if debug.enabled():
    yield Result(state=State.OK, summary="Device is of type %s" % section[0])

    service_name="Device info",

To test out this plugin I execute:

>>> cmk --debug --detect-plugins device_info --II <HOSTNAME>
[['v1', '12345']]

This makes this service show up in CMK UI as a vanished service with Status UNKN. The clue from the debug is that the printout in ‘check_function’ is never printed, which must mean the function is never called. Now the issue is that I cannot understand why it is not called, and was hoping for a simple explanation of what I am doing wrong.

Many thanks!

I am still in desperate need for any idea or suggestion on what I am doing wrong. Is there additional information needed in order to determine what is the cause?

When you call “cmk” with “-I” only the discovery function is called.
I don’t currently see an obvious error in your code, but you can check with
"cmk --debug -v " after you discoverd your service if your print statements show up and maybe this helps?

Thank you, when I execute cmk --debug -v <HOSTNAME> there are no print statements. If I also add --detect-plugins device_info the result is the same.

>> cmk --debug -v <HOSTNAME>
[SNMPFETCHER] Execute data source
[PiggybackFetcher] Execute data source
No piggyback files for <HOSTNAME>
No piggyback files for <HOSTIP>
Received no piggyback data
[snmp] Success, execution time 0.0 sec | .....

Can you share the full original code (or replace a little less?) I’m not sure if maybe the changes in the OIDs, Variable names etc hid the problem…

also, maybe add a second “-v” to see if the snmp output yields anything.
An execution time of 0.0 seems like your device is not even contacted.

The only things I have changed are the oids. It could happen that the device was not reachable earlier. Now it is showing SNMP results, amongst them, the oids I have specified, and a lot of other oids. And the service is showing up with an OK status. It might have been a timeout issue all along, which there was not really any indication of in the calls. I changed the timeout for snmp calls to 10 seconds but fewer retries, and now it appears to be running smoothly…