public List <ZabHostSslStatus> GetSsl(int hoursBack, IEnumerable <string> itemIds) { if (zabbix.loggedOn == false) { return(null); } var data = ReadSslData(hoursBack, itemIds); if (data == null) { return(null); } List <ZabHostSslStatus> ret = new List <ZabHostSslStatus>(); DateTime now = DateTime.Now; foreach (var host in data.Select(m => m.itemId).Distinct().Select(m => ZabTools.Weby().First(h => h.itemIdSsl == m))) { var hint = data.Where(h => h.itemId == host.itemIdSsl).ToArray(); var last = hint.OrderByDescending(h => h.clock).FirstOrDefault(); if (last != null) { ZabHostSslStatus.EndpointStatus[] statuses = Newtonsoft.Json.JsonConvert.DeserializeObject <ZabHostSslStatus.EndpointStatus[]>(last.svalue); statuses = statuses .Where(m => { System.Net.IPAddress ip; if (System.Net.IPAddress.TryParse(m.ipAddress, out ip)) { return(ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork); } else { return(false); } }) .ToArray(); ret.Add(new ZabHostSslStatus(host, statuses, last.clock)); } } return(ret); }
public List <ZabHostAvailability_PerMin> GetAvailability_PerMin(int hoursBack, IEnumerable <string> itemIds) { if (zabbix.loggedOn == false) { return(null); } var data = ReadWebResponseDataHistory(hoursBack, itemIds); if (data == null) { return(null); } List <ZabHostAvailability_PerMin> ret = new List <ZabHostAvailability_PerMin>(); DateTime now = DateTime.Now; foreach (var host in data.Select(m => m.itemId).Distinct().Select(m => ZabTools.Weby().First(h => h.itemIdResponseTime == m))) { var hint = data.Where(h => h.itemId == host.itemIdResponseTime).ToArray(); ret.Add(new ZabHostAvailability_PerMin(host, hint)); } return(ret); }
public List <ZabHostAvailability> GetAvailability_Raw(int hoursBack, IEnumerable <ZabHost> hosts, bool fillMissingWithNull = false) { if (zabbix.loggedOn == false) { return(null); } var dataResponseTime = ReadWebResponseDataHistory(hoursBack, hosts.Select(m => m.itemIdResponseTime) .Where(m => !string.IsNullOrEmpty(m)) ); if (dataResponseTime == null) { return(null); } List <ZabHostAvailability> ret = new List <ZabHostAvailability>(); DateTime now = DateTime.Now; foreach (var host in dataResponseTime.Select(m => m.itemId).Distinct().Select(m => ZabTools.Weby().First(h => h.itemIdResponseTime == m))) { var hint = dataResponseTime.Where(h => h.itemId == host.itemIdResponseTime).OrderBy(m => m.clock).ToArray(); ret.Add(new ZabHostAvailability(host, hint, fillMissingWithNull)); } var dataResponseCode = ReadWebResponseDataHistory(hoursBack, hosts.Select(m => m.itemIdResponseCode) .Where(m => !string.IsNullOrEmpty(m)) , 3); foreach (var host in dataResponseCode.Select(m => m.itemId).Distinct().Select(m => ZabTools.Weby().First(h => h.itemIdResponseCode == m))) { var hint = dataResponseCode.Where(h => h.itemId == host.itemIdResponseCode).ToArray(); //ret.Add(new ZabHostAvailability(host, hint, fillMissingWithNull)); var foundHost = ret.Where(m => m.Host.hostid == host.hostid).FirstOrDefault(); if (foundHost != null) { //merge status code with response time data foreach (var status in hint) { var foundHistoryItem = foundHost.Data.Where(m => Math.Abs((m.Time - status.clock).TotalSeconds) < 15).FirstOrDefault(); if (foundHistoryItem != null) { int httpstatus = (int)status.value; foundHistoryItem.HttpStatusCode = httpstatus; if (httpstatus > 399) { foundHistoryItem.Response = ZabAvailability.BadHttpCode; } } } } } return(ret); }