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:

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,

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.


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.


You’ve made my day!

You can’t imagine how helpful was this for me. This will make revolution in my plugins. Do you know how to make a combined custom graph? Like official plugin does:

Hi @marbaa ,
use the same metrics file and combine the graphs - i am still looking for hints regarding this one but hey - maybe you can help me there :wink:

graph_info["my_custom_graph_name"] = {
    "title": _("Server and Device Uptimes"),
    "metrics": [
        ("Server_Time", "line"),
        ("Device_Time", "line"),

1 Like

Hi @kribbit ,

at first I didn’t understand your code, but it gave me very good hint and then I search in check_mk files. Found /opt/omd/versions/1.6.0p11.cee/lib/python/cmk/gui/plugins/metrics/check_mk.py with all metric and graph definitions. I got it work almost perfectly. I can now produce combined graph with warn/crit values.

This is my custom metric file lokal.py in /omd/sites/otcsite16/local/share/check_mk/web/plugins/metrics

#!/usr/bin/env python

metric_info["totalused"] = {
  "title": _("Used filesystem space"),
  "unit": "bytes",
  "color": "#00ffc6",
metric_info["totalsize"] = {
  "title": _("Filesystem size"),
  "unit": "bytes",
  "color": "#006040",

metric_info["totalfree"] = {
  "title": _("Free space"),
  "unit": "bytes",
  "color": "#e3fff9",

graph_info["totalused"] = {
  "title": _("MapR filesystem usage"),
  "metrics": [
    ("totalused", "area"),
    ("totalsize,totalused,-#e3fff9", "stack", _("Free space")),
    ("totalsize", "line"),
# scalars -> show warn/crit values in graph for item send by agent custom check
  "scalars": [
  "range": (0, "totalused:max"),
# I thought this is needed to hide second graph which is created because of stacking with 'totalsize'
  "conflicting_metrics": ["totalfree"],

Simple script which is sending data from agent:


# = GB
free=$(( $size-$used ))

echo "0 lokal totalused=${used};${warn};${crit}|totalsize=${size}|totalfree=${free} Dumb output"
exit 0

Problem with this is, that separated graph Free space is still shown and I don’t understand why.

Fixed. I don’t need to send free space value in performace data from agent. Check_MK can calculate it by itself. So I can delete the metric info

metric_info["totalfree"] = {
  "title": _("Free space"),
  "unit": "bytes",
  "color": "#e3fff9",

Afterwards omd retart to make sure, and finally I have one, nice combined graph with warn/crit values.

Is there a way of only applying the changes to a certain graph?

I created long ago a local check that generated output like this:

0 Apache_CPU value=35 Current CPU Usage (%)
0 Apache_Memory value=1011933184;1073741824;1610612736 Current Memory Usage (bytes)

It works fine but obviously the units are not ok.

My problem is that because of inexperience I named both metrics ‘value’ and I still got 2 different services, so everything “worked”.

But if I change one of these graphs using what you’re describing on this post, I change both… Is there a way of only apply changes by both metric name AND service name?

Otherwise I’ll have to rename each metric and probably lose all my historic data…

For colors you should use this:

# Colors:
#                   red
#  magenta                       orange
#            11 12 13 14 15 16
#         46                   21
#         45                   22
#   blue  44                   23  yellow
#         43                   24
#         42                   25
#         41                   26
#            36 35 34 33 32 31
#     cyan                       yellow-green
#                  green
# Special colors:
# 51  gray
# 52  brown 1
# 53  brown 2
# For a new metric_info you have to choose a color. No more hex-codes are needed!
# Instead you can choose a number of the above color ring and a letter 'a' or 'b
# where 'a' represents the basic color and 'b' is a nuance/shading of the basic color.
# Both number and letter must be declared!
# Example:
# "color" : "23/a" (basic color yellow)
# "color" : "23/b" (nuance of color yellow)
# As an alternative you can call indexed_color with a color index and the maximum
# number of colors you will need to generate a color. This function tries to return
# high contrast colors for "close" indices, so the colors of idx 1 and idx 2 may
# have stronger contrast than the colors at idx 3 and idx 10.

# retrieve an indexed color.
# param idx: the color index
# param total: the total number of colors needed in one graph.

how can I apply the new rule without restarting all? I have tried
cmk -O and cmk -R but seems that my configuration is not seen until i do a full: omd restart

Moreover is possible to change the default value of a metric from Float to Integer ?


Hi @davidemarrone,

you need to do omd restart apache to apply changes in the metric section.