Replacement of cmk modules in 2.3

Hello,
I’ve written in the past a plug-in that uses the module ‘cmk.base.item_state’.
With 2.3 that module seem to be gone after I did an test update.

How can I find what module I should use for replacement of this? I’m not sure what is the right way to approach this.

It’s regarding this module: cmk.base.item_state.
I got that option recommended in the past in this post

But overall is there a document that helps us find modules that replace the old ones? Or how does that work?

Best Regards,
Erik

The mechanics to store and retreive data between check intervals have changed. Until 1.6 it was done with the checkmk functions get_item_state() and set_item_state(). With 2.0/2.1 these functions still existed but became deprecated and apparently they have completely gone with 2.3. (I don’t know about 2.2.).

The new way to store data between check intervals is the value store:

from .agent_based_api.v1 import get_value_store

def check_function(...):

    # get a reference to the value_store:
    value_store = get_value_store()
    
    # get previous data:
    previous_data = value_store['my_key'] # or value_store.get('my_key', 0)
    
    # store current data:
    value_store['my_key'] = current_data

    ...  

The value store is a MutableMapping and can be used like a regular dictionary. It gets automatically persisted, i.e. there is no function like put_value_store() or something like that.

2 Likes