/// <summary> /// Retrieve the process monitors /// </summary> /// <param name="apiKey"></param> /// <param name="client"></param> /// <param name="showMonitors"></param> public void GetProcessMonitors(string apiKey, HttpClient client, List<string> showProcesses) { using (HttpResponseMessage response = client.Get("api?action=agentInfo&apikey=" + apiKey + "&output=xml&agentId=" + this.Id + "&loadTests=true")) { response.EnsureStatusIsSuccessful(); String data = response.Content.ReadAsString(); XDocument xml = XDocument.Parse(data); // select all process monitors var allMonitors = from monitorNode in xml.Descendants("process") select new { Id = monitorNode.Element("id").Value, Name = monitorNode.Element("processName").Value }; // filter the process monitors based on the name and create // the monitor objects and fill in the values foreach (var a in allMonitors) { foreach (string m in showProcesses) { if (a.Name.ToLower().Contains(m.ToLower()) || m.ToLower() == "all") { Monitor monitor = new ProcessMonitor(this); monitor.Id = a.Id; monitor.Name = a.Name; monitor.GetMetrics(apiKey, client); this.AddMonitor(monitor); } } } } }