insights-core icon indicating copy to clipboard operation
insights-core copied to clipboard

RFE: Easy way to monitor local status

Open mvollmer opened this issue 5 years ago • 1 comments

Hi,

I am working on adding some Insights support to Cockpit (https://cockpit-project.org/) and I am currently pondering how to monitor the local status, such as whether the machine is registered and when the last succesfull upload was, and whether there were any problems recently.

The obvious approach is to run insights-client --status --quiet and check the exit code. This works well enough. It does require a working network connection and is a bit slow, and we wouldn't want to run it periodically just to keep the UI up-to-date for that reason. Also, it doesn't give information about the latest upload or recent upload failures.

I had hopes that running insights-client --status --quiet --offline would be cheap and not require network access, but it crashes. Also, it still checks the signatures on the eggs, which is again too slow for polling.

The sneaky approach is to monitor /etc/insights-client/{.registered,.unregistered,.lastupload} with inotify. I guess there is no stability guarantee for those files and using them as API is problematic. (I have noticed that with legacy_upload=True they seem to be written on every invocation of the client and thus the timestamps in them are meaningless... True?)

So what if insights-client maintains a little JSON record in /etc/insights-client/status that we can watch? Something simple like

{
   registered: true,
   last_upload: <time-in-seconds-since-the-epoch>
}

for a start.

For failures, it is probably best to refer to the status and logs of the insights-client systemd unit.

I am happy to prototype this as part of my work on Cockpit and open a PR once I have something tangible.

mvollmer avatar May 21 '19 10:05 mvollmer