I have only an idea that might help: One can query livestatus information with
services have a
staleness column. So if you query e.g.
hosts table with the columns
lq "GET hosts\nColumns: name staleness"
You get a list, similar to this one (hostnames intentionally modified):
The value on the “right hand” is always rising when you execute the query again, until it reaches
1 (or slightly above
1), and then “goes down”. I believe that this represents a “check cycle/interval”. If one filters this with
staleness > 1 and counts that, one might be able to check the “number of stale services”, this way.
Obviously, one still has to write a check for this. I hope I haven’t made a mistake in my thinking, and am leading you on a completely wrong path…
Perhaps someone from the forum can confirm or refute this, and/or has a “different/better idea”. In the meantime, here is the official livestatus documentation, with lots of helpful hints and examples:
5.3.2: Retrieving status data via Livestatus