SNMP Custom Plugins

Hello,
i wrote a custom plugins to detect disk status from asustor nas. I get data only if i start via command line.
I have to start it once via
cmk --debug -nvI --detect-plugins asustor_disks NAS

where i get:
SUCCESS - Found 3 services, no new host labels

then i give:
cmk --debug -nv --detect-plugins asustor_disks NAS

and i get:

  • PARSE FETCHER RESULTS
    Received no piggyback data
    Asustor_Disk 1 WDC WD40EFRX-68N32N0 is Healthy.
    Asustor_Disk 2 WDC WD40EFRX-68N32N0 is Healthy.
    Asustor_Disk 3 WDC WD40EFRX-68WT0N0 is Healthy.

after this, if i perform a full scan in WATO i get no response.

anyone could help me on this?

the script is really basic:
#!/usr/bin/env python3

-- coding: utf-8 --

def check_asustor_disks(item, _no_params, info):
for disk_id, disk_bay, disk_model, disk_type, disk_status, disk_temperature in info[0]:
if disk_id == item:
if disk_status == “Healthy”:
state = 0
elif disk_status == “Normal”:
state = 0
elif disk_status in [ “Risky”, “Dangerous”, “Bad” ]:
state = 2
# Any state we don’t know.
else:
state = 3
msg = “%s is %s.” % (disk_model, disk_status)

return (state, "%s " % (msg))

        yield state, "%s " % (msg)

return (3, "UNKW - Error")

def inventory_asustor_disks(info):
inventory = []
for disk_id, disk_bay, disk_model, disk_type, disk_status, disk_temperature in info[0]:
yield disk_id, None

check_info[“asustor_disks”] = {
“inventory_function”: inventory_asustor_disks,
“check_function”: check_asustor_disks,
“service_description”: “Asustor_Disk %s”,
“snmp_scan_function”: lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.44738.4"),
“snmp_info”: [(
“.1.3.6.1.4.1.44738.4.1.1”,
[
“1”, # disk index
“2”, # disk bay
“3”, # disk model
“4”, # disk type
“5”, # disk status
“6”, # disk temperature
])
]
}

Please can you post the code inside a preformatted text block?
For your discovery problem it is possible that the “snmp_scan_function” does not find anything.

Thanks for your answer.

below the output of snmpwalk on the oid i used inside the script and below the code preformatted

how can i debug the snmp_scan_function?

snmpwalk -On -v2c -c public 192.168.100.250 .1.3.6.1.4.1.44738.4
.1.3.6.1.4.1.44738.4.1.1.1.1 = INTEGER: 1
.1.3.6.1.4.1.44738.4.1.1.1.2 = INTEGER: 2
.1.3.6.1.4.1.44738.4.1.1.1.3 = INTEGER: 3
.1.3.6.1.4.1.44738.4.1.1.2.1 = STRING: "Disk1"
.1.3.6.1.4.1.44738.4.1.1.2.2 = STRING: "Disk2"
.1.3.6.1.4.1.44738.4.1.1.2.3 = STRING: "Disk3"
.1.3.6.1.4.1.44738.4.1.1.3.1 = STRING: "WDC WD40EFRX-68N32N0"
.1.3.6.1.4.1.44738.4.1.1.3.2 = STRING: "WDC WD40EFRX-68N32N0"
.1.3.6.1.4.1.44738.4.1.1.3.3 = STRING: "WDC WD40EFRX-68WT0N0"
.1.3.6.1.4.1.44738.4.1.1.4.1 = STRING: "SATA"
.1.3.6.1.4.1.44738.4.1.1.4.2 = STRING: "SATA"
.1.3.6.1.4.1.44738.4.1.1.4.3 = STRING: "SATA"
.1.3.6.1.4.1.44738.4.1.1.5.1 = STRING: "Healthy"
.1.3.6.1.4.1.44738.4.1.1.5.2 = STRING: "Healthy"
.1.3.6.1.4.1.44738.4.1.1.5.3 = STRING: "Healthy"
.1.3.6.1.4.1.44738.4.1.1.6.1 = INTEGER: 44
.1.3.6.1.4.1.44738.4.1.1.6.2 = INTEGER: 43
.1.3.6.1.4.1.44738.4.1.1.6.3 = INTEGER: 42

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

def check_asustor_disks(item, _no_params, info):
    for disk_id, disk_bay, disk_model, disk_type, disk_status, disk_temperature in info[0]:
        if disk_id == item:
            if disk_status == "Healthy":
                state = 0
            elif disk_status == "Normal":
                state = 0
            elif disk_status in [ "Risky", "Dangerous", "Bad" ]:
                state = 2
            # Any state we don't know.
            else:
                state = 3
            msg = "%s is %s." % (disk_model, disk_status)
#           return (state, "%s " % (msg))
            yield state, "%s " % (msg)

    return (3, "UNKW - Problemi nel recupero dei dati sui dischi")

def inventory_asustor_disks(info):
    inventory = []
    for disk_id, disk_bay, disk_model, disk_type, disk_status, disk_temperature in info[0]:
         yield disk_id, None
 
check_info["asustor_disks"] = {
    "inventory_function": inventory_asustor_disks,
    "check_function": check_asustor_disks,
    "service_description": "Asustor_Disk %s",
    "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.44738.4"),
    "snmp_info": [(
        ".1.3.6.1.4.1.44738.4.1.1",
        [
          "1", # disk index
          "2", # disk bay
          "3", # disk model
          "4", # disk type
          "5", # disk status
          "6", # disk temperature
        ])
                 ]
}


i asked:

snmpwalk -On -v2c -c public   192.168.100.250 system
.1.3.6.1.2.1.1.1.0 = STRING: Linux AS6204T-4689 4.14.x #1 SMP Mon May 10 00:30:33 CST 2021 x86_64
**.1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.8072.3.2.10**
.1.3.6.1.2.1.1.3.0 = Timeticks: (4154551) 11:32:25.51
.1.3.6.1.2.1.1.4.0 = STRING: @@no.where
.1.3.6.1.2.1.1.5.0 = STRING: AS6204T-4689
.1.3.6.1.2.1.1.6.0 = STRING: Unknown
.1.3.6.1.2.1.1.8.0 = Timeticks: (0) 0:00:00.00

and i changed the scan function as follows:

"snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.8072.3.2.10",

but still i cannot get the plugin executed

It’s complicated :slight_smile: enterprise OID 8072 is the netsnmp OID from every Linux system.

You are right, btw this is a linux host. I confirm I get the information changing the snmp scan function

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.