예제 #1
0
        /// <summary>
        /// Retrieve the fullpage monitors
        /// </summary>
        /// <param name="apiKey"></param>
        /// <param name="client"></param>
        /// <param name="showMonitors"></param>
        public void GetFullpageMonitors(string apiKey, HttpClient client, List <string> argMonitors)
        {
            using (HttpResponseMessage response = client.Get("api?version=2&apikey=" + apiKey + "&output=xml&action=topFullpage&limit=50&detailedResults=true"))
            {
                response.EnsureStatusIsSuccessful();

                String    data = response.Content.ReadAsString();
                XDocument xml  = XDocument.Parse(data);

                // copy the list of monitors from the command line
                List <string> showMonitors = new List <string>(argMonitors);

                // check if the list of monitors to show is 'all' or 'empty'
                if (showMonitors.Count == 0)
                {
                    foreach (MonitorDefinition md in FullpageMonitor.GetMonitorDefinitions())
                    {
                        showMonitors.Add(md.Metric);
                    }
                }


                // filter the monitors from the returned XML
                var allMonitors = from monitorNode in xml.Descendants("test")
                                  select new
                {
                    Id   = monitorNode.Element("id").Value,
                    Name = monitorNode.Element("testName").Value
                };

                // create all the monitor objects and copy in the values from the XML results
                foreach (var a in allMonitors)
                {
                    foreach (string m in showMonitors)
                    {
                        if (a.Name.ToLower().Contains(m.ToLower()) || m.ToLower() == "all")
                        {
                            Monitor monitor = new FullpageMonitor(this);
                            monitor.Id   = a.Id;
                            monitor.Name = a.Name;
                            monitor.GetMetrics(apiKey, client);
                            this.AddMonitor(monitor);
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Retrieve the fullpage monitors
        /// </summary>
        /// <param name="apiKey"></param>
        /// <param name="client"></param>
        /// <param name="showMonitors"></param>
        public void GetFullpageMonitors(string apiKey, HttpClient client, List<string> argMonitors)
        {
            using (HttpResponseMessage response = client.Get("api?version=2&apikey=" + apiKey + "&output=xml&action=topFullpage&limit=50&detailedResults=true"))
            {
                response.EnsureStatusIsSuccessful();

                String data = response.Content.ReadAsString();
                XDocument xml = XDocument.Parse(data);

                // copy the list of monitors from the command line
                List<string> showMonitors = new List<string>(argMonitors);

                // check if the list of monitors to show is 'all' or 'empty'
                if (showMonitors.Count == 0)
                {
                    foreach (MonitorDefinition md in FullpageMonitor.GetMonitorDefinitions())
                        showMonitors.Add(md.Metric);
                }

                // filter the monitors from the returned XML
                var allMonitors = from monitorNode in xml.Descendants("test")
                                  select new
                                  {
                                      Id = monitorNode.Element("id").Value,
                                      Name = monitorNode.Element("testName").Value
                                  };

                // create all the monitor objects and copy in the values from the XML results
                foreach (var a in allMonitors)
                {
                    foreach (string m in showMonitors)
                    {
                        if (a.Name.ToLower().Contains(m.ToLower()) || m.ToLower() == "all")
                        {
                            Monitor monitor = new FullpageMonitor(this);
                            monitor.Id = a.Id;
                            monitor.Name = a.Name;
                            monitor.GetMetrics(apiKey, client);
                            this.AddMonitor(monitor);
                        }
                    }
                }
            }
        }