0

I inherited a project that uses custom performance counters to monitor number of successful/failed requests and their processing time for an IIS deployed web service. Code I used to log counters is like below:

using (var performanceCounter = new PerformanceCounter() { CategoryName = MyConstants.Constants.PerformanceCountersRootName, CounterName = counterName, MachineName = "." })
{
    performanceCounter.ReadOnly = false;
    if (operationCounter != OperationCounter.ProcessingTime)
    {
        performanceCounter.Increment();
    }
    else
    {
        performanceCounter.RawValue = value;
    }
}

Now my question is how could I reset counters after a fixed period of time, say once every week. Here is a similar question, but my problem is I don't want to reset counters using code.

I need to do so using some scheduling mechanism, may be some sort of powershell script or windows schedule or something of this sort.

I have checked this answer and I don't feel this to be approach for me. Please suggest.

Thank You

Ravi

Community
  • 1
  • 1
TechnicalSmile
  • 1,387
  • 5
  • 16
  • 30
  • 1
    Run a weekly scheduled task with a powershell script or C# app that sets the `RawValue` to `0` – Mathias R. Jessen Dec 30 '16 at 13:50
  • thanks Mathias that sounds good. I'll do search on how to do this via powershell. If you know that on top of your head then please post it as answer and I'll accept it. – TechnicalSmile Dec 30 '16 at 14:07

0 Answers0