Quick question regarding usage of valuestore

When using (in a/your plugin):

previous_value = value_store.get(key, 0)

but you just introduced a new host via discovery , what will be returned ?
Asking this as i would like to compensate a wrong initial evaluation on this.

I am assuming it will return nothing, therefore i would evaluate it as:

previous_value = value_store.get(key, 0)
if (previous_value) is None:

Struggling with this as atm i dont have a host that fits the condition to test.

Adjacent question would be for a dev environment, how can i deliberately clear/erase a stored value to test such a condition?

  • Glowsome

Hi Michael!

We will be having a DevHour relatively soon.
If you do not find the answer before that, maybe you could add the question to the doc?

The valuestore can be used just like a regular dictionary. So the get() method will return the given default value if the key cannot be found. In your case it will return 0.

The expression for the if statement will only be true if someone stored the actual value of None in the valuestore (as in value_store[key] = None).

If you want to delete an entry from the valuestore, do it just like with any other ordinary dictionary:

del value_store[key]

The more brutal method would be to delete the persistant storage, i.e. the file where the data is stored.

Look in the file ~/tmp/check_mk/counters/HOSTNAME. It contains all the values associated with HOSTNAME as a Python structure. Either manipulate the file (best done when the site is not running) or delete the file altogether.

Hi , thanks for clarifying/explaining it to me …

  • Glowsome
1 Like