Exemplo n.º 1
0
 public CpuMetricsController(
     ILogger <CpuMetricsController> logger,
     ICpuMetricRepository cpuRepository
     )
     : base(logger, cpuRepository)
 {
 }
 public MetricJob(
     ICpuMetricRepository cpuRepository,
     IHddMetricRepository hddRepository,
     IRamMetricRepository ramRepository,
     INetworkMetricRepository networkRepository,
     IDotnetMetricRepository dotnetRepository,
     IAgentRepository agentRepository,
     IMetricsAgentClient metricsAgentClient
     )
 {
     _cpuRepository      = cpuRepository;
     _hddRepository      = hddRepository;
     _ramRepository      = ramRepository;
     _networkRepository  = networkRepository;
     _dotnetRepository   = dotnetRepository;
     _agentRepository    = agentRepository;
     _metricsAgentClient = metricsAgentClient;
 }
 public QuartzHostedService(
     ICpuMetricRepository cpuRepository,
     IRamMetricRepository ramRepository,
     IHddMetricRepository hddRepository,
     INetworkMetricRepository networkRepository,
     IDotnetMetricRepository dotnetRepository,
     ISchedulerFactory schedulerFactory,
     IJobFactory jobFactory,
     IEnumerable <JobSchedule> jobSchedules)
 {
     _cpuRepository     = cpuRepository;
     _ramRepository     = ramRepository;
     _hddRepository     = hddRepository;
     _networkRepository = networkRepository;
     _dotnetRepository  = dotnetRepository;
     _schedulerFactory  = schedulerFactory;
     _jobSchedules      = jobSchedules;
     _jobFactory        = jobFactory;
 }
        private void SaveCpuMetrics(AllMetricsApiResponseModel allMetrics, ICpuMetricRepository repository)
        {
            //foreach (var metric in allMetrics.Metrics)
            //{
            //    repository.AddAsync(new CpuMetricEntity()
            //    {
            //        AgentId = metric.AgentId,
            //        Time = new DateTimeOffset(metric.Time).ToUnixTimeSeconds()
            //    });
            //}
            var entities = allMetrics.Metrics.Select(x => new CpuMetricEntity()
            {
                AgentId = x.AgentId,
                Time    = new DateTimeOffset(x.Time, TimeSpan.FromSeconds(0)).ToUnixTimeSeconds()
            }).ToList();

            if (entities.Count > 0)
            {
                repository.AddRangeAsync(entities);
            }
        }