Graphs not showing warn/crit values when using levels_lower parameter in check_levels function

CMK version: 2.3.0p2
OS version: Ubuntu 22.04

Hi,

I’m studying docs for writing own plugins with graphs. For testing, After all, I copy/pasted the example check plugin and agent plugin from github page. To prevent typos.

On pictures in Writing agent-based check plug-ins section 4.5, there are shown lines for WARN and CRIT values.

However in my case, after I used examples from github, WARN/CRIT values are not shown.

1 Like

I made some progress with milliions of try/error.

If I don’t use check_levels function and only use

yield Metric(name="hosts_up_perc", value=hosts_up_perc, levels=(hosts_up_lower))

then I get Warning/Critical lines in graph.

But, I had to add levels=(hosts_up_lower) into yield Metric command. That is missing in documentation. But since I didn’t used check_levels functions, state determination is not working now.

If I use check_levels function according documentation

    yield from check_levels(
        hosts_up_perc,
        levels_lower = (hosts_up_lower),
        metric_name = "hosts_up_perc",
        label = "UP hosts",
        boundaries = (0.0, 100.0),
        notice_only = True,
    )

then warning/critical is missing.

It has something to do with paramter levels_lower. Using together check_levels and yield Metric with command above I mentioned doesn’t help.

Any advice?

@Sara Can we move thread back to the Troubleshooting section? I think it’s not a problem with Checkmk documentation and particular example from docu as I stated before, but general with function check_levels itself. I will change Topic name so more people will have look (hopefuly) if it won’t be specified as problem with just docu.

No matter what I try, when using levels_lower Warning/Critical is just not drawn.

    yield from check_levels(
        hosts_up_perc,
        levels_lower = (45.0, 21.0),
#        levels_lower = (None),
#        levels_upper = (45.0, 21.0),
#        levels_upper = (None),
        metric_name = "hosts_up_perc",
        label = "UP hosts",
        boundaries = (0.0, 100.0),
        notice_only = False,
    )

Using only levels_upper will drawn Warning/Critical fine.

I tried to combine lower and upper with same values, None value, etc, nothing helped.

I think this is by design, with check_levels the warn/crit for the graph system comes from the upper_levels. And as there is no field for a second pair of warn/crit in the metrics definition you can not have both. see: Metrics in the Docs.

metricname=value;warn;crit;min;max

here a sample from one of my FW checks with upper and lower levels
image
as you can see the warn/crit is shown.

Here the rule for the levels
image

and a final look at the raw perfdata, there you also see the upper levels are used

if you want the lower levels in the metrics and still use check_levels you could do the check_levels with out metric_name and yield a separate metric.

    yield from check_levels(
        hosts_up_perc,
        levels_lower = (45.0, 21.0),
        # metric_name = "hosts_up_perc",
        label = "UP hosts",
        boundaries = (0.0, 100.0),
        notice_only = False,
    )
   yield Metric(name="hosts_up_perc", value=hosts_up_perc, levels=(45.0, 21.0)) 

Cheers
Thomas

2 Likes

Wow, interesting behaviour. That is exactly what I need.
Thank you for advice.

@marbaa Please don’t forget to mark the answer as a solution if it has solved the problem :wink:

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.