minmon icon indicating copy to clipboard operation
minmon copied to clipboard

[Feature Request] 'dump out' current state

Open cap-cat opened this issue 1 year ago • 3 comments

I'd like a way to have minmon 'dump' all of its current state. That is, it would tell me the "OK", "alarm" or whatever of all the checks it has configured. It could either do this periodically (like reports), or possibly more usefully on some sort of prompt (eg. a SIGUSR1 signal).

The aim here is to be able to get a complete view of the current system, which I could then subsequently parse and display or render in some way. I'd use this when working on the system. For example, I do some sort of work, which causes a number of alarms to trigger and reset several times. When the work is finished, I'd like to ensure that all alarms are reset and that all the services on the machine are "green" (if not, then I've got some more work to do!).

It feels like the current reports mechanism could be extended to do this, perhaps with a magic variable (that the report Action could consume) that contains the whole state in some sort of serialised form. Alternatively, I guess its possible that every action could could be told to 'fire', so that you get updates for everything so could see from that what wasn't yet 'green'.

cap-cat avatar Jan 07 '25 17:01 cap-cat

I agree, SIGUSR1 is the most common way afaik. Where would the output go? stdout/stderr or a third file descriptor? What format would be a good fit (JSON, TOML, ..)? Or do you want to trigger the report with the signal? That would also be an option.

flo-at avatar Jan 11 '25 11:01 flo-at

I'd imagine the output would have to go to a configured location. The default could be /run/minmon/state (just add a RuntimeDirectory to the Systemd unit to have that directory created). If it can't write it because the directory doesn't exist, then write out a log message.

I'd personally go for json format to get maximum parser support in as many other languages as possible, but I guess Toml would be okay too.

Triggering the report is an option, BUT the report needs to have a magic variable that contains the state available to it. This feels like the "quick solution" rather than the best one, but works fine.

cap-cat avatar Jan 13 '25 10:01 cap-cat

Would you like to give it a try and make a PR? I don't have much time at the moment so it will have to wait some time otherwise.

flo-at avatar Jan 18 '25 15:01 flo-at