public IList<CounterDescriptor> UpdateCounterItems(IList<CounterDescriptor> counterItems) { //no need to update, since we're hardcoded (& eventually configuration-based) if (counterItems.Count == 0) { //create reference to PerformanceCounter object var pc = new PerformanceCounter("Processor", "% Processor Time", "_Total", true); //read value to start counter pc.NextValue(); //setup descriptor object for central framework var result = new CpuPerformanceCounterDescriptor { Name = "CPUUtilization", SystemCounter = pc, Unit = "Percent", MetricName = "CPUUtilization" }; counterItems.Add(result); } return counterItems; }
public IList <CounterDescriptor> UpdateCounterItems(IList <CounterDescriptor> counterItems) { //no need to update, since we're hardcoded (& eventually configuration-based) if (counterItems.Count == 0) { //create reference to PerformanceCounter object var pc = new PerformanceCounter("Processor", "% Processor Time", "_Total", true); //read value to start counter pc.NextValue(); //setup descriptor object for central framework var result = new CpuPerformanceCounterDescriptor { Name = "CPUUtilization", SystemCounter = pc, Unit = "Percent", MetricName = "CPUUtilization" }; counterItems.Add(result); } return(counterItems); }