Is it possible to use metrics in a SNMP-based check?

Hi,

is it possible to use metrics (like for agent-based checks) for the returns in SNMP-based checks?

I would like to plot the transmitted values in WATO and easily change the warn and crit parameters.
All I could find, was this german article. But that solution seems rather tricky and unstable.

Thanks for your help!

of course it is possible

the best way is you analyze a check with is simelar the check you want to creat

and adapted the code perhaps you just to change the OID`s

Hi,

thanks for your advice, but from my perspective the structure of the agent-based code contradicts the snmp-based one. For example, in the SNMP check the service name is defined in the inventory function.

The agent-based check from the documentation sets the service name in the return string:
0 myservice count1=42|count2=21;23;27|count3=73 OK - This is my custom output

Could you show me a return line from a SNMP-based check, that uses metrics?

Thanks

I believe you should take @BH2005 advice.

On your CMK server list all the SNMP checks making “cmk -L | grep snmp” to check all the SNMP checks available,
I advise you to take a look at ups_power check to get started and see how to start making your own since it’s very simple to understand the logic behind developing SNMP checks.

Also give a look at the official documentation about Writing SNMP based checks

Any doubt feel free to share.

What you’re showing here is the output from a simple local check, not from the agent.
This is part of the agent output, prefixed by “<<<local>>>” - together with all the other checks from the agent, each in their own section with a corresponding “<<<…>>>” heading.

Native agent checks and SNMP checks are a bit more complicated and require python code on the monitoring server.
See https://checkmk.com/cms_devel_check_plugins.html for more information.
Unfortunately, “This article is not finished yet”. So I guess you are left with looking at existing checks.

Thanks for your fast response. Perhaps I am not making myself clear.

The ups_power snmp check only provides a simple check with a return like:

        if power <= crit:
            return (2, "CRIT" + infotext, perfdata)
        elif power <= warn:
            return (1, "WARN" + infotext, perfdata)
        else:
            return (0, "OK" + infotext, perfdata)

Just plain text without any WATO intelligence whatsoever.

I already wrote SNMP checks like this. And I guess, I am able to follow the logic of the inventory and the check function. But I want a more complex return that looks like this in WATO:

My non-SNMP code for that looks like this:

    print("P " + target + " TX=" + tx + ";" + tx_warn_lower + ":" + tx_warn_upper + ";" + tx_crit_lower + ":" + tx_crit_upper +
        "|RX=" + rx + ";" + rx_warn_lower + ":" + rx_warn_upper + ";" + rx_crit_lower + ":" + rx_crit_upper)

The OK, WARN, CRIT alerts are generated dynamically based on the TX and RX variable. And WATO automatically generates a wonderful plot.

P.S.: I thought that this was an agent check, because I had to set the data source from the host in WATO to “Normal Checkmk agent”, activate an agent and deploy my python script in the right folder to make it work:
PNG