Ejemplo n.º 1
0
        public Task Execute(IJobExecutionContext context)
        {
            IList <Agents> _agents = _agentsRepository.GetAgents();

            foreach (var agent in _agents)
            {
                var fromTime = _repository.GetLastDate(agent.AgentId);
                var toTime   = DateTimeOffset.Now;

                var metrics = _metricsAgentClient.GetHddMetrics(new GetAllHddMetricsApiRequest
                {
                    FromTime          = fromTime,
                    ToTime            = toTime,
                    ClientBaseAddress = agent.AgentUrl
                });

                if (metrics != null)
                {
                    foreach (var metric in metrics)
                    {
                        _repository.Create(new HddMetric {
                            Time = metric.time.ToUnixTimeSeconds(), Value = metric.value, AgentId = agent.AgentId
                        });
                    }
                }
            }

            return(Task.CompletedTask);
        }