Active Check graphing issue

Hi, I’ve made myself a active check plugin via the nagios intergration, which checks if certain WireGuard peers on a mikrotik device have had a recent handshake and I also added the tx and rx values to the perf data.

Service performance data (source code) rx=71288B tx=286952B

When CheckMK creates the graphs, the units of the values aren’t being honoured. I thought it would auto scale the units from B to KB to MB to GB. But instead it’s just showing 1.01e+5 for example on the graph.

Have I missed something here, or is this not supported on Nagios plugins gathering perf data?

I’m not sure where or how currently but do I need to create a pnp4nagios definition by chance?

Short answer no.

To fix this you need to generate a CheckMK graph definition or better said a definition of the type of data the check returns.
The section “Customized presentation of metrics” is what you need to read.

Slowly getting the hang of it now.

Although I can’t workout were I’m going wrong, if it reports the rx and tx directly from the WireGuard peer, the service graph slows correctly, but the Service Metrics shows incorrectly as it shows total but with per second unit. It always reports in bytes.

If I set the plugin to only report back the different between each run in the prefdata, then Graph and Service Metrics unit size is way out!. 3-3.5MB/s shows as 192MiB/s.

The graph is showing what happens during a file download and when not downloading.
The script always outputs the metrics in Bytes, so I know the units isn’t changing.

#!/usr/bin/env python3

from cmk.gui.i18n import _
from cmk.gui.plugins.metrics import (metric_info, graph_info, perfometer_info)

metric_info["wgpeerrx"] = {
    "title": _("WireGuard Peer RX"),
    "unit": "bytes/s",
    "color": "#00e060",
}

metric_info["wgpeertx"] = {
    "title": _("WireGuard Peer TX"),
    "unit": "bytes/s",
    "color": "#0080e0",
}

graph_info["wgpeertraffic"] = {
    "title": _("WireGuard Peer Bandwidth"),
    "metrics": [
        ("wgpeerrx", "area", _("Input bandwidth")),
        ("wgpeertx", "-area", _("Output bandwidth")),
    ]
}

nagios check script output
continuous

print(message + f"|wgpeerrx={rx_bytes}c wgpeertx={tx_bytes}c")

difference between last run

print(message + f"|wgpeerrx={rx_bytes_diff} wgpeertx={tx_bytes_diff}")

Any idea where I’m going wrong here?