Help - use of PerformanceCounter for monitoring heartbeat?

N

n.phelge

I have a C# .NET 1.1 application where I need to monitor heartbeat
requests from an external system - the external system (which I cannot
otherwise access) is going to send a message to my application on a
periodic basis to let me know it is still functional, and my
application needs to monitor those messages, sending an email
notification if it doesn't receive one within some configured
interval. This seems like a good candidate for use of performance
counters within my application and MOM to monitor the counter values,
as this isn't data that necessarily needs to be persisted, but I'm not
sure which type of PerformanceCounter would apply to this scenario. I
really don't need to know the average or total number of messages
received - I need to know either when I received the last message or
how many I received in a fixed interval of time. I guess I could use
the NumberOfItems64 to represent the ticks at the time when the last
message was received and have MOM calculate the delta between the
current time and that value to see if it exceeds some threshold, but I
thought I would ask if anyone has other suggestions.

Thanks in advance
 
R

r norman

I have a C# .NET 1.1 application where I need to monitor heartbeat
requests from an external system - the external system (which I cannot
otherwise access) is going to send a message to my application on a
periodic basis to let me know it is still functional, and my
application needs to monitor those messages, sending an email
notification if it doesn't receive one within some configured
interval. This seems like a good candidate for use of performance
counters within my application and MOM to monitor the counter values,
as this isn't data that necessarily needs to be persisted, but I'm not
sure which type of PerformanceCounter would apply to this scenario. I
really don't need to know the average or total number of messages
received - I need to know either when I received the last message or
how many I received in a fixed interval of time. I guess I could use
the NumberOfItems64 to represent the ticks at the time when the last
message was received and have MOM calculate the delta between the
current time and that value to see if it exceeds some threshold, but I
thought I would ask if anyone has other suggestions.

Thanks in advance

I do this quite regularly, but don't bother with all the rigmarole you
suggest. Instead I use a simple timer.

When the heartbeat is detected, increment a counter. When the timer
interval expires, check to see how many heart beats have occurred. A
non-zero value indicates a problem. Then zero the counter.

Don't rely on a single heartbeat count -- you may get a race condition
and it may occur a fraction of a microsecond after your timer hit
especially if the clocks in the two systems have a slightly different
rate. If you expect one beat per second, check every two or three
seconds for a non-zero count of received beats. Unless you have a
very special application, that will detect a problem soon enough.
 

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