tags:

views:

69

answers:

3

Need to develop a Webserver Monitoring system. There may be Hundreds of webserver running on different servers. This system need to keep monitoring of each webservice at a given interva and update the status in DB.

The current options designed.

Options1: Created class Monitorig it has Method1 which call the webservice dynamically on regular interval say 10 Min. And stores the status(Fail/Success) data to DB.

In a for loop I'm creating a new instance of monitoring class every time and a new Thread.

Example.

foreach(int i in idlist)
{
Monitoring monObj = new Monitoring();
Thread workerT = new Thread(monObj.MonitorWebService);
workerT.Start(i);
}

in the MonitorWebService API there is a infinity for loop which does calling of the given webservice at a given interval as 1 min or 10 min etc. To process this in a regular inverval I'm using EventWaitHandle.WaitOne(T1 * 1000, false) instead of Thread.Sleep(). Here T1 can be 1 min or 1 or 5 hours.

Oprion 2:

in the for loop open a new appdomain with new Name and open a new thread as given below.

foreach(int i in idlist)
{
string appDNname = WSMonitor + i.ToString();
AppDomain WMSObj = AppDomain.CreateDomain(appDNname);
Type t= typeof(Monitoring);
Monitoring monWSObj = (Monitoring) WMSObj.CreateInstanceAndUnwrap(Assembly.GetExecuti ngAssembly().FullName, t.FullName);
Thread WorkerT = new Thread(monWSObj.MonitorWebService);
WorkerT.Start(i);
}

in option2 I'm unloading the AppDomain when the time interval is more then 10 min. And when ever its required loading. I thought option 2 will release resource when its not required and reload when its required.

Which is the best/better approach? Do we have any better solution. A Quick Help is highly appreciated.

+2  A: 

First of all:

Option 2 is bad. It will not unload any more data than your Option 1 does. .Net will automatically unload all application data when it is no longer referenced/needed. It just won't unload the application itself. But in your case you cannot unload your application itself anyways so using an AppDomain is completely useless here.

Option 1 is not terribly good either because (abusing) Threadsyncs for timining has huge overhead and is never a good idea.

Better options are:

1) If you don't need to run permanently just have the external windows task scheduler call your application at the needed times. This has the advantage that it is easily externally configurable and you don't have to worry about any timing in your code at all.

2) If you need/want to run permanently then the most simple and clear way would be to use one of the available Timer objects.

3) If you don't like 2) use a loop with Thread.Sleep (Don't try to abuse the Sleep interval for timing, just sleep e.g. 1 min and then wake up and check if things need to be done).

Foxfire
+1 for running as a scheduled task; Microsoft have provided us with a while infrastructure for running tasks at a given time/interval and in Vista/Windows 7 as a response to an event occuring, it's crazy not to use it.
Rob
A: 

Did you consider using an existing website monitoring solutions such as Nagios, Pingdom or AlertFox?

I mention this because we once had our own homegrown monitoring system but then gave up and outsourced it.

RegExGuru
A: 

Tnx for you time and immediate response.

1) If you don't need to run permanently just have the external windows task scheduler call your application at the needed times. This has the advantage that it is easily externally configurable and you don't have to worry about any timing in your code at all.

---Monitoring of webservice is a permanent job. This should run for ever. This application job is to monitor the webservices and update the respective to DB.

2) If you need/want to run permanently then the most simple and clear way would be to use one of the available Timer objects.

---Initially I thought using the timer object. But the trouble is I need to open new timer object ever time based on the new webservices added to the system. The time interval can change once the time object is created. I need to increase the time interval if the respective webserver is under maintenance. Controlling the timerobject once it is created looks like out of control. I don’t know how to do this.

3) If you don't like 2) use a loop with Thread.Sleep (Don't try to abuse the Sleep interval for timing, just sleep e.g. 1 min and then wake up and check if things need to be done).

---I my case the time interval is not a constant. This changes as per the administrator decision. Thread sleep has over heads so I was using the waitone method to achieve the time delay.

Let me explain my requirements:

There are some webservices/aspx/asp running on the different servers. I my application need to monitor these and update db with fail or success. Each webservice monitoring is an independent process. Monitoring interval (30s, 1 min or more) will differ from url to url that will be based on the administrator. Administrator can change the time interval or url etc once the process has started. I have designed the system intelligent to take care of this. This app is something probes monitoring system.

I can’t use third party tool or can buy any tools for this. I need to design this and I’m look for an idea.

Madhu
If your posting a response to someone's question, use the `add comment` link instead of postion a new answer. If you are updating your requirements, edit your original question.
Alastair Pitts