Looking for some wisdom around the best way to have some data persistent across plugin executions. The case is I'm working on a plugin that involves reading a value from a database that indicates an issue has occurred but the record 'stacks' every time the event occurs. Until the database is reset the count will grow, so we only want to return the delta/change from the previously detected count as the measure. I'm interested in the best way to accomplish this which I'm thinking would be just creating a file on the collector the plugin is running from, and writing the last value to it. The next run can use that to compare against and then change the number if necessary.
Does this sound like a good solution or is there a better / more efficient way?
Solved! Go to Solution.
I think thats a good approach. Another approach would be to keep the status in a global variable. This works because the plugin instance is only loaded once and kept in memory. so - you could keep state in memory betwen executions. the problem obviously is if something happens to the collector and your plugin gets re-instantiate. in that case you have to fall back to a sollution like you described. I once created a plugin where I also wanted to only display the delta between runs. I used the in-memory approach
Oh interesting, I think that's worth a shot. For each instance of the plugin this will be instance per monitored host, correct? So if we're running it against 2 hosts the global variable will be one for instance A and one for instance B (i.e I don't have to do anything fancy to have one variable per host)?