Discussion:
[Check_mk (english)] maximum recursion depth exceeded
chuck
2018-11-26 18:58:16 UTC
Permalink
I keep getting this maximum recursion depth exceeded. From what I can
see is it's getting stuck in a loop when parsing out my SNMP Request.
The OID only returns 1 value, but it looks like the script just keeps
looping over it and i'm not sure what i'm doing different than the other
scripts in the checks folder. I'm relatively new to both python and
CheckMK, so if I did something stupid, don't judge me too harsh lol. I'd
really appreciate some help on this though!


Also - this is my first time using a mailing list so if i'm using it
incorrect, I apologize.


Script below

----------------------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/python

import re

def inventory_raisecom_y1731_delay_avg(parsed):
    print(parsed)
    return inventory_raisecom_y1731_delay_avg(parsed)

def check_raisecom_y1731_delay_avg(item, params, parsed):
    return check_raisecom_y1731_delay_avg(item, params, parsed)

def parse_raisecom_y1731_delay_avg(info):
    print(re.findall(r'\b\d+\b', str(info)))
    parsed = re.findall(r'\b\d+\b', str(info))
    return parsed

check_info["y1731_delay_avg"] = {
    'check_function'            : check_raisecom_y1731_delay_avg,
    'inventory_function'        : inventory_raisecom_y1731_delay_avg,
    'parse_function'            : parse_raisecom_y1731_delay_avg,
    'snmp_info'                 : (".1.3.6.1.4.1.8886.6.1.36.3.1.1.6",
["1"]),
}

----------------------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------------------------

Output when running these commands below

cmk --checks=raisecom_y1731_delay_min -I 10.104.1.1

cmk -vII 10.104.1.1


['2788']

['2788']

['2788']

['2788']

['2788']

['2788']

['2788']

WARNING: Exception in discovery function of check type
'y1731_delay_avg': maximum recursion depth exceeded
  3 if64
  1 snmp_info
  1 snmp_uptime
SUCCESS - Found 5 services
--
Chuck Greve
Level I Support Technician
STARTOUCH INC
Ph.360.543.5679 Ext. 118
www.startouch.com
***@startouch.com
Washington State's Largest Microwave Internet Provider
Greg Wildman
2018-11-27 05:39:23 UTC
Permalink
Post by chuck
I keep getting this maximum recursion depth exceeded. From what I can
see is it's getting stuck in a loop when parsing out my SNMP Request.
The OID only returns 1 value, but it looks like the script just keeps
looping over it and i'm not sure what i'm doing different than the
other scripts in the checks folder. I'm relatively new to both python
and CheckMK, so if I did something stupid, don't judge me too harsh
lol. I'd really appreciate some help on this though!
<snip>
Post by chuck
--------------------------
#!/usr/bin/python
import re
print(parsed)
return inventory_raisecom_y1731_delay_avg(parsed)
return check_raisecom_y1731_delay_avg(item, params, parsed)
print(re.findall(r'\b\d+\b', str(info)))
parsed = re.findall(r'\b\d+\b', str(info))
return parsed
check_info["y1731_delay_avg"] = {
'check_function' : check_raisecom_y1731_delay_avg,
'inventory_function' : inventory_raisecom_y1731_delay_avg,
'parse_function' : parse_raisecom_y1731_delay_avg,
(".1.3.6.1.4.1.8886.6.1.36.3.1.1.6", ["1"]),
}
At first glance I see that the inventory function is calling itself, a
loop ensues. The same for the check function.

--
Greg
Arno Wijnhoven
2018-11-27 08:34:32 UTC
Permalink
Greg has a point. Best use a variable.
You cannot use the function name as return variable (as that will call the function again).

I've got a custom script that monitors Dell RAID BBUs. Perhaps something like this is included in recent versions, but back in the day a script like this didn't exist.
In the inventory function I'm creating a new variable which I return. The variable is filled in a for-loop using append.

Another thing. For the inventory function you don't want to return the actual value.
You'd want to return the name of the item you are monitoring. The value itself will be returned in the check.

Example (mind you - this is for more than one result but the idea is the same):

def inventory_dell_cache_battery(info):
battery_inventory = []
for batteryState, batteryControllerName, batteryControllerNumber in info:
battery_inventory.append(( batteryControllerNumber, None ))
return battery_inventory # <------------ this returns a list of controller numbers to be matched in the check function, no actual values here!

In my check_info I have a line 'service_description':

"service_description" : "Controller %s", # <-------------- %s will be replaced by 'battery_inventory' from the inventory function

This results in 'Controller 1', 'Controller 2' etc.

The check function will get the actual value. The first thing in the check function will be matching the right controller.
This is why you see stuff like ' if batteryControllerNumber == item:' in each check function, where 'item' is a stored value from the inventory function.

I started with Python when starting with Check_MK and I love both.
I included one of my own scripts as this one is really short and comprehensible (at least, for me :D). Perhaps it's of any use to you as an example.

Hope this helps.

Arno Wijnhoven

-----Original Message-----
From: checkmk-en [mailto:checkmk-en-***@lists.mathias-kettner.de] On Behalf Of Greg Wildman
Sent: dinsdag 27 november 2018 06:39
To: chuck <***@startouch.com>; checkmk-***@lists.mathias-kettner.de
Subject: Re: [Check_mk (english)] maximum recursion depth exceeded
Post by chuck
I keep getting this maximum recursion depth exceeded. From what I can
see is it's getting stuck in a loop when parsing out my SNMP Request.
The OID only returns 1 value, but it looks like the script just keeps
looping over it and i'm not sure what i'm doing different than the
other scripts in the checks folder. I'm relatively new to both python
and CheckMK, so if I did something stupid, don't judge me too harsh
lol. I'd really appreciate some help on this though!
<snip>
Post by chuck
--------------------------
#!/usr/bin/python
import re
print(parsed)
return inventory_raisecom_y1731_delay_avg(parsed)
return check_raisecom_y1731_delay_avg(item, params, parsed)
print(re.findall(r'\b\d+\b', str(info)))
parsed = re.findall(r'\b\d+\b', str(info))
return parsed
check_info["y1731_delay_avg"] = {
'check_function' : check_raisecom_y1731_delay_avg,
'inventory_function' : inventory_raisecom_y1731_delay_avg,
'parse_function' : parse_raisecom_y1731_delay_avg,
(".1.3.6.1.4.1.8886.6.1.36.3.1.1.6", ["1"]), }
At first glance I see that the inventory function is calling itself, a loop ensues. The same for the check function.
--
Greg
Loading...