Example #1
0
        /// <summary>
        /// 查询主机配置数据
        /// </summary>
        public async Task <ShowEventDataResponse> ShowEventDataAsync(ShowEventDataRequest showEventDataRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();
            string              urlPath          = HttpUtils.AddUrlPath("/V1.0/{project_id}/event-data", urlParam);
            SdkRequest          request          = HttpUtils.InitSdkRequest(urlPath, showEventDataRequest);
            HttpResponseMessage response         = await DoHttpRequestAsync("GET", request);

            return(JsonUtils.DeSerialize <ShowEventDataResponse>(response));
        }
        /// <summary>
        /// 查询指定时间范围指定事件类型的主机配置数据,可以通过参数指定需要查询的数据维度。
        /// 注意:该接口提供给HANA场景下SAP Monitor查询主机配置数据,其他场景下查不到主机配置数据。
        /// </summary>
        /// <param name="cesV1Client"></param>
        private static void ShowEventData(CesClient cesClient)
        {
            ShowEventDataRequest showEventDataRequest = new ShowEventDataRequest()
            {
                Namespace = "SYS.ECS",
                Dim0      = "instance_id,22d98f6c-16d2-4c2d-b424-50e79d82838f",
                //Dim1 = "",
                //Dim2 = "",
                Type = "instance_host_info",
                From = 1587014357000,
                To   = 1587017957000,
            };

            try
            {
                ShowEventDataResponse showEventDataResponse = cesClient.ShowEventData(showEventDataRequest);
                foreach (var eventDataInfo in showEventDataResponse.Datapoints)
                {
                    Console.WriteLine(eventDataInfo.ToString());
                }
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }