How to reset perfmon counter added using System.Diagnostics.PerformanceCounter

399 views Asked by At

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

0

There are 0 answers