Example #1
0
        public IActionResult Create([FromBody] HddMetricCreateRequest request)
        {
            repository.Create(new HddMetric
            {
                Left = request.Left
            });

            return(Ok());
        }
Example #2
0
        public Task Execute(IJobExecutionContext context)
        {
            var            hddUsageInPercents = Convert.ToInt32(_hddCounter.NextValue());
            DateTimeOffset time = DateTimeOffset.UtcNow;

            _repository.Create(new Models.HddMetrics {
                Time = time, Value = hddUsageInPercents
            });
            return(Task.CompletedTask);
        }
 public IActionResult Create([FromBody] HddMetricCreateRequest request)
 {
     _repository.Create(new HddMetric
     {
         Time  = request.Time,
         Value = request.Value
     });
     _logger.LogInformation($"Add item. Parameters: Time = {request.Time}, Value = {request.Value}");
     return(Ok());
 }
        public IActionResult Create([FromBody] HddMetricCreateRequest request)
        {
            repository.Create(new HddMetric
            {
                Time  = request.Time,
                Value = request.Value
            });

            return(Ok());
        }
Example #5
0
        public Task Execute(IJobExecutionContext context)
        {
            var hddLeft = Convert.ToInt32(_hddCounter.RawValue);
            var time    = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

            _repository.Create(new DAL.Models.HddMetric {
                Time = time, Value = hddLeft
            });

            return(Task.CompletedTask);
        }
        public IActionResult Create([FromBody] HddMetricsCreateRequest request)
        {
            _logger.LogInformation($"Метод Create {request}");
            _repository.Create(new HddMetrics
            {
                Time  = request.Time,
                Value = request.Value
            });

            return(Ok());
        }
        public Task Execute(IJobExecutionContext context)
        {
            int value = Convert.ToInt32(_counter.NextValue());
            var time  = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

            _repository.Create(new HddMetric {
                Time = time, Value = value
            });

            return(Task.CompletedTask);
        }
        public IActionResult Create([FromBody] HddMetricCreateRequest request)
        {
            _repository.Create(new HddMetric
            {
                Time  = request.Time,
                Value = request.Value
            });

            _logger.LogInformation(string.Concat("Create_HDD: ", " Time: ", request.Time.ToString(), " Value: ", request.Value.ToString()));

            return(Ok());
        }
Example #9
0
        public Task Execute(IJobExecutionContext context)
        {
            var hddFreeSpaceInMBytes = Convert.ToInt32(_hddCounter.NextValue());
            //var time = TimeSpan.FromSeconds(DateTimeOffset.UtcNow.ToUnixTimeSeconds());
            var time = DateTimeOffset.UtcNow;

            _repository.Create(new HddMetric {
                Time = time, Value = hddFreeSpaceInMBytes
            });

            return(Task.CompletedTask);
        }
Example #10
0
        public IActionResult Create([FromBody] HddMetricCreateRequest request)
        {
            _repository.Create(new HddMetric
            {
                Time  = request.Time,
                Value = request.Value
            });

            _logger.LogInformation($"Create - Value: {request.Value}, Time: {request.Time} - Entry added successfully");

            return(Ok());
        }
        public IActionResult Create([FromBody] HddMetricCreateRequest request)
        {
            _logger.LogInformation($"Создается запись с данными Time:{request.Time}; Value:{request.Value}");

            _repository.Create(new HddMetric
            {
                Time  = request.Time,
                Value = request.Value
            });

            return(Ok());
        }
Example #12
0
        public Task Execute(IJobExecutionContext context)
        {
            double hddFreeSpace = _hddCounter.NextValue() / 1024 / 1024;
            var    time         = DateTimeOffset.UtcNow;

            _repository.Create(new HddMetricModel()
            {
                Time     = time,
                FreeSize = hddFreeSpace
            });
            return(Task.CompletedTask);
        }
Example #13
0
        public Task Execute(IJobExecutionContext context)
        {
            _logger.LogDebug("== HddMetricJob START - " +
                             $"Time {DateTimeOffset.UtcNow}");
            //Получаем из репозитория агентов список всех агентов
            var allAgentsInfo = _agentsRepository.GetAllAgentsInfo();

            //Обрабатываем каждого агента в списке
            foreach (var agentInfo in allAgentsInfo.Agents)
            {
                //Временная метка, когда для текущего агента была снята последняя метрика
                var lastTime = _repository.GetLast(agentInfo.AgentId);

                // Создаем запрос для получения от текущего агента метрик за период времени
                // от последней проверки до текущего момента
                var request = new HddMetricGetByIntervalRequestByClient()
                {
                    AgentUri = agentInfo.AgentUri,
                    FromTime = lastTime,
                    ToTime   = DateTimeOffset.UtcNow,
                };

                // Делаем запрос к Агенту метрик и получаем список метрик
                var response = _client.GetMetrics <HddMetricFromAgentDto>(request, ApiNames.Hdd);

                if (response != null)
                {
                    // Убираем из выборки первую метрику если она совпадает с последней сохраненной в базе
                    // для исключения дублирования данных в базе
                    if (response.Metrics[0].Time == lastTime)
                    {
                        response.Metrics.RemoveAt(0);
                    }

                    // Перекладываем данные из Response в модели метрик
                    var recievedMetrics = new AllMetrics <HddMetric>();
                    foreach (var metricDto in response.Metrics)
                    {
                        recievedMetrics.Metrics.Add(new HddMetric
                        {
                            AgentId = agentInfo.AgentId,
                            Time    = metricDto.Time,
                            Value   = metricDto.Value
                        });
                    }
                    _repository.Create(recievedMetrics);
                }
            }
            _logger.LogDebug("!= HddMetricJob END - " +
                             $"Time {DateTimeOffset.UtcNow}");
            return(Task.CompletedTask);
        }
Example #14
0
        public Task Execute(IJobExecutionContext context)
        {
            var disc  = DriveInfo.GetDrives().First();
            var value = disc.AvailableFreeSpace;

            var time = DateTimeOffset.UtcNow;

            _repository.Create(new HddSpaceMetric {
                Time = time, Value = value
            });

            return(Task.CompletedTask);
        }
Example #15
0
        public Task Execute(IJobExecutionContext context)
        {
            var diskTime = Convert.ToInt32(_hddCounter.NextValue());

            _repository.Create(new HddMetric
            {
                Time  = DateTimeOffset.Now,
                Value = diskTime
            });

            _logger.LogDebug("Disk Time {0}% by {1}", diskTime, DateTimeOffset.Now);

            return(Task.CompletedTask);
        }
        public Task Execute(IJobExecutionContext context)
        {
            var hddFreeInPercents = Convert.ToInt32(_HddCounter.NextValue());

            // узнаем когда мы сняли значение метрики.
            var time = DateTimeOffset.UtcNow;

            // теперь можно записать что-то при помощи репозитория

            _repository.Create(new HddMetric {
                Time = time, Value = hddFreeInPercents
            });

            return(Task.CompletedTask);
        }
Example #17
0
        public Task Execute(IJobExecutionContext context)
        {
            // Складываем характеристики всех экземпляров счетчиков
            int value = Convert.ToInt32(_counter.NextValue());

            // Время когда была собрана метрика
            var time = DateTimeOffset.UtcNow;

            // Запись метрики в репозиторий
            _repository.Create(new HddMetric {
                Time = time, Value = value
            });

            return(Task.CompletedTask);
        }
 public IActionResult Create([FromBody] HddMetricCreateRequest metric)
 {
     try
     {
         _logger.Debug($"Route(api/metrics/hdd): Running the Create method");
         _repository.Create(_mapper.Map <HddMetric>(metric));
         _logger.Debug($"Route(api/metrics/hdd): Create method completed successfully");
         return(Ok());
     }
     catch (Exception e)
     {
         _logger.Error(e);
         return(BadRequest(e.Message));
     }
 }
Example #19
0
 public Task Execute(IJobExecutionContext context)
 {
     try
     {
         var hddFreeSpace = Convert.ToInt32(_hddCounter.NextValue());
         var time         = DateTimeOffset.Now.ToUnixTimeSeconds();
         _repository.Create(new HddMetric()
         {
             Time = time, Value = hddFreeSpace
         });
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
     }
     return(Task.CompletedTask);
 }
Example #20
0
        public Task Execute(IJobExecutionContext context)
        {
            var adress = new AdressAgentFormTable();
            List <AgentInfo> uriAdress = adress.GetAllAdress();

            foreach (var adressAgent in uriAdress)
            {
                var fromTimeTable     = new LastDate();
                var fromTimeFromTable = fromTimeTable.GetTimeFromTable("hddmetrics", adressAgent.AgentId);
                AllHddMetricsApiResponse hddMetrics = null;

                if (fromTimeFromTable == null)
                {
                    DateTimeOffset fromTime = DateTimeOffset.UnixEpoch;
                    DateTimeOffset toTime   = DateTimeOffset.UtcNow;
                    hddMetrics = _metricsAgent.GetAllHddMetrics(new Requests.GetAllHddMetricsApiRequest {
                        ClientBaseAddress = new Uri(adressAgent.AgentAddress), ToTime = toTime, FromTime = fromTime
                    });
                }
                else
                {
                    DateTimeOffset toTime = DateTimeOffset.UtcNow;
                    hddMetrics = _metricsAgent.GetAllHddMetrics(new Requests.GetAllHddMetricsApiRequest {
                        ClientBaseAddress = new Uri(adressAgent.AgentAddress), ToTime = toTime, FromTime = fromTimeFromTable
                    });
                }
                if (hddMetrics != null)
                {
                    foreach (var item in hddMetrics.Metrics)
                    {
                        _repository.Create(new HddMetrics
                        {
                            AgentId = adressAgent.AgentId,
                            Time    = item.Time,
                            Value   = item.Value
                        });
                    }
                }
            }
            return(Task.CompletedTask);
        }
Example #21
0
 public Task Execute(IJobExecutionContext context)
 {
     try
     {
         var agents = _agentsRepository.GetAgentsList();
         for (int i = 0; i < agents.Count(); i++)
         {
             if (agents[i].Enabled)
             {
                 long           lastTime = _repository.GetLastTime(i);
                 DateTimeOffset fromTime = DateTimeOffset.FromUnixTimeSeconds(lastTime);
                 var            metrics  = _client.GetHddMetrics(new GetAllHddMetricsApiRequest()
                 {
                     AgentAddress = agents[i].AgentAddress,
                     FromTime     = fromTime,
                     ToTime       = DateTimeOffset.Now
                 });
                 if (metrics != null)
                 {
                     foreach (var metric in metrics.Metrics)
                     {
                         _repository.Create(new HddMetric()
                         {
                             AgentId = metric.AgentId,
                             Time    = metric.Time.ToUnixTimeSeconds(),
                             Value   = metric.Value
                         });
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
     }
     return(Task.CompletedTask);
 }
        public Task Execute(IJobExecutionContext context)
        {
            var agentsList = _repositoryAgents.GetAll();

            foreach (var agent in agentsList)
            {
                var metricsList = _metricsAgentClient.GetAllHddMetrics(new GetAllHddMetricsApiRequest
                {
                    FromTime          = _repository.GetMaxDate(agent.AgentId),
                    ToTime            = DateTimeOffset.UtcNow,
                    ClientBaseAddress = agent.AgentURL
                });
                if (!object.ReferenceEquals(metricsList, null))
                {
                    foreach (var metric in metricsList.Metrics)
                    {
                        _repository.Create(metric, agent.AgentId);
                    }
                }
            }

            return(Task.CompletedTask);
        }
        public IActionResult Create([FromBody] HddMetricCreateRequest request)
        {
            _repository.Create(_mapper.Map <HddMetric>(request));

            return(Ok());
        }