Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programatically determine if an IIS site is receiving requests?

Tags:

c#

iis

wmi

The title pretty much says it all. Some caveats are:

  • I need to be able to do it in C#
  • It needs to be able to be done from a remote server (ie, running on one server, checking IIS on another)
  • Needs to be close to real-time (within 1 second)
  • Can use WMI calls

I've tried watching the log file, but it turns out that isn't nearly close enough to real-time.

Thanks!

EDIT: I put this in a comment on Tom's answer, but it's more visible here:

I was able to look for changes using this counter:

var perf = new PerformanceCounter("ASP.NET Apps v2.0.50727", "Requests Total", "_LM_W3SVC_[IIS-Site-ID]_ROOT", "[Server-Name]");
like image 696
Daniel Schaffer Avatar asked Dec 05 '08 17:12

Daniel Schaffer


1 Answers

How about reading the ASP.NET requests/sec performance counter on the remote machine?

The System.Diagnostics.PerformanceCounter class has a constructor which takes a machine name.

like image 146
Tom Jelen Avatar answered Nov 16 '22 08:11

Tom Jelen