Plugin check_mk-mtr - service graphs are not rendered (Cannot calculate graph recipes)

Hi,

we are using the check_mk-mtr Plugin.
With version 1.5 we had no problems with the plugin.
After upgrading to version 2.08p.cre the service graphs are not rendered for the mtr data.
Deleting of the performance datafiles and even creation a new mtr-destination doesn‘t help.
I tested the plugin on another checkmk host and had the same issues.

The problem occurs, when there are 3 or more hops to the destination.

Instead of service Graphs we get the message

Cannot calculate graph recipes
Syntax error in expression '(‘rrd’, ‘it273’, ‘XXXXXX-01.vserver.nessus.at’, ‘Mtr to www.orf.at’, ‘hop_1_rtmax’, ‘max’, 1.0), (‘rrd’, ‘it273’, '‘XXXXXX-01-01.vserver.nessus.at’, ‘Mtr to www.orf.at’, ‘hop_1_rtmax’, ‘max’, 1.0), (‘rrd’, ‘it273’, ‘‘XXXXXX-01.vserver.nessus.at’, ‘Mtr to www.orf.at’, ‘hop_1_rtmax’, ‘max’, 1.0), (‘rrd’, ‘it273’, ‘‘XXXXXX-01.vserver.nessus.at’, ‘Mtr to www.orf.at’, ‘hop_1_rtmax’, ‘max’, 1.0), (‘rrd’, ‘it273’, ‘‘XXXXXX-01.vserver.nessus.at’, ‘Mtr to www.orf.at’, ‘hop_1_rtmax’, ‘max’, 1.0), (‘rrd’, ‘it273’, ‘XXXXXX-01.vserver.nessus.at’, ‘Mtr to www.orf.at’, ‘hop_1_rtmax’, ‘max’, 1.0), (‘rrd’, ‘it273’, XXXXXX.vserver.nessus.at’, ‘Mtr to www.orf.at’, ‘hop_1_rtmax’, ‘max’, 1.0), (‘rrd’, ‘it273’, XXXXXX.vserver.nessus.at’, ‘Mtr to www.orf.at’, ‘hop_1_rtmax’, ‘max’, 1.0), (‘operator’, ‘MERGE’)’: too many operands left

The Output of the Agent with the mtr.py plugin looks like this
OMD[site1]:~$ cmk -d XXXXXX-01.vserver.nessus.at

<<<check_mk>>>
Version: 2.0.0p8
AgentOS: linux
Hostname: XXXXXX-01
AgentDirectory: /etc/check_mk

<<mtr:sep(124)>>
www.orf.at|1628514492|8|vl700.edge03.ndc.vie.nessus.at|0.0%|10|1.4|1.1|0.7|1.8|0.3|100g-ae0.edge01.ndc2.vie.nessus.at|0.0%|10|1.2|1.2|0.7|1.6|0.3|vix-et-0-1-2-0-r60.esh.vie.at.nextlayer.net|0.0%|10|1.7|6.8|1.2|41.8|12.7|ae2-0-r18.uni.vie.nextlayer.net|0.0%|10|8.4|15.4|5.1|74.2|21.0|apa.customers.at.nextlayer.net|0.0%|10|2.1|2.1|1.6|2.7|0.4|rou-vie-pe-101.apa.net|0.0%|10|2.1|2.0|1.3|2.7|0.4|194.158.128.241|0.0%|10|1.9|1.6|1.1|2.4|0.4|www.orf.at|0.0%|10|1.1|1.0|0.8|1.5|0.2

The Service Check is OK in the Web-GUI and looks like this

Service check command: check_mk-mtr
Details:
Number of Hops: 8
Packet loss 0.0%, Round trip average 1.0ms, Standard deviation 0.2ms
Hops in last check:
Hop 1: vl700.edge03.ndc.vie.nessus.at
Hop 2: 100g-ae0.edge01.ndc2.vie.nessus.at
Hop 3: vix-et-0-1-2-0-r60.esh.vie.at.nextlayer.net
Hop 4: ae1-0-r18.uni.vie.nextlayer.net
Hop 5: apa.customers.at.nextlayer.net
Hop 6: rou-vie-pe-101.apa.net
Hop 7: 194.158.128.241
Hop 8: www.orf.at
Service performance data (source code) hops=8;;;; hop_1_rta=0.0012;;;; hop_1_rtmin=0.0006;;;; hop_1_rtmax=0.002;;;; hop_1_rtstddev=0.0004;;;; hop_1_response_time=0.0013;;;; hop_1_pl=0;;;; hop_1_rta=0.0012;;;; hop_1_rtmin=0.0006;;;; hop_1_rtmax=0.002;;;; hop_1_rtstddev=0.0004;;;; hop_1_response_time=0.0013;;;; hop_1_pl=0;;;; hop_2_rta=0.0034;;;; hop_2_rtmin=0.001;;;; hop_2_rtmax=0.0214;;;; hop_2_rtstddev=0.0063;;;; hop_2_response_time=0.0012;;;; hop_2_pl=0;;;;

hop_8_rta=0.001;0.15;0.25;; hop_8_rtmin=0.0008;;;; hop_8_rtmax=0.0015;;;; hop_8_rtstddev=0.0002;0.15;0.25;; hop_8_response_time=0.0011;;;; hop_8_pl=0;10;25;;

When i query livestatus i get performancedata:

lq “GET services\nColumns: perf_data metrics check_command\nFilter: host_name = XXXXX-01.vserver.nessus.at\nFilter: service_description = Mtr to www.orf.at\nLocaltime: 1628600525\nOutputFormat: python3\nKeepAlive: on\nResponseHeader: fixed16\nColumnHeaders: off”
200 8482
[[u"hops=8;;;; hop_1_rta=0.0035;;;; … ,u"hop_8_response_time",u"hop_8_pl"],u"check_mk-mtr"]]

Can anyone help me with this problem?

BTW: The checkplugin-script mtr.py (Python3) has 2 errors
File “./mtr.py”, line 183, in host_to_filename
hostname = host.decode(“utf8”)
AttributeError: ‘str’ object has no attribute ‘decode’
solved by changing hostname = host.decode(“utf8”) to hostname = host

Thanks and
Best Regards Fritz

Hi Fritz,

I can’t help you on your question, sorry.

But on the last bit, you could actually help us by opening a pull request on Github with the fix.
Here’s the right place for you: checkmk/mtr.py at master · tribe29/checkmk · GitHub

Thanks
Elias

Short solution for this problem is the following.

Copy the mtr plugin from “~/share/check_mk/checks/mtr” to “~/local/share/check_mk/checks/mtr” and modify the line beginning at 143

for idx in range(0, hc):
        state, text, perfdata = get_hop_info(hops, idx + 1, apply_levels=(idx + 1 == hc))
        if state is not None:
            # This is perfdata from a hop, we do not yield it yet (looks ugly..)
            #hop_perfdata.extend(perfdata)
            #else:
            # Last hop with state, text and perfdata. Yield everything we have
            yield 0, "Number of Hops: %d" % hc, hop_perfdata
            yield state, text + "\r\n%s" % format_hopnames(hopnames), perfdata

The problem is only the line what outputs performance data if in the original no state is present - why? :smiley:

1 Like

Thank you, your solution did not solve the problem, but showed me the right way.

I have avoid the issue with this modifications.

for idx in range(0, hc):
    state, text, perfdata = get_hop_info(hops, idx + 1, apply_levels=(idx + 1 == hc))

    if state is None:
        ## This is perfdata from a hop, we do not yield it yet (looks ugly..)
        hop_perfdata.extend(perfdata)
    else:
        # Last hop with state, text and perfdata. Yield everything we have
        #yield 0, "Number of Hops: %d" % hc, hop_perfdata
        yield 0, "Number of Hops: %d" % hc
        yield state, text + "\r\n%s" % format_hopnames(hopnames), perfdata
1 Like