SNMP checks not found with normal discovery

CMK version: 2.1.0p20
OS version: ubuntu server 22.04

Error message:
I’ve had a few self made SNMP checks running here in the old version 1.6 . Ive been rewriting them for the new version. I think I’m doing something wrong. When I do a discovery on the host in the GUE I get :

Vanished services - monitored, but no longer exist (1) 
Check plugin received no monitoring data

When I run from the command line a detect for the plugin in gets added to the host.
cmk --detect-plugins=hwg_sms_signal -vI HWg-SMS-GW3

Discovering services and host labels on: HWg-SMS-GW3
HWg-SMS-GW3:
+ FETCHING DATA
[SNMPFetcher] Execute data source
[PiggybackFetcher] Execute data source
No piggyback files for 'HWg-SMS-GW3'. Skip processing.
No piggyback files for '192.168.5.230'. Skip processing.
+ ANALYSE DISCOVERED HOST LABELS
SUCCESS - Found no new host labels
+ ANALYSE DISCOVERED SERVICES
+ EXECUTING DISCOVERY PLUGINS (1)
  1 hwg_sms_signal
SUCCESS - Found 1 services

Now the servers starts to monitor this check, only Im missing something to get it running in the GUE for the discovery. can anyone give me some pointers what im doing wrong?

**Output
Here is the code of my check:
/opt/omd/sites/DGL/local/lib/python3/cmk/base/plugins/agent_based/hwg_sms_signal.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2023 Bjorn Stout De Graaf Logistics
# This file is a custom check foor SMS Gateway from www.hw-group.com
# Product info page https://www.hw-group.com/accessory/sms-gw3
from .agent_based_api.v1 import *
import pprint


def discover_hwg_sms_signal(section):
    for opertator, _strength, _quality in section:
        yield Service(item=opertator)


def check_signal(item, params ,section):
    warn,crit = params["levels_lower"]
    for opertator, strength, quality in section:
        if opertator == item:
            strength = int(strength)
            quality = int(quality)
            if quality <= crit:
                s = State.CRIT
                m = "Signaal Quality very low "+str(quality) + "% Signaal Strength " + str(strength) + "db"
            elif quality <= warn:
                s = State.WARN
                m = "Signaal Quality low "+str(quality) + "% Signaal Strength " + str(strength) + "db"
            else:
                s = State.OK
                m = "Signaal Quality OK "+str(quality) + "% Signaal Strength " + str(strength) + "db"
            yield Metric("signaalquality", quality, levels=(warn,crit), boundaries=(0,100))
            yield Metric("signaalstrength", strength, levels=(-85,-95), boundaries=(0,-100))
            yield Result(state=s, summary=m)
            return

def parse_hwg_sms_signal(string_table):
    return string_table

register.snmp_section(
    name = "hwg_sms_signal",
    detect = all_of(
        startswith(".1.3.6.1.4.1.21796", "hwgroup device"),
        contains(".1.3.6.1.4.1.21796" ,".4.10."),  # System ObjectID
        ),
    parse_function=parse_hwg_sms_signal,
    fetch = SNMPTree(
        base = '.1.3.6.1.4.1.21796.4.10.1',
        oids = [
            #1.0', #Modem IMEI
            #2.0', #Modem Network Registration
            '3.0', #Operator Name
            '4.0', #Signal Strength
            '5.0', #Signal Quality
        ],
    ),
)

register.check_plugin(
    name='hwg_sms_signal',
    service_name='%s',
    discovery_function=discover_hwg_sms_signal,
    check_default_parameters={"levels_lower": (30.0, 10.0)},
    check_ruleset_name="generic_number",
    check_function=check_signal,
)

                              

This line enforces the detection of the plugin. The detect function inside your plugin is not used here.
What happens if you do a “cmk --debug -vvII HWg-SMS-GW3”?

Looks like other checks from this brand are being hit if i see it correcly could that prevent my check from matching?

SNMP scan found hr_mem hwg_humidity hwg_temp snmp_info snmp_os snmp_uptime

Here the output it gives:
output.txt (130.7 KB)

If i have look at this detect function then it will not work.

i would try here with your device output the following

detect = startswith(
        ".1.3.6.1.2.1.1.2.0",
        ".1.3.6.1.4.1.21796.4.10",
    ),

Can you try this modification?

1 Like

Yes :smiley: thats it thanks!

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.