Custom check and graph template

Hello,

I am writting a custom check with mutiple values in 1 check and while it’s currently graphing those each in it’s own graph, i would like to have 1 graph with all the values in it the same way you they are graphed for TCP connections.
I can’t find anything about it. Some doc speak about pnp-templates but i when i look at some checks, they aren’t using templates.
Can someone point me into the right direction.

Best,
Laurent

You are right, pnp-templates are not what you are looking for. The magic term is graph_info.

This is an example taken from ~/share/doc/check_mk/treasures/memcached/web/plugins/metrics/memcached.py:

...
metric_info["cas_hits"] = {"title": _("CAS hits"), "unit": "", "color": "32/a"}
metric_info["cas_misses"] = {"title": _("CAS misses"), "unit": "", "color": "22/a"}
metric_info["cas_badval"] = {"title": _("CAS bad identifier"), "unit": "", "color": "12/a"}

graph_info.append({
    "title"   : _("CAS"),
    "metrics" : [
        ( "cas_hits", "area" ),
        ( "cas_misses", "stack" ),
        ( "cas_badval", "line" ),
    ],
})
...

It defines three metrics and a graph that includes them.

More samples can be found in ~/lib/python/cmk/gui/plugins/metrics/check_mk.py, e.g.

graph_info["replicas"] = {
    "title": _("Replicas"),
    "metrics": [
        ("ready_replicas", "area"),
        ("total_replicas", "line"),
    ],
    "scalars": ["ready_replicas:crit",]
}

That’s a graph with two metrics but it also shows the CRIT level as a red line (given the CRIT level comes with the performance data).

If you are confused about graph_info.append({…}) vs. graph_info['some_id'] = {…} then don’t be. graph_info is actually an OrderedDict with a special append() method: if you don’t supply a key, then some unique key (like ID_nnnnn) is generated for you, so either way is OK.

wow, i did have a quick look at metrics but not enough i guess. I wasn’t expecting graphs to be in metrics like they are another part.
Many thanks, i am going to try that shortly !