Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Guys,

So, this question is more of an asking for a recommendation request for ideas so it may be better suited in the discussions forum I'm not certain.

Basically, I've been working on a Dashboard which contains a component that monitors a variety of sites to check they are working.

I've gone down the route of using HttpWebRequests

C#
var request = (HttpWebRequest) WebRequest.Create(url);
request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);                

var timer = new Stopwatch();

var siteState = WebSiteStateEnum.Okay;
try
{
     timer.Start();
     var response = (HttpWebResponse) request.GetResponse();
     response.Close();
     timer.Stop();

     TimeSpan timeTaken = timer.Elapsed;

     ...//Code to determine if site is up/down/slow based on response
}
catch (Exception)
{
     timer.Stop();
}
UpdateWebsiteResult(id, siteState);
Thread.Sleep( siteState == WebSiteStateEnum.Down ? 30000 : 60000);


So this code runs and it seems to be okay. Not amazing but okay.

My question is, would you have taken this approach or would you have driven this process from the individual sites by creating a signalR HeartBeat type module that you add to each site?

Is there anything I should add-in / do differently to monitor the status of various websites from a central point?

(These sites are hosted on different servers/locations to the dashboard site due to various client requirements on the individual sites.
Posted

1 solution

Hi,

I think a better approach would be to:

1. Put the website "ping" code into a service that updates a database table.
2. In the dashboard just retrieve the table status and display it.
3. Put a history of the pings into another table so the dashboard can drill down into it.

This frees the dashboard so it is responsive and doesn't freeze on delays and timeouts.

You can then easily create different views to show different groups or categories of the various websites that you are monitoring.

Can't comment on SignalR as I haven't used it extensively.

- Grant
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900