private void InitPerformanceCounter(PerformanceCounterInitData data) { PerformanceCounter pc; ExceptionHelper.FalseThrow <ArgumentNullException>(data != null, "data"); ExceptionHelper.CheckStringIsNullOrEmpty(data.CategoryName, "CategoryName"); ExceptionHelper.CheckStringIsNullOrEmpty(data.CounterName, "CounterName"); try { if (string.IsNullOrEmpty(data.MachineName)) { pc = new PerformanceCounter(data.CategoryName, data.CounterName, data.InstanceName, data.Readonly); } else { pc = new PerformanceCounter(data.CategoryName, data.CounterName, data.InstanceName, data.MachineName); } this.counter = pc; } catch (System.Exception) { } }
private void InitCountersFromInstaller(PerformanceCounterInstaller installer, string instanceName) { installer.NullCheck("installer"); PerformanceCounterInitData initData = new PerformanceCounterInitData(installer.CategoryName, string.Empty, instanceName); foreach (CounterCreationData counter in installer.Counters) { initData.CounterName = counter.CounterName; this.counters[initData.CounterName] = new PerformanceCounterWrapper(initData); } }
private void InitCountersFromAttribute(string instanceName) { PerformanceCounterDescriptionAttribute attribute = AttributeHelper.GetCustomAttribute <PerformanceCounterDescriptionAttribute>(this.GetType()); if (attribute != null && attribute.CategoryName.IsNotEmpty() && attribute.CounterNames.IsNotEmpty()) { PerformanceCounterInitData initData = new PerformanceCounterInitData(attribute.CategoryName, string.Empty, instanceName); string[] counterNames = attribute.CounterNames.Split(','); foreach (string counterName in counterNames) { initData.CounterName = counterName; this.counters[counterName] = new PerformanceCounterWrapper(initData); } } }
/// <summary> /// 构造方法 /// </summary> /// <param name="data">性能计数器的初始化参数</param> public PerformanceCounterWrapper(PerformanceCounterInitData data) { InitPerformanceCounter(data); }
private void InitPerformanceCounter(PerformanceCounterInitData data) { PerformanceCounter pc; ExceptionHelper.FalseThrow<ArgumentNullException>(data != null, "data"); ExceptionHelper.CheckStringIsNullOrEmpty(data.CategoryName, "CategoryName"); ExceptionHelper.CheckStringIsNullOrEmpty(data.CounterName, "CounterName"); try { if (string.IsNullOrEmpty(data.MachineName)) pc = new PerformanceCounter(data.CategoryName, data.CounterName, data.InstanceName, data.Readonly); else pc = new PerformanceCounter(data.CategoryName, data.CounterName, data.InstanceName, data.MachineName); this.counter = pc; } catch (System.Exception) { } }
private void InitCounters(string instanceName) { PerformanceCounterInitData data = new PerformanceCounterInitData( "MCSLibraryPageCounters", "Page access count", instanceName); this.pageAccessCount = new PerformanceCounterWrapper(data); data.CounterName = "Page access error count"; this.pageErrorCount = new PerformanceCounterWrapper(data); data.CounterName = "Page access success count"; this.pageSuccessCount = new PerformanceCounterWrapper(data); data.CounterName = "Page access success ratio"; this.pageSuccessRatio = new PerformanceCounterWrapper(data); data.CounterName = "Page access success ratio base"; this.pageSuccessRatioBase = new PerformanceCounterWrapper(data); data.CounterName = "Page access current average"; this.pageAccessCurrentAverage = new PerformanceCounterWrapper(data); data.CounterName = "Page access current average base"; this.pageAccessCurrentAverageBase = new PerformanceCounterWrapper(data); data.CounterName = "Page access total average(ms)"; this.pageAccessTotalAverage = new PerformanceCounterWrapper(data); data.CounterName = "Page access total average base"; this.pageAccessTotalAverageBase = new PerformanceCounterWrapper(data); data.CounterName = "Page access count per second"; this.pageAccessCountPerSecond = new PerformanceCounterWrapper(data); }
private void InitCounters(string instanceName) { PerformanceCounterInitData data = new PerformanceCounterInitData( "MCSWorkflow", "WF Count", instanceName); this.totalWFCount = new PerformanceCounterWrapper(data); data.CounterName = "WF fail count"; this.failWFCount = new PerformanceCounterWrapper(data); data.CounterName = "WF success count"; this.successWFCount = new PerformanceCounterWrapper(data); data.CounterName = "WF Average Duration(ms)"; this.averageWFDuration = new PerformanceCounterWrapper(data); data.CounterName = "WF Average Duration Base"; this.averageWFBase = new PerformanceCounterWrapper(data); data.CounterName = "WF with Tx Average duration(ms)"; this.averageWithTxWFDuration = new PerformanceCounterWrapper(data); data.CounterName = "WF with Tx Average duration base"; this.averageWithTxWFBase = new PerformanceCounterWrapper(data); data.CounterName = "WF Move to count per second"; this.moveToCountPerSecond = new PerformanceCounterWrapper(data); }