protected IPerformanceCounterInfo[] PrepareCounters() { if (_refreshCountdown == 0) { _refreshCountdown = _performanceCounterGroup.RefreshInstanceInterval - 1; return(_performanceCounterGroup.GetFreshCounters().ToArray()); } _refreshCountdown--; if (_refreshCountdown < 0) { _refreshCountdown = _performanceCounterGroup.RefreshInstanceInterval - 1; } return(_performanceCounterGroup.GetCounters().ToArray()); }
protected void ReadCounterGroup(IPerformanceCounterGroup counterGroup) { var count = 0; foreach (var counter in counterGroup.GetFreshCounters()) { if (counter.HasPerformanceCounter) { var nextValue = counter.NextValue(); OutputInformation("{0}.{1}.{2} {3}:\t{4}", counter.CategoryName, counter.CounterName, counter.InstanceName, counter.Name, nextValue); count++; } else { OutputWarning("Cannot read counter {0}.", counter.Name); } } OutputInformation("{0} counters read.", count); }