I was wondering how people have gone about programatically checking if SharePoint is still available?
I use the following now to check it, but it relies on the SharePoint object model and must run on the machine in question... is there an approach for doing this remotely? Simply pinging the server is not an option as this won't pick up on instances when IIS has stopped working:
public class Uptime
{
/// <summary>
/// Checks uptime directly by using the SharePoint Object Model
/// </summary>
/// <param name="siteCollection">The site collection to check availability for</param>
/// <returns>True on a connection, false if no connection was able to be made</returns>
public bool CheckUptimeDirect(string siteCollection)
{
try
{
using (var site = new SPSite(siteCollection))
{
using (var web = site.OpenWeb())
{
web.Dispose();
return true;
}
}
}
catch (Exception)
{
return false;
}
}
}