Having a website up and running reliably requires that you monitor its health. You should always be using a monitoring tool like Pingdom (there are many others). That way, you can get notified when the website is down.
Now, there are several ways of making sure that things are ok at runtime. For example:
Personally, I like to monitor more than just if a website is up. I also want to know if key parts of the system are functioning properly, like connections to other systems, if certain content is available and if my indexes are ok. These checks may be very specific to my implementation.
That’s why I created a simple drop-in .aspx script that you can easily configure to check these things. You can find it in this Gist on Github. Example output:
It’s quite easy to configure and extend. Just read through the implementation of the Page_Load(…) method. Some more details here:
Security
You’ll want to limit who gets to use the monitoring page, to prevent abuse and prevent hackers from getting details about your implementation. This is especially important if the checks you are doing may impact system performance significantly. Make sure your monitoring tool’s requests to the page match your security settings here.
Adding checks
You can add checks to do when the page is requested by adding them to the ChecksRun collection. Some examples are in the code below. They include checking specific items’ presence in databases and having versions and layout/presentation. They also include checking if search indexes contain enough items, if certain url’s are reachable from the server and if configuration is specified correctly.
It’s also easy to implement your own specific types of checks. Add them to the region “actual checks” as classes that implement the ISitecoreCheck interface (or use the SitecoreCheckBase class).
Tags
You may not always want to run the same checks. Perhaps some checks should only be performed at night and some checks may be specific to your DTAP or CM/CD servers specifically. You can use tags to limit which tests are run, as demonstrated in the example below. And then you can specify which tags are applicable by specifiying them |-separated in the url parameter “tags”. The url //SitecoreChecks.aspx?tags=fail would result in the following:
Let me know if you have any questions/suggestions.