Ejemplo n.º 1
0
        public Task Execute(IJobExecutionContext context)
        {
            var agentList = _repositoryAgent.GetAllAgents();

            foreach (var agent in agentList)
            {
                string agentAddress = _repositoryAgent.GetAddressForId(agent.AgentId);

                var fromTime = _repositoryRam.GetDateTimeOfLastRecord(agent.AgentId);
                var toTime   = DateTimeOffset.UtcNow;

                var metrics = _metricsAgentClient.GetRamMetrics(new GetAllRamMetricsApiRequest()
                {
                    FromTime          = fromTime,
                    ToTime            = toTime,
                    ClientBaseAddress = agentAddress
                });

                if (metrics != null)
                {
                    foreach (var metricFromAgent in metrics.Metrics)
                    {
                        _repositoryRam.Create(agent.AgentId, metricFromAgent);
                    }
                }
            }
            return(Task.CompletedTask);
        }