Missing function in check_mk 2.0 (Migration issue)

CMK version:
check_mk 2
OS version:
Ubuntu 20.04
Error message:
none
Output of “cmk --debug -vvn hostname”: (If it is a problem with checks or plugins)
Problem is the function “get_age_human_readable” is not anymore in check_mk 2.0. I cant find the method in the new API. Can someone give me the content of the method or the new version for it in check_mk 2.0?

So it would help me if you only give me the function/method content, what the method does. Then I would copy it 1:1 in a new method with the same name. (if it not would work, then pls give me a another solution)

regards

The easy solution is - the function is not gone. If you take a look at the checks like “acme_certifcates” or “veeam_client” you see the usage of “get_age_human_readable”. This is for classic legacy checks.

If you want to use this function inside a new CMK 2 check you need to make an import at the start.

from cmk.base.check_api import (
    get_age_human_readable,
)
4 Likes

Thanks that was the solution for my problem :slight_smile:
If I may ask you one more question, is there a guide for a migration to cmk 2.0?

I have simmilar issues with WATO checks, like “ListofStrings” is also not anymore in check_mk 2.0. Can I also import that from a lib or is there a diffrent approach nessecary?

Ok, I found my problem with “ListOfStrings”.
But still thanks for your help. :slight_smile:

The new check API 2.0 has the render class with the timespan methord to achieve the same output.

from .agent_based_api.v1 import render

infotext = render.timespan(seconds)

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.