public async Task <int> CollectAssync(IPerformanceCounterGroup counterGroup, bool metadata) { var engine = GetCollectorEngine(counterGroup, counterGroup.CollectorEngineType, metadata); engine.CollectRegisterCounterValuesEvent += CollectRegisterCounterValuesEvent; return(await engine.CollectRegisterCounterValuesAsync()); }
public async void RunAsync(IPerformanceCounterGroup[] counterGroups) { foreach (var counterGroup in counterGroups) { var engine = new CollectorEngine(counterGroup, _sendBusiness, _tagLoader); await engine.StartAsync(); engine.CollectRegisterCounterValuesEvent += CollectRegisterCounterValuesEvent; } }
private ICollectorEngine GetCollectorEngine(IPerformanceCounterGroup counterGroup, CollectorEngineType collectorEngineType, bool metadata) { switch (collectorEngineType) { case CollectorEngineType.Exact: return new ExactCollectorEngine(counterGroup, _sendBusiness, _tagLoader, metadata); case CollectorEngineType.Safe: return new SafeCollectorEngine(counterGroup, _sendBusiness, _tagLoader, metadata); default: throw new ArgumentOutOfRangeException(string.Format("Unknown collector engine type {0}.", collectorEngineType)); } }
public CollectorEngine(IPerformanceCounterGroup performanceCounterGroup, ISendBusiness sendBusiness, ITagLoader tagLoader) { _performanceCounterGroup = performanceCounterGroup; _sendBusiness = sendBusiness; _tags = tagLoader.GetGlobalTags().Union(_performanceCounterGroup.Tags).ToArray(); if (performanceCounterGroup.SecondsInterval > 0) { _timer = new Timer(1000 * performanceCounterGroup.SecondsInterval); _timer.Elapsed += Elapsed; } _name = _performanceCounterGroup.Name; }
private ICollectorEngine GetCollectorEngine(IPerformanceCounterGroup counterGroup, CollectorEngineType collectorEngineType, bool metadata) { switch (collectorEngineType) { case CollectorEngineType.Exact: return(new ExactCollectorEngine(counterGroup, _sendBusiness, _tagLoader, metadata)); case CollectorEngineType.Safe: return(new SafeCollectorEngine(counterGroup, _sendBusiness, _tagLoader, metadata)); default: throw new ArgumentOutOfRangeException(string.Format("Unknown collector engine type {0}.", collectorEngineType)); } }
protected CollectorEngineBase(IPerformanceCounterGroup performanceCounterGroup, ISendBusiness sendBusiness, ITagLoader tagLoader, bool metadata) { _engineName = GetType().Name; _performanceCounterGroup = performanceCounterGroup; _name = _performanceCounterGroup.Name; _sendBusiness = sendBusiness; _tags = tagLoader.GetGlobalTags().Union(_performanceCounterGroup.Tags).ToArray(); if (performanceCounterGroup.SecondsInterval > 0) { _timer = new Timer(1000 * performanceCounterGroup.SecondsInterval); _timer.Elapsed += Elapsed; } _metadata = metadata; }
protected void ReadCounterGroup(IPerformanceCounterGroup counterGroup) { var count = 0; foreach (var counter in counterGroup.PerformanceCounterInfos) { if (counter.PerformanceCounter != null) { var nextValue = counter.PerformanceCounter.NextValue(); OutputInformation("{0}.{1}.{2} {3}:\t{4}", counter.PerformanceCounter.CategoryName, counter.PerformanceCounter.CounterName, counter.PerformanceCounter.InstanceName, counter.Name, nextValue); count++; } else { OutputWarning("Cannot read counter {0}.", counter.Name); } } OutputInformation("{0} counters read.", count); }
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); }
public async Task RunAsync(IPerformanceCounterGroup[] counterGroups, ICounterPublisher[] counterPublishers, bool metadata) { if (counterGroups != null) { foreach (var counterGroup in counterGroups) { var engine = GetCollectorEngine(counterGroup, counterGroup.CollectorEngineType, metadata); engine.CollectRegisterCounterValuesEvent += CollectRegisterCounterValuesEvent; await engine.StartAsync(); } } if (counterPublishers != null) { foreach (var counterPublisher in counterPublishers) { var engine = GetPublisherEngine(counterPublisher); engine.PublishRegisterCounterValuesEvent += PublishRegisterCounterValuesEvent; await engine.StartAsync(); } } }
public SafeCollectorEngine(IPerformanceCounterGroup performanceCounterGroup, ISendBusiness sendBusiness, ITagLoader tagLoader, bool metadata) : base(performanceCounterGroup, sendBusiness, tagLoader, metadata) { }
public async Task<int> CollectAssync(IPerformanceCounterGroup counterGroup, bool metadata) { var engine = GetCollectorEngine(counterGroup, counterGroup.CollectorEngineType, metadata); engine.CollectRegisterCounterValuesEvent += CollectRegisterCounterValuesEvent; return await engine.CollectRegisterCounterValuesAsync(); }
public async Task<int> CollectAssync(IPerformanceCounterGroup counterGroup) { var engine = new CollectorEngine(counterGroup, _sendBusiness, _tagLoader); engine.CollectRegisterCounterValuesEvent += CollectRegisterCounterValuesEvent; return await engine.CollectRegisterCounterValuesAsync(); }
public ExactCollectorEngine(IPerformanceCounterGroup performanceCounterGroup, ISendBusiness sendBusiness, ITagLoader tagLoader, bool metadata) : base(performanceCounterGroup, sendBusiness, tagLoader, metadata) { _metaDataBusiness = new MetaDataBusiness(); }