Local Check - specify correct Unit for Graph Metric

Hi there,

i’ve a local check which returns some perfdata values. (using the enterprise edition)
The problem is that cmk is interpreting the unit wrong and takes it as “Floating number” instead of Bytes:

image
Data = size=7060926234624;;;; allocatedsize=7060926234624;;;; footprintonpool=21182778703872

With custom graphs I can create an additional graph with the correct metrics like this:

But Is is possible to change the unit of the service graph directly instead of the use of an additional custom graph ?

Kind regards,
Constantin

Hi,
alternatively, you can add your own metric’s definition. Giving that your site is installed under /omd/sites/yoursite, you could add a python file under /omd/sites/yoursite/local/share/check_mk/web/plugins/metrics/yourdata.py. In your case it could look like:

#!/usr/bin/env python
# -*- encoding: utf-8; py-indent-offset: 4 -*-

metric_info["allocatedsize"] = {
    "title": _("Allocated size"),
    "unit": "bytes",
    "color": "green",
}

You can add in the same file more metrics (for size and footprintonpool).

Hope it helps.
Regards
Yvan

2 Likes

Hey Yvan,
thanks very much - that’s awesome, works like charm :slight_smile:
Just the Color definition seems to must be a html hexcode, just the name does not work.

image

You’ve made my day!
Constantin