I'm writing a report that shows total downtime for our website. When a user visits our site and something's not working (ie the load balancer thinks our site isn't responsive), it sends visitors to a "Maintenance" page. The maintenance page logs to the database that it's been viewed and displays a friendly message to the visitor.
That means that I end up with a table of values that looks like this:
ReportedOutage
-----------------------
2010-07-30 06:23:18.093
2010-07-30 06:23:18.623
2010-07-30 06:23:18.720
2010-08-02 14:28:07.123
Ideally, I'd want to run the report and see something like this:
OutageStart OutageEnd
----------------------- -----------------------
2010-07-30 06:23:18.093 2010-07-30 06:23:18.720
2010-08-02 14:28:07.123 2010-08-02 14:28:07.123
Since I have only the failed records in the logs, how do I calculate the length of the various outages? I can start by getting MIN(Reported)
, but then I have to find the last record in the series, such that there's a time period in between it at the next record.
Any thoughts on how to do this? I realize that I could create a process to check the site every minute and record outages and successes, which would make this easier, but I'm trying to work with what I've got before I add another step.