views:

197

answers:

1

I have a C# windows service which listens to a MSMQ and sends each message out as an email.

Since there's no UI, I'd like to offer an ability to monitor this service to see things such as # messages in queue, # emails sent (by message type perhaps), # of errors, etc.

What is the best/recommended way to accomplish this? Is it WMI or performance counters? Is this data viewed using PerfMon or WMI CIM Studio? Does any approach allow one to monitor the service real-time as well as providing historical analysis?

I can dig into the details myself but would appreciate some broad guidance to help demystify this subject.

+1  A: 

I do sometimes implement performance monitoring of my windows services. What I do I keep internal counters of things I am interested and create a way for an external program to access it. It can be WCF service hosted inside windows service which is fairly easy to implement and it can be accessed by various channels. Client of this WCF service is also quite easy to be done.

Other way is to create your own windows performance counters which could be read by an event viewer application.

In either case you need to keep track of what's going on in your service and expose that to outside. In your case you would need to keep count of MSMQ size, emails sent, errors got and measure time of collection of those. Should be easy. Then go for WCF service or custom performance counters. Use this msdn article on how to create custom counter. Hope this helps.

Maciej