I have a command in my crontab to monitor a service (specifically, check whether the Tor version of my website can still be accessed): this monitoring command succeeds if it can access the site, and fails otherwise (and I get an email). However, because of intermittent failures of Tor, I get emails every now and then, ever for fairly short downtimes.
I would like to be notified if this monitoring command in my crontab has been failing for multiple consecutive times (say, 10 times), so I would only be notified for longer outages.
Of course, I could write a custom script to do this, storing the number of failures in a temporary file, etc., but as this looks like a pretty common need, I thought some standard solution for this may already exist (in the same way that moreutils' chronic already exists to serve a similar but different purpose.)
Is there a wrapper script such that issuing wrapper COMMAND will run COMMAND and succeed unless the last 10 invocations of COMMAND have failed, in which case it should return the last error code and the output of the failed invocations?