예제 #1
0
        public AllHddMetricsApiResponse GetAllHddMetrics(GetAllHddMetricsApiRequest request)
        {
            var fromParameter = request.FromTime.ToString("s") + "Z";
            var toParameter   = request.ToTime.ToString("s") + "Z";
            var httpRequest   = new HttpRequestMessage(HttpMethod.Get, $"{request.ClientBaseAddress}/api/metrics/hdd/from/{fromParameter}/to/{toParameter}");

            try
            {
                HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result;

                string jsonString = response.Content.ReadAsStringAsync()
                                    .Result
                                    .Replace("\\", "")
                                    .Trim(new char[1] {
                    '"'
                });

                var allHddMetricsApiResponse = JsonConvert.DeserializeObject <AllHddMetricsApiResponse>(jsonString);

                return(allHddMetricsApiResponse);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #2
0
        public AllHddMetricsApiResponse GetHddMetrics(GetAllHddMetricsApiRequest request)
        {
            string content = GetMetricsApiResponseString(request, Strings.TableNames[(int)Enums.MetricsNames.Hdd]);

            if (content != null)
            {
                return(JsonConvert.DeserializeObject <AllHddMetricsApiResponse>(content));
            }
            else
            {
                _logger.LogError("null content");
                return(null);
            }
        }
예제 #3
0
        public AllHddMetricsApiResponse GetHddMetrics(GetAllHddMetricsApiRequest request)
        {
            var fromParameter = request.FromTime.ToString("yyyy-MM-dd HH:mm:ss");
            var toParameter   = request.ToTime.ToString("yyyy-MM-dd HH:mm:ss");
            var httpRequest   = new HttpRequestMessage(HttpMethod.Get, $"{request.ClientBaseAddress.TrimEnd('/')}/api/metrics/hdd/left/from/{fromParameter}/to/{toParameter}");

            try
            {
                HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result;
                using var responseStream = response.Content.ReadAsStreamAsync().Result;
                return(JsonSerializer.DeserializeAsync <AllHddMetricsApiResponse>(responseStream).Result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }
            return(null);
        }
        public AllHddMetricsApiResponse GetAllHddMetrics(GetAllHddMetricsApiRequest request)
        {
            var fromParameter = request.FromTime.ToUnixTimeSeconds();
            var toParameter   = request.ToTime.ToUnixTimeSeconds();
            var httpRequest   = new HttpRequestMessage(HttpMethod.Get, $"{request.AgentUrl}/api/hddmetrics/from/{fromParameter}/to/{toParameter}");

            try
            {
                HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result;

                using var responseStream = response.Content.ReadAsStreamAsync().Result;
                return(JsonSerializer.DeserializeAsync <AllHddMetricsApiResponse>(responseStream).Result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }

            return(null);
        }
예제 #5
0
        public AllHddMetricsApiResponse GetAllHddMetrics(GetAllHddMetricsApiRequest request)
        {
            var fromParameter = request.FromTime.UtcDateTime.ToString("O");
            var toParameter   = request.ToTime.UtcDateTime.ToString("O");
            var uri           = request.ClientBaseAddress;
            var httpRequest   = new HttpRequestMessage(HttpMethod.Get, $"{uri}api/metrics/hdd/from/{fromParameter}/to/{toParameter}");

            try
            {
                HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result;
                using var responseStream = response.Content.ReadAsStreamAsync().Result;
                using var streamReader   = new StreamReader(responseStream);
                var content = streamReader.ReadToEnd();
                return(JsonConvert.DeserializeObject <AllHddMetricsApiResponse>(content));
            }
            catch (Exception ex)
            {
                _loggerHdd.LogError(ex.Message);
                return(null);
            }
        }
예제 #6
0
        public AllHddMetricApiResponse GetAllHddMetrics(GetAllHddMetricsApiRequest request)
        {
            var fromParameter = request.FromTime.ToString("O");
            var toParameter   = request.ToTime.ToString("O");
            var httpRequest   = new HttpRequestMessage(HttpMethod.Get, $"{request.ClientBaseAddress}/api/metrics/hdd/left/from/{fromParameter}/to/{toParameter}");

            try
            {
                HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result;

                using var responseStream = response.Content.ReadAsStreamAsync().Result;
                return(JsonSerializer.DeserializeAsync <AllHddMetricApiResponse>(responseStream, new JsonSerializerOptions {
                    PropertyNameCaseInsensitive = true
                }).Result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }

            return(null);
        }
예제 #7
0
        public AllHddMetricsApiResponse GetAllHddMetrics(GetAllHddMetricsApiRequest request)
        {
            var httpRequest = new HttpRequestMessage(HttpMethod.Get,
                                                     $"{request.Addres}/api/metrics/hdd/from/{request.FromTime:o}/to/{request.ToTime:o}");

            try
            {
                HttpResponseMessage response = _httpClient.SendAsync(httpRequest).Result;
                using var responseStream = response.Content.ReadAsStreamAsync().Result;
                using var streamReader   = new StreamReader(responseStream);
                var content = streamReader.ReadToEnd();
                var result  = JsonSerializer.Deserialize <AllHddMetricsApiResponse>(content, new JsonSerializerOptions()
                {
                    PropertyNameCaseInsensitive = true
                });
                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }
            return(null);
        }