Parse_function is never called

You defined the check as

check_info["ttn_gateway.lastseen"]

The dot indicates that this is a sub-check of the main check ttn_gateway. For subchecks, there can only be one parse function: that of the main check. You cannot have separate parse functions for the main check and subchecks.

Btw, the check function can be simplified to

def check_ttn_gateway_lastseen(item, params, parsed):
    if not parsed or item not in parsed:
        return

    if isinstance(params, tuple):
        warn, crit = params
    else:
        warn, crit = params['levels']
        
    value = saveint(parsed[item])
    perfdata = [('last seen', value, warn, crit)]
    if value < warn:
        yield 0, "%d s since last seen" % value, perfdata
    elif value < crit:
        yield 1, "%d s since last seen" % value, perfdata
    else:
        yield 2, "%d s since last seen" % value, perfdata

No need for the for loop because item is already the key to the parsed structure.

3 Likes