We use cookies to ensure that we give you the best experience on our website.  Visit our Privacy Policy to learn more. If you continue to use this site, we will assume that you are okay with it.

Your choices regarding cookies on this site.
Your preferences have been updated.
In order for the changes to take effect completely please clear your browser cookies and cache. Then reload the page.

Using Parse Functions

Checkmk Manual

Search in the manual

This is the old documentation.
You can find the shiny new documentation here, which is replacing over time this one.
Thus, this article is obsolete and may be not valid anymore - however, the new one is not finished yet!

1. Parse Functions

Some agent based checks have to deal with more complex agent output then simply a few well defined rows and columns. One such example is the check multipath, which needs to deal with a great variety of bizarre output formats of the command multipath -l on Linux.

The typical implementation of such a check is to shift the task of parsing the stuff that arrives the inventory- or check function in the info parameter to a helper function. That function parses the raw agent output into some convenient data structure - often, but now always, a dictionary. While this works pretty well, it has one drawback: If the check deals with more than one item then the same parsing has to be done over and over again.

Beginning with version 1.2.5i7 Checkmk's check API now allows to declare a "parse_function" in the check_info declaration. Here is an example:

check_info["multipath"] = {
    'check_function':          check_multipath,
    'inventory_function':      inventory_multipath,
    'parse_function':          parse_multipath,
    'service_description':     'Multipath %s',
    'group':                   'multipath',

You need to define this function in the same file. It gets the one argument info and must return some parsed representation of that data:

def parse_multipath(info):
    parsed = {}
    # Do some bizarre parsing from info into the new variable parsed
    return parsed

Checkmk will now automatically process all agent output with the parse function before it calls the inventory or check function. In order to make this clear, you should not anymore use the name info as argument, but rather parsed:

def inventory_multipath(parsed):
    # parsed is already in convenient parsed form

... and ...

def check_multipath(item, params, parsed):
    # parsed is already in convenient parsed form

Note: Parse functions cannot be defined for sub checks like foo.bar. Define it on the main check foo. All subchecks will the automatically also use the parse function. If there is no man check then you have bad luck and cannot use parse functions.