SNMP Plugin, get past service values for metric calculation

Hi there!

The idea is to display the delta value for a basic counting service (current value - past value). I would like to hand over that value to a custom metric. That metric would then display me delta-graph for that service.
I’m not quite shure if I have to do the correct delta-value calculation in the plugin file or if the metric has a specific function for that.
If I have to do it in the plugin file, is there a way to get a past service value?

Thank you very much!
Lou1s

You can do this in the check plugin using the value_store (look for get_value_store() in the Check API documentation.) or you can use the set_item_state and get_item_state functions (not part of the official API).

from cmk.base.item_state import (
    get_item_state,
    set_item_state,
)

past_value = get_item_state('name_of_the_value')
set_item_state('name_of_the_value', value)
2 Likes

The check API for check plugins provides a get_rate method for that.

E.g. if you have a byte counter value it returns a bytes per second rate.

1 Like

@thl-cmk , @r.sander thank you, that’s what I was looking for.
I implemented it via a value_store and get_value_store() and got the delta value with the build in function get_rate().

If somebody doesn’t find the Check API documentation directly. Click the “Help Icon” on the bottom left corner of the CheckMK WebView.
Under: “Help Icon” > “Developer resources” > “Check plugin API reference”, you will find the API documentation.

Like @thl-cmk mentioned, search for get_value_store() or get_rate().

1 Like

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.