public override async Task <bool> InvokeAsync(string paramList) { var config = _configBusiness.LoadFiles(new string[] { }); var counterGroups = _publisherBusiness.GetCounterPublishers(config).ToArray(); var index = 0; var counterPublisher = QueryParam("Counter", GetParam(paramList, index++), counterGroups.Select(x => new KeyValuePair <ICounterPublisher, string>(x, x.CounterName))); var processor = new Processor(_configBusiness, _counterBusiness, _publisherBusiness, _sendBusiness, _tagLoader); processor.EngineActionEvent += EngineActionEvent; //if (counterPublisher == null) //{ // if (!processor.RunAsync(new string[] { }).Wait(5000)) // { // throw new InvalidOperationException("Unable to start processor engine."); // } //} //else //{ var counterPublishers = new[] { counterPublisher }; await processor.RunAsync(null, counterPublishers, 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); }
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 SendBusiness(IConfigBusiness configBusiness, IQueueEvents queueEvents) { var config = configBusiness.LoadFiles(); foreach (var databaseConfig in config.Databases) { ISenderAgent senderAgent = null; try { if (databaseConfig.IsEnabled) { senderAgent = databaseConfig.GetSenderAgent(); } } catch (Exception exception) { queueEvents.OnExceptionEvent(exception); } if (senderAgent != null) { var queueSettings = new QueueSettings(config.Application.FlushSecondsInterval, false, config.Application.MaxQueueSize, config.Application.Metadata); var metaDataBusiness = new MetaDataBusiness(); _queues.Add(new Queue(senderAgent, queueEvents, metaDataBusiness, queueSettings)); } } }
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 SendBusiness(IConfigBusiness configBusiness, IInfluxDbAgentLoader influxDbAgentLoader) { var config = configBusiness.LoadFiles(); _timer = new Timer(1000 * config.Application.FlushSecondsInterval); _timer.Elapsed += Elapsed; _client = new Lazy<IInfluxDbAgent>(() => influxDbAgentLoader.GetAgent(config.Database)); }
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); }
public SendBusiness(IConfigBusiness configBusiness, IInfluxDbAgentLoader influxDbAgentLoader) { var config = configBusiness.LoadFiles(); var flushMilliSecondsInterval = 1000 * config.Application.FlushSecondsInterval; if (flushMilliSecondsInterval > 0) { _timer = new Timer(flushMilliSecondsInterval); _timer.Elapsed += Elapsed; } _dataSenders = config.Databases.Where(x => x.IsEnabled).Select(x => x.GetDataSender(influxDbAgentLoader, config.Application.MaxQueueSize)).ToList(); foreach (var dataSender in _dataSenders) { dataSender.SendCompleteEvent += OnSendBusinessEvent; } _metadata = config.Application.Metadata; }
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 SendBusiness(IConfigBusiness configBusiness, IInfluxDbAgentLoader influxDbAgentLoader) { var config = configBusiness.LoadFiles(); var flushMilliSecondsInterval = 1000 * config.Application.FlushSecondsInterval; if (flushMilliSecondsInterval > 0) { _timer = new Timer(flushMilliSecondsInterval); _timer.Elapsed += Elapsed; } _dataSenders = config.Databases.Where(x => x.IsEnabled).Select(x => x.GetDataSender(influxDbAgentLoader, config.Application.MaxQueueSize)).ToList(); foreach (var dataSender in _dataSenders) { dataSender.SendCompleteEvent += OnSendBusinessEvent; } _metadata = config.Application.Metadata; }
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); }
public ITag[] GetGlobalTags() { var result = _configBusiness.LoadFiles().Tags.ToArray(); return(result); }