public override async Task <bool> InvokeAsync(string paramList) { var config = _configBusiness.LoadFiles(new string[] { }); var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray(); var index = 0; var counterGroup = QueryParam("Group", GetParam(paramList, index++), counterGroups.Select(x => new KeyValuePair <IPerformanceCounterGroup, string>(x, x.Name))); var processor = new Processor(_configBusiness, _counterBusiness, _publisherBusiness, _sendBusiness, _tagLoader); processor.EngineActionEvent += EngineActionEvent; if (counterGroup == null) { if (!processor.RunAsync(new string[] { }).Wait(5000)) { throw new InvalidOperationException("Unable to start processor engine."); } } else { var counterGroupsToRead = new[] { counterGroup }; await processor.RunAsync(counterGroupsToRead, null, config.Application.Metadata); } return(true); }
public async override Task <bool> InvokeAsync(string paramList) { var config = _configBusiness.LoadFiles(new string[] { }); var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray(); var cnt = 0; foreach (var counterGroup in counterGroups) { OutputInformation("{0}", counterGroup.Name); foreach (var counter in counterGroup.GetFreshCounters()) { if (counter.PerformanceCounter != null) { OutputInformation(" OK\t{0}.{1}.{2} {3}", counter.PerformanceCounter.CategoryName, counter.PerformanceCounter.CounterName, counter.PerformanceCounter.InstanceName, counter.Name); cnt++; } else { var name = counter.Name; if (string.IsNullOrEmpty(name)) { name = "N/A"; } OutputWarning(" -\t{0}", name); } } } OutputInformation("Totally {0} counters that will be executed by the service.", cnt); return(true); }
private void TestNewCounterGroup(string counterGroupName) { var config = _configBusiness.LoadFiles(new string[] { }); var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray(); var counterGroup = counterGroups.Single(x => x.Name == counterGroupName); ReadCounterGroup(counterGroup); }
public async Task RunAsync(string[] configFileNames) { var config = _configBusiness.LoadFiles(configFileNames); var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray(); var counterPublishers = _publisherBusiness.GetCounterPublishers(config).ToArray(); await RunAsync(counterGroups, counterPublishers, config.Application.Metadata); }
public override async Task <bool> InvokeAsync(string paramList) { var config = _configBusiness.LoadFiles(new string[] { }); var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray(); var index = 0; var counterGroup = QueryParam("Group", GetParam(paramList, index++), counterGroups.Select(x => new KeyValuePair <IPerformanceCounterGroup, string>(x, x.Name))); ReadCounterGroup(counterGroup); return(true); }
public override async Task <bool> InvokeAsync(string paramList) { var config = _configBusiness.LoadFiles(new string[] { }); var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray(); var index = 0; var counterGroup = QueryParam("Group", GetParam(paramList, index++), counterGroups.Select(x => new KeyValuePair <IPerformanceCounterGroup, string>(x, x.Name))); using (var oneTimeDryRunCollectorEngine = new SafeCollectorEngine(counterGroup, new ConsoleSendBusiness(_configBusiness, new InfluxDbAgentLoader(), ShowOutput), new TagLoader(_configBusiness), config.Application.Metadata)) { oneTimeDryRunCollectorEngine.CollectRegisterCounterValuesEvent += CollectRegisterCounterValuesEvent; await oneTimeDryRunCollectorEngine.CollectRegisterCounterValuesAsync(); } return(true); }
private Tuple <string, OutputLevel> CreateFile(string name, CounterGroup counterGroup) { var config = _configBusiness.LoadFiles(new string[] { }); var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray(); if (counterGroups.Any(x => x.Name == counterGroup.Name)) { return(new Tuple <string, OutputLevel>(string.Format("There is already a counter group named {0}.", counterGroup.Name), OutputLevel.Error)); } if (!_configBusiness.CreateConfig(name + ".xml", new List <ICounterGroup> { counterGroup })) { return(new Tuple <string, OutputLevel>(string.Format("Did not create {0}, the file {0}.xml" + " already exists.", name), OutputLevel.Error)); } return(new Tuple <string, OutputLevel>(string.Format("Created counter config {0}.", name), OutputLevel.Information)); }
public async override Task <bool> InvokeAsync(string paramList) { var config = _configBusiness.LoadFiles(new string[] { }); var counterGroups = _counterBusiness.GetPerformanceCounterGroups(config).ToArray(); var index = 0; var counterGroup = QueryParam("Group", GetParam(paramList, index++), counterGroups.Select(x => new KeyValuePair <IPerformanceCounterGroup, string>(x, x.Name))); var counterGroupsToRead = counterGroup != null ? new[] { counterGroup } : counterGroups; var processor = new Processor(_configBusiness, _counterBusiness, _publisherBusiness, _sendBusiness, _tagLoader); processor.EngineActionEvent += EngineActionEvent; var count = 0; foreach (var cg in counterGroupsToRead) { count += await processor.CollectAssync(cg, config.Application.Metadata); } //OutputInformation("Totally {0} metrics points where collected and sent to the database.", count); return(true); }