Item in SNMP checks are always empty after upgrade from 1.6 to 2.0.p17

After upgrading from 1.6 to 2.0.0p17 I found multiple selfmade checks no longer working.
The problem is that in 1.6 the check function is called once for every service it is responsible for having set the item argument as the service that should be checked.
In 2.0 this item parameter is ‘None’ ending in the check function no longer working.
I know that I could convert the whole check to the new api, which is quite a lot of work.
But normally CheckMK 2.0 should be able to work with old plugins and as the plugins having the problems are from a lot of different sources this is not a problem of a specific one (which is the reason I do not include any code example here).
Does anyone know if there is anything I can do to solve this issue without converting the plugin to the new api? Or is there any documentation explaining this behavior? Otherwise I consider this behavior to be a bug.

Hello!
Are there any updates on this issue?
Have you solved the problem or is it a bug and you reported it?

I’m experiencing the same problem here and could not update the check without bigger effort.

Regards
Sven

I can only say, i have no problems with old style checks and items with 2.0.
Here a very simple SNMP check example with items whats working also in 2.0

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from cmk.base.check_legacy_includes.temperature import *  # pylint: disable=wildcard-import,unused-wildcard-import
factory_settings["netgear_boxservice_temp_default_levels"] = {"levels": (50.0, 60.0)}


def inventory_netgear_boxservice_temp(info):
    for line in info:
        if float(line[2]) > 0:
            yield (line[0], {})


def check_netgear_boxservice_temp(item, params, info):
    for line in info:
        if line[0] == item:
            return check_temperature(float(line[2]), params, "netgear_boxservice_temp_%s" % item)


check_info["netgear_boxservice_temp"] = {
    "check_function": check_netgear_boxservice_temp,
    "inventory_function": inventory_netgear_boxservice_temp,
    "service_description": "Temperature %s",
    "has_perfdata": True,
    "group": "temperature",
    "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.4526.100"),
    "snmp_info": (
        ".1.3.6.1.4.1.4526.11.43.1.8.1",
        [
            OID_END,
            "4",  #Sensor Name
            "5",  #Sensor Value
        ]),
    "default_levels_variable": "netgear_boxservice_temp_default_levels"
}

Same Problem

My Solution:
Old: “service_description”: “VPN IPSec Tunnel”,
New: “service_description”: “VPN IPSec Tunnel %s”,

(And change from python2 to python3)

#!/usr/bin/env python3

def inventory_tunnel(info):
   inventory = []
   for name, state in info:
       if state == "2":
          inventory.append( (name, state) )
   return inventory


def check_tunnel(item, params, info):
        for name, state in info:
                if name == item:
                        if state == "2":
                                return (0, "OK - Tunnel is up")
                        else:
                                return (2, "CRITICAL - link is down")
        return (3, "UNKNOWN - Tunnel not found")
    
check_info["fortigate_tunnel"] = {
    "inventory_function": inventory_tunnel,
    "check_function": check_tunnel,
    "service_description": "VPN IPSec Tunnel %s",
    "snmp_scan_function": lambda oid: ".1.3.6.1.4.1.12356.101.1" in oid(".1.3.6.1.2.1.1.2.0"),
    "snmp_info": (
        ".1.3.6.1.4.1.12356.101.12.2.2.1",
        [
            3,  # fgVpnTunEntPhase2Name
            20,  # fgVpnTunEntStatus
        ]),
    "has_perfdata": False,
}

This was already in 1.6 a wrong codded check but it was working :wink:
The “new” syntax is the correct one for all checks with items.

This solved my problem.
Thanks for your help.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.