Monitoring windows services

B

BC

Hi all,

I have a windows service (on client machine) that monitors a MSMQ queue
(on server machine). When a new message is in the server queue, the
client windows service will get the message and does some process.
What I want to do now is create a small windows application that sits on
the client machine and monitor the activities of the windows service.
I am using Visual Studio .NET 2003 with C#.
The question is how can I monitor a windows service? Any related
articles will be great.


Cheers,

Benny
 
W

Willy Denoyette [MVP]

BC said:
Hi all,

I have a windows service (on client machine) that monitors a MSMQ queue
(on server machine). When a new message is in the server queue, the
client windows service will get the message and does some process.
What I want to do now is create a small windows application that sits on
the client machine and monitor the activities of the windows service.
I am using Visual Studio .NET 2003 with C#.
The question is how can I monitor a windows service? Any related
articles will be great.


Cheers,

Benny

What exactly do you mean with "monitor", if you didn't implement your
service such that it could be monitored there is very little to be
monitored. Sure you can control the state of the service, like starting
stopping etc. but if you need to monitor it's activity you should expose
some objects and/or counters data, lets say the number of MSMQ processed
sent so far.
You have several options depending on your requirements, but you will need
to add some code to your service; the easiest is to publish performance
objects through private performance counters and use the performance monior
to watch these counters.
Another option is to use System.Management classes to expsose performance
objects or state info by publishing these objects through the WMI system,
this is the way most Msft services like IIS, ASP.NET, SQL Server... publish
their state/performance data. Any client (.NET using System.Management and
others using COM and or scripting) can be built to query the exposed
objects. Note that the latter option can also be used to manage the service.


Willy.
 
B

BC

Hi Willy,

Thanks for the reply. Basically what I want is awindows application that
allows me to monitor the activties (performance, exception errors...
etc) of a windows service that will be also create by me.


Cheers,

Benny
 
R

Richard Grimes

BC said:
Thanks for the reply. Basically what I want is awindows application
that allows me to monitor the activties (performance, exception
errors... etc) of a windows service that will be also create by me.

The best way to do monitor information is to add performance counters to
your service and use the performance monitor in XP.

The event log was designed to be the place for messages (like exception
details) from services. Unfortunately Microsoft provided a really bad
implementation of the code to log an event in v1.0 and v1.1, so I never
recommend people use the EventLog class to log events. The version of
this class in v2.0 is much better, and you can use it to log events
correctly, but unfortunately it also allows you to log events in the
incorrect way :(

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top