diff --git a/SkyScanner.cs b/SkyScanner.cs index d1f488a..46eb743 100644 --- a/SkyScanner.cs +++ b/SkyScanner.cs @@ -1,14 +1,7 @@ using System; using ln.logging; -using ln.http; -using System.Net; -using ln.skyscanner.http; using System.IO; using ln.types.threads; -using ln.skyscanner.checks; -using ln.skyscanner.import.skytron; -using System.Linq; -using ln.skyscanner.entities; using ln.types.net; using ln.application; using ln.application.service; @@ -114,23 +107,19 @@ namespace ln.skyscanner public override void ServiceMain(IApplicationInterface applicationInterface) { - String BasePath = "."; - - Resource rootResource = applicationInterface.HTTPApplication.RootResource; - String TemplatesBasePath = Path.Combine(BasePath, "templates", "static"); - - /* Development hint */ - if (Directory.Exists("../../templates/static")) - TemplatesBasePath = Path.Combine(BasePath, "..", "..", "templates", "static"); - - DirectoryResource staticTemplates = new DirectoryResource(rootResource, TemplatesBasePath); + DirectoryResource staticTemplates = new DirectoryResource(new string[] { "../../www", "www" }); staticTemplates.ResourceTypeHook = ResourceTypeHook; staticTemplates.DefaultResource = staticTemplates.GetResource("index.html"); + staticTemplates.FallBackResource = staticTemplates.DefaultResource; - rootResource.DefaultResource = staticTemplates; + staticTemplates.GetResource("vue").DefaultResource = staticTemplates.GetResource("vue").GetResource("vue.html"); + staticTemplates.GetResource("vue").FallBackResource = staticTemplates.GetResource("vue").DefaultResource; - webSocketInterface = new ApplicationWebSocket(rootResource, "socket", RPCContainer); + applicationInterface.HTTPApplication.RootResource = staticTemplates; + + webSocketInterface = new ApplicationWebSocket(null, "socket", RPCContainer); + staticTemplates.InjectResource(webSocketInterface); RPCContainer.Add("", new SkyScannerRpc(this)); RPCContainer.Add("ServiceContainer",applicationInterface.ServiceContainer.RPC); diff --git a/checks/APC.cs b/checks/APC.cs index d5cd342..bc876bd 100644 --- a/checks/APC.cs +++ b/checks/APC.cs @@ -71,7 +71,7 @@ namespace ln.skyscanner.checks foreach (Sequence[] battery in batteries) { node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ups_battery_{0}_status", n), (double)((Integer)(battery[0].Items[1])).LongValue); - node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ups_battery_{0}_minutes_remain", n), (double)((Integer)(battery[1].Items[1])).LongValue, wLower: 20, cLower: 10 ); + node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ups_battery_{0}_minutes_remain", n), (double)((Integer)(battery[1].Items[1])).LongValue, wLower: 20, cLower: 10); node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ups_battery_{0}_capacity", n), (double)((Integer)(battery[2].Items[1])).LongValue, wLower: 75, cLower: 50); node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ups_battery_{0}_voltage", n), (double)((Integer)(battery[3].Items[1])).LongValue / 10.0); node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ups_battery_{0}_temperature", n), (double)((Integer)(battery[4].Items[1])).LongValue, wUpper: 40, cUpper: 60); @@ -80,6 +80,8 @@ namespace ln.skyscanner.checks checkState.CheckState = CheckState.OK; return; + } catch (TimeoutException) + { } catch (SnmpError) { } diff --git a/checks/Hostalive.cs b/checks/Hostalive.cs index 88c66a3..0fe9456 100644 --- a/checks/Hostalive.cs +++ b/checks/Hostalive.cs @@ -49,11 +49,32 @@ namespace ln.skyscanner.checks float fSuccess = (float)success / (float)n; - node.WritePerformanceValue(checkService.PerformanceValueService, Name, "replies", fSuccess, node.DeviceType == DeviceType.UNKNOWN ? Double.MinValue : 0.8, double.MaxValue, node.DeviceType == DeviceType.UNKNOWN ? Double.MinValue : 0.6, double.MaxValue); - if (success > 0) + node.WritePerformanceValue( + checkService.PerformanceValueService, + Name, + "replies", + fSuccess, + node.DeviceType == DeviceType.UNKNOWN ? Double.MinValue : 0.8, + double.MaxValue, + node.DeviceType == DeviceType.UNKNOWN ? Double.MinValue : 0.6, + double.MaxValue, + "%" + ); + + if (success > 0) { roundTripTime /= success; - node.WritePerformanceValue(checkService.PerformanceValueService, Name, "rta", roundTripTime, 0, 80, 0, 140); + node.WritePerformanceValue( + checkService.PerformanceValueService, + Name, + "rta", + roundTripTime, + 0, + 80, + 0, + 140, + "ms" + ); } foreach (PerformanceValue pv in checkState.PerformanceValues) diff --git a/checks/Mimosa.cs b/checks/Mimosa.cs index f11904f..5091871 100644 --- a/checks/Mimosa.cs +++ b/checks/Mimosa.cs @@ -38,10 +38,8 @@ namespace ln.skyscanner.checks double sig = (sigData[n][0].Items[1] as Integer).LongValue / 10.0; double snr = (sigData[n][1].Items[1] as Integer).LongValue / 10.0; - node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ptp_rx_pwr_{0}",n), sig, -75.0, 0, -80.0, 0); - node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ptp_rx_snr_{0}",n), snr, 12, 99, 8, 99); - - + node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ptp_rx_pwr_{0}",n), sig, -75.0, 0, -80.0, 0,"dBm",n.ToString()); + node.WritePerformanceValue(checkService.PerformanceValueService, Name, String.Format("ptp_rx_snr_{0}",n), snr, 12, 99, 8, 99,"dB", n.ToString()); } } diff --git a/checks/SkyCheckState.cs b/checks/SkyCheckState.cs index 13951ab..90c0176 100644 --- a/checks/SkyCheckState.cs +++ b/checks/SkyCheckState.cs @@ -61,6 +61,8 @@ namespace ln.skyscanner.checks public CheckStateChange[] History => history.ToArray(); List history = new List(); + public string Message { get; set; } + protected SkyCheckState() { } diff --git a/crawl/CrawlNetwork.cs b/crawl/CrawlNetwork.cs index e5f3d7a..925ea15 100644 --- a/crawl/CrawlNetwork.cs +++ b/crawl/CrawlNetwork.cs @@ -90,12 +90,12 @@ namespace ln.skyscanner.crawl Crawler.FindHostForIP(ip); } - if (AbortRequested) + if (JobAbortRequested) break; } - if (!AbortRequested) + if (!JobAbortRequested) { Subnet.LastScan = startTime; Subnet.NextScan = startTime + TimeSpan.FromHours(24); diff --git a/entities/Node.cs b/entities/Node.cs index 5e1afa4..e332cda 100644 --- a/entities/Node.cs +++ b/entities/Node.cs @@ -145,7 +145,7 @@ namespace ln.skyscanner.entities // performanceValues[Name] = performanceValue; //} - public void WritePerformanceValue(PerformanceValueService performanceValueService, String checkName, String perfName, double value, double wLower = Double.MinValue, double wUpper = Double.MaxValue, double cLower = Double.MinValue, double cUpper = Double.MaxValue) + public void WritePerformanceValue(PerformanceValueService performanceValueService, String checkName, String perfName, double value, double wLower = Double.MinValue, double wUpper = Double.MaxValue, double cLower = Double.MinValue, double cUpper = Double.MaxValue,String perfUnit = "",String group = "",double exMin = double.MinValue,double exMax = double.MaxValue) { string[] perfPath = new string[] { UniqueIdentity, checkName, perfName }; perfName = string.Join("/", perfPath); @@ -157,6 +157,12 @@ namespace ln.skyscanner.entities performanceValue = new PerformanceValue(perfPath, wLower, wUpper, cLower, cUpper); skyCheckState.AddPerformanceValue(performanceValue); } + + performanceValue.PerfUnit = perfUnit; + performanceValue.Group = group; + performanceValue.ExpectedMinimum = exMin; + performanceValue.ExpectedMaximum = exMax; + performanceValueService.WriteValue(performanceValue, value); } diff --git a/ln.skyscanner.csproj b/ln.skyscanner.csproj index a842745..a6c83af 100644 --- a/ln.skyscanner.csproj +++ b/ln.skyscanner.csproj @@ -95,135 +95,6 @@ - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - @@ -239,6 +110,170 @@ + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + PreserveNewest + + + PreserveNewest + + + + PreserveNewest + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + @@ -246,21 +281,15 @@ - - - - - - - - + + diff --git a/perfvalue/PerformanceValue.cs b/perfvalue/PerformanceValue.cs index 9c59cd7..fc5ad63 100644 --- a/perfvalue/PerformanceValue.cs +++ b/perfvalue/PerformanceValue.cs @@ -27,6 +27,13 @@ namespace ln.skyscanner.perfvalue public bool IgnoreLimits; + public String PerfUnit { get; set; } = String.Empty; + public String Group { get; set; } = String.Empty; + + public double ExpectedMaximum { get; set; } = double.MaxValue; + public double ExpectedMinimum { get; set; } = double.MinValue; + + private PerformanceValue() { } diff --git a/services/CheckService.cs b/services/CheckService.cs index 309236d..692a1eb 100644 --- a/services/CheckService.cs +++ b/services/CheckService.cs @@ -51,9 +51,10 @@ namespace ln.skyscanner.services checkPool = new Pool(96); checkPool.PoolJobFinished += PoolJobFinished; + checkPool.Start(); SNMPEngine = new SNMPEngine(); - SNMPEngine.Timeout = 2000; + SNMPEngine.Timeout = 5000; long nextMinute = DateTimeOffset.Now.ToUnixTimeMilliseconds(); @@ -100,12 +101,18 @@ namespace ln.skyscanner.services } } - checkPool.Abort(); + Logging.Log(LogLevel.INFO, "CheckService: Aborting currently scheduled checks"); + checkPool.Stop(true); + + SNMPEngine.Close(); coreService.RPCContainer.Remove("CheckService"); entityService = null; performanceValueService = null; coreService = null; + + Logging.Log(LogLevel.INFO, "CheckService: stopped"); + } private void UpdateNodeList() diff --git a/services/PerformanceValueService.cs b/services/PerformanceValueService.cs index fc2b5a2..9e38471 100644 --- a/services/PerformanceValueService.cs +++ b/services/PerformanceValueService.cs @@ -43,7 +43,12 @@ namespace ln.skyscanner.services { lock (this) { - Monitor.Wait(this); + try + { + Monitor.Wait(this); + } catch (ThreadInterruptedException) + { + } } } diff --git a/skyscanner.sln b/skyscanner.sln new file mode 100644 index 0000000..aaf981f --- /dev/null +++ b/skyscanner.sln @@ -0,0 +1,71 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.http", "..\ln.http\ln.http.csproj", "{CEEEEB41-3059-46A2-A871-2ADE22C013D9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.templates", "..\ln.templates\ln.templates.csproj", "{AD0267BB-F08C-4BE1-A88D-010D49041761}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.http.resources", "..\ln.http.resources\ln.http.resources.csproj", "{F9086FE4-8925-42FF-A59C-607341604293}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.snmp", "..\ln.snmp\ln.snmp.csproj", "{C7A43B82-55F2-4092-8DBE-6BE29CBF079D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.skyscanner", "ln.skyscanner.csproj", "{8456AFA0-20E9-4566-A81A-3C0EDB12356F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.perfdb", "..\ln.perfdb\ln.perfdb.csproj", "{D934C1E8-9215-4D8D-83B3-A296E4912792}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.logging", "..\ln.logging\ln.logging.csproj", "{D471A566-9FB6-41B2-A777-3C32874ECD0E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.types", "..\ln.types\ln.types.csproj", "{8D9AB9A5-E513-4BA7-A450-534F6456BF28}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.application", "..\ln.application\ln.application.csproj", "{44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.json", "..\ln.json\ln.json.csproj", "{D9342117-3249-4D8B-87C9-51A50676B158}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CEEEEB41-3059-46A2-A871-2ADE22C013D9}.Debug|x86.ActiveCfg = Debug|Any CPU + {CEEEEB41-3059-46A2-A871-2ADE22C013D9}.Debug|x86.Build.0 = Debug|Any CPU + {CEEEEB41-3059-46A2-A871-2ADE22C013D9}.Release|x86.ActiveCfg = Release|Any CPU + {CEEEEB41-3059-46A2-A871-2ADE22C013D9}.Release|x86.Build.0 = Release|Any CPU + {AD0267BB-F08C-4BE1-A88D-010D49041761}.Debug|x86.ActiveCfg = Debug|Any CPU + {AD0267BB-F08C-4BE1-A88D-010D49041761}.Debug|x86.Build.0 = Debug|Any CPU + {AD0267BB-F08C-4BE1-A88D-010D49041761}.Release|x86.ActiveCfg = Release|Any CPU + {AD0267BB-F08C-4BE1-A88D-010D49041761}.Release|x86.Build.0 = Release|Any CPU + {F9086FE4-8925-42FF-A59C-607341604293}.Debug|x86.ActiveCfg = Debug|Any CPU + {F9086FE4-8925-42FF-A59C-607341604293}.Debug|x86.Build.0 = Debug|Any CPU + {F9086FE4-8925-42FF-A59C-607341604293}.Release|x86.ActiveCfg = Release|Any CPU + {F9086FE4-8925-42FF-A59C-607341604293}.Release|x86.Build.0 = Release|Any CPU + {C7A43B82-55F2-4092-8DBE-6BE29CBF079D}.Debug|x86.ActiveCfg = Debug|Any CPU + {C7A43B82-55F2-4092-8DBE-6BE29CBF079D}.Debug|x86.Build.0 = Debug|Any CPU + {C7A43B82-55F2-4092-8DBE-6BE29CBF079D}.Release|x86.ActiveCfg = Release|Any CPU + {C7A43B82-55F2-4092-8DBE-6BE29CBF079D}.Release|x86.Build.0 = Release|Any CPU + {8456AFA0-20E9-4566-A81A-3C0EDB12356F}.Debug|x86.ActiveCfg = Debug|x86 + {8456AFA0-20E9-4566-A81A-3C0EDB12356F}.Debug|x86.Build.0 = Debug|x86 + {8456AFA0-20E9-4566-A81A-3C0EDB12356F}.Release|x86.ActiveCfg = Release|x86 + {8456AFA0-20E9-4566-A81A-3C0EDB12356F}.Release|x86.Build.0 = Release|x86 + {D934C1E8-9215-4D8D-83B3-A296E4912792}.Debug|x86.ActiveCfg = Debug|Any CPU + {D934C1E8-9215-4D8D-83B3-A296E4912792}.Debug|x86.Build.0 = Debug|Any CPU + {D934C1E8-9215-4D8D-83B3-A296E4912792}.Release|x86.ActiveCfg = Release|Any CPU + {D934C1E8-9215-4D8D-83B3-A296E4912792}.Release|x86.Build.0 = Release|Any CPU + {D471A566-9FB6-41B2-A777-3C32874ECD0E}.Debug|x86.ActiveCfg = Debug|Any CPU + {D471A566-9FB6-41B2-A777-3C32874ECD0E}.Debug|x86.Build.0 = Debug|Any CPU + {D471A566-9FB6-41B2-A777-3C32874ECD0E}.Release|x86.ActiveCfg = Release|Any CPU + {D471A566-9FB6-41B2-A777-3C32874ECD0E}.Release|x86.Build.0 = Release|Any CPU + {8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Debug|x86.ActiveCfg = Debug|Any CPU + {8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Debug|x86.Build.0 = Debug|Any CPU + {8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Release|x86.ActiveCfg = Release|Any CPU + {8D9AB9A5-E513-4BA7-A450-534F6456BF28}.Release|x86.Build.0 = Release|Any CPU + {44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}.Debug|x86.ActiveCfg = Debug|Any CPU + {44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}.Debug|x86.Build.0 = Debug|Any CPU + {44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}.Release|x86.ActiveCfg = Release|Any CPU + {44AA3A50-7214-47F2-9D60-6FF34C0FE6D3}.Release|x86.Build.0 = Release|Any CPU + {D9342117-3249-4D8B-87C9-51A50676B158}.Debug|x86.ActiveCfg = Debug|Any CPU + {D9342117-3249-4D8B-87C9-51A50676B158}.Debug|x86.Build.0 = Debug|Any CPU + {D9342117-3249-4D8B-87C9-51A50676B158}.Release|x86.ActiveCfg = Release|Any CPU + {D9342117-3249-4D8B-87C9-51A50676B158}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/templates/static/ln.application.js b/templates/static/ln.application.js deleted file mode 100644 index 4f4ce61..0000000 --- a/templates/static/ln.application.js +++ /dev/null @@ -1,343 +0,0 @@ -var LN = (function(){ - var appInterface; - - var defaultOptions = { - url: null, - - }; - - class LNInterface { - constructor(opt){ - var self = this; - - this.options = {} - Object.assign(this.options,opt); - - if (this.options.url == null) - this.options.url = this.constructURL(); - - - this.rpcCallbacks = []; - this.rpcNextID = 1; - - this.websocket = new WebSocket(this.options.url); - this.websocket.onerror = function(e){ - alert("WebSocket caught error: " + e.date); - } - this.websocket.onmessage = function(e){ - try{ - var j = JSON.parse(e.data); - if (j.state){ - updateState(j.state); - } else if (j.id) - { - for (var n=0;n").text(e.data).appendTo($(body)); - } - } - } - - rpc(module,method,parameters,cbfn){ - - var rpcCall = { - module: module, - method: method, - parameters: parameters, - id: this.rpcNextID++, - }; - - if (this.websocket.readyState != 1) - { - setTimeout(function(){ - LN().rpc(module,method,parameters,cbfn); - },250); - } else { - this.rpcCallbacks.push( { id: rpcCall.id, cbfn: cbfn } ); - this.websocket.send( - JSON.stringify(rpcCall) - ); - } - } - - - - - constructURL(){ - var pageURI = window.location; - - var scheme = pageURI.scheme == "https" ? "wss:" : "ws:"; - var host = pageURI.host; - - return scheme + "//" + host + "/socket"; - } - - - - } - - return function(options){ - if (!appInterface) - appInterface = new LNInterface(options); - return appInterface; - }; -})(); - - - - -/* - -Object.values = function(o) { - var values = []; - for(var property in o) { - values.push(o[property]); - } - return values; -} - -function encodeID( t ) -{ - return ("" + t).replace( /[\.\/]/g, "_"); -} - -var lagDetector = null; - -function updateState(state) -{ - try - { - if (lagDetector) - clearTimeout(lagDetector); - - $("#ServerTime").text("ServerTime: " + moment(state.currentTime).format()); - - lagDetector = setTimeout(function(){ - $("#ServerTime").text("Server lag detected"); - }, 2000); - - } catch (e) - { - $("#ServerTime").text("Server state unexpected!"); - } -} - -function SKYAPI(baseurl){ - - this.baseurl = baseurl; - this.refresh = [] - - this.websocket = new WebSocket("ws://localhost:8080/socket"); - this.websocket.onerror = function(e){ - alert("WebSocket Error: " + e); - } - this.websocket.onmessage = function(e){ - var j = JSON.parse(e.data); - if (j.state){ - updateState(j.state); - } - } - - this.setBaseURL = function(url){ this.baseurl = url; } - this.addRefresh = function( rh, seconds = null ){ this.refresh.push( { interval: seconds ? seconds : 5, refresh: rh } ); } - - this.get = function(page, json, handler = null){ return this.__request("GET", page, json, handler); } - this.post = function(page, json, handler = null){ return this.__request("POST", page, json, handler); } - this.put = function(page, json, handler = null){ return this.__request("PUT", page, json, handler); } - - this.__request = function(method, page, json, handler = null){ - if (page[0] == '/') - page = page.substr(1); - - var x = new XMLHttpRequest(); - if (handler != null) - { - x.onload = function(){ - var responseText = x.responseText; - if (json && !content) - handler( JSON.parse( responseText ) ); - else - handler( responseText ); - } - } - x.open(method, this.baseurl + page); - - if (json) - x.send(JSON.stringify(json)); - else - x.send(); - } - - this.getJson = function(page, handler){ - var j = function(t){ - handler(JSON.parse(t)); - }; - return this.get( page, null, j ); - } - - this.call = function(endpoint,method,parameters = [], receiver = null){ - var x = new XMLHttpRequest(); - - x.open("POST", this.baseurl + endpoint, (receiver != null)); - x.setRequestHeader("content-type","application/json"); - - if (receiver) - { - x.onload = function(){ var r = JSON.parse(this.responseText).Result; receiver(r); } - x.onerror = function(){ receiver(false); } - } - - var methodCall = { - "MethodName": method, - "Parameters": parameters - } - - x.send(JSON.stringify(methodCall)); - - if (!receiver) - { - var result = JSON.parse(x.responseText); - if (result.Exception != null) - throw result.Exception; - - return result.Result; - } - return x; - } - - this.loadPage = function (page) { - if (page[0] == '/') - page = page.substr(1); - - var x = new XMLHttpRequest(); - - x.open("GET", this.baseurl + page); - x.setRequestHeader("x-template-unframed","unframed"); - x.onload = function() - { - $("#content").empty(); - $("#content").append(this.responseText); - history.pushState(null, page, skyapi().baseurl + page); - } - - this.refresh = [] - - x.send(); - - return false; - } - - this.fireOnLoad = function(element){ - if (element.onload != null) - { - element.onload(); - } - - for (var n=0;n 1000000000) - return ((value / 1000000000) | 0) + "G"; - if (value > 1000000) - return ((value / 1000000) | 0) + "M"; - if (value > 1000) - return ((value / 1000) | 0) + "k"; - return value; -} - - -*/ - diff --git a/templates/static/network/nodes.html b/templates/static/network/nodes.html deleted file mode 100644 index b1dacb9..0000000 --- a/templates/static/network/nodes.html +++ /dev/null @@ -1,151 +0,0 @@ -<%frame "frame.html"%> - -

Network Overview

-

Hosts / Nodes - - Sync with Skytron CRM -

- -
-
-
- -

Details

-
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
- - diff --git a/templates/static/topnav.html b/templates/static/topnav.html deleted file mode 100644 index 44cd79f..0000000 --- a/templates/static/topnav.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - diff --git a/templates/static/checks/checks.html b/www/checks/checks.html similarity index 100% rename from templates/static/checks/checks.html rename to www/checks/checks.html diff --git a/templates/static/checks/checkstates.html b/www/checks/checkstates.html similarity index 100% rename from templates/static/checks/checkstates.html rename to www/checks/checkstates.html diff --git a/templates/static/checks/index.html b/www/checks/index.html similarity index 100% rename from templates/static/checks/index.html rename to www/checks/index.html diff --git a/templates/static/checks/issues.html b/www/checks/issues.html similarity index 100% rename from templates/static/checks/issues.html rename to www/checks/issues.html diff --git a/templates/static/checks/issues2.html b/www/checks/issues2.html similarity index 90% rename from templates/static/checks/issues2.html rename to www/checks/issues2.html index d4e1e9f..fed6683 100644 --- a/templates/static/checks/issues2.html +++ b/www/checks/issues2.html @@ -35,33 +35,7 @@ var charts = [] var chartTimeout = null; - function ntos(n,l){ - n = n.toString(); - while (n.length < l){ - n = "0" + n; - } - return n; - } - function timespan(value){ - var days, hours, minutes, seconds; - value = parseInt(value); - - days = parseInt(value / 86400); - value %= 86400; - hours = parseInt(value / 3600); - value %= 3600; - minutes = parseInt(value / 60); - value %= 60; - seconds = parseInt(value); - - var r = ""; - if (days > 0) - r += `${days}d `; - r += `${ntos(hours,2)}:${ntos(minutes,2)}:${ntos(seconds,2)}`; - - return r; - } @@ -100,7 +74,7 @@ .append( $("") .text(node.Name + " [ "+ node.UniqueIdentity +" ]") - .attr("href","/static/checks/node.html#" + node.ID) + .attr("href","/checks/node.html#" + node.ID) .attr("target","_blank") ); @@ -192,6 +166,11 @@ //console.log(JSON.stringify(nodes)); + if (nodes.length > 500) + { + nodes = nodes.slice(0,1000); + } + $.each( nodes , function(){ updateNode(this); }); diff --git a/templates/static/checks/node.html b/www/checks/node.html similarity index 84% rename from templates/static/checks/node.html rename to www/checks/node.html index 7a6086d..5739361 100644 --- a/templates/static/checks/node.html +++ b/www/checks/node.html @@ -7,13 +7,13 @@ Sender:
@@ -71,6 +71,31 @@ $("#checkStates > tbody").empty(); + $("#link-http").hide(); + $("#link-ssh").hide(); + $("#link-telnet").hide(); + + $.each( node.URIs, function(){ + if ((this.Scheme == "http")||(this.Scheme == "https")) + { + $("#link-http") + .attr("href", this.Scheme + "://" + this.Authority + this.Path) + .show(); + } + if ((this.Scheme == "ssh")) + { + $("#link-ssh") + .attr("href", this.Scheme + "://" + this.Authority + this.Path) + .show(); + } + if ((this.Scheme == "telnet")) + { + $("#link-telnet") + .attr("href", this.Scheme + "://" + this.Authority + this.Path) + .show(); + } + }); + $.each( node.CheckStates, function(){ var row = $("") .append( @@ -95,9 +120,19 @@ var age = (lastTimestamp - currentTimestamp) / 1000; tdHist.append( - $("
") + $("

") + .addClass("flex row") .addClass("issue-" + this.NewState ) - .text(this.NewState + "[ " + timespan(age) + " ]") + .append($("") + .css("flex-grow","1") + .text(this.NewState) + ) + .append( $("") + .css("flex-grow","0") + .css("width","80px") + .css("text-align","right") + .text(timespan(age)) + ) ); lastTimestamp = currentTimestamp; diff --git a/templates/static/checks/status.html b/www/checks/status.html similarity index 100% rename from templates/static/checks/status.html rename to www/checks/status.html diff --git a/templates/static/crawler/hosts.html b/www/crawler/hosts.html similarity index 100% rename from templates/static/crawler/hosts.html rename to www/crawler/hosts.html diff --git a/templates/static/crawler/status.html b/www/crawler/status.html similarity index 100% rename from templates/static/crawler/status.html rename to www/crawler/status.html diff --git a/templates/static/crawler/subnets.html b/www/crawler/subnets.html similarity index 100% rename from templates/static/crawler/subnets.html rename to www/crawler/subnets.html diff --git a/templates/static/css/Chart.min.css b/www/css/Chart.min.css similarity index 100% rename from templates/static/css/Chart.min.css rename to www/css/Chart.min.css diff --git a/templates/static/css/datatables.min.css b/www/css/datatables.min.css similarity index 100% rename from templates/static/css/datatables.min.css rename to www/css/datatables.min.css diff --git a/templates/static/css/images/ui-icons_444444_256x240.png b/www/css/images/ui-icons_444444_256x240.png similarity index 100% rename from templates/static/css/images/ui-icons_444444_256x240.png rename to www/css/images/ui-icons_444444_256x240.png diff --git a/templates/static/css/images/ui-icons_555555_256x240.png b/www/css/images/ui-icons_555555_256x240.png similarity index 100% rename from templates/static/css/images/ui-icons_555555_256x240.png rename to www/css/images/ui-icons_555555_256x240.png diff --git a/templates/static/css/images/ui-icons_6495ED_256x240.png b/www/css/images/ui-icons_6495ED_256x240.png similarity index 100% rename from templates/static/css/images/ui-icons_6495ED_256x240.png rename to www/css/images/ui-icons_6495ED_256x240.png diff --git a/templates/static/css/images/ui-icons_777620_256x240.png b/www/css/images/ui-icons_777620_256x240.png similarity index 100% rename from templates/static/css/images/ui-icons_777620_256x240.png rename to www/css/images/ui-icons_777620_256x240.png diff --git a/templates/static/css/images/ui-icons_777777_256x240.png b/www/css/images/ui-icons_777777_256x240.png similarity index 100% rename from templates/static/css/images/ui-icons_777777_256x240.png rename to www/css/images/ui-icons_777777_256x240.png diff --git a/templates/static/css/images/ui-icons_cc0000_256x240.png b/www/css/images/ui-icons_cc0000_256x240.png similarity index 100% rename from templates/static/css/images/ui-icons_cc0000_256x240.png rename to www/css/images/ui-icons_cc0000_256x240.png diff --git a/templates/static/css/images/ui-icons_ffffff_256x240.png b/www/css/images/ui-icons_ffffff_256x240.png similarity index 100% rename from templates/static/css/images/ui-icons_ffffff_256x240.png rename to www/css/images/ui-icons_ffffff_256x240.png diff --git a/templates/static/css/index.html b/www/css/index.html similarity index 100% rename from templates/static/css/index.html rename to www/css/index.html diff --git a/templates/static/css/jquery-ui.min.css b/www/css/jquery-ui.min.css similarity index 100% rename from templates/static/css/jquery-ui.min.css rename to www/css/jquery-ui.min.css diff --git a/www/css/ln.application.css b/www/css/ln.application.css new file mode 100644 index 0000000..c65238f --- /dev/null +++ b/www/css/ln.application.css @@ -0,0 +1,2 @@ + + diff --git a/templates/static/css/select.jqueryui.min.css b/www/css/select.jqueryui.min.css similarity index 100% rename from templates/static/css/select.jqueryui.min.css rename to www/css/select.jqueryui.min.css diff --git a/templates/static/css/style.css b/www/css/style.css similarity index 80% rename from templates/static/css/style.css rename to www/css/style.css index 0cf6565..99e7eda 100644 --- a/templates/static/css/style.css +++ b/www/css/style.css @@ -1,35 +1,9 @@ -body { - padding: 0px; - margin: 0px; - - font-family: Arial, Helvetica, sans-serif; - font-size: 12px; - - display: block; - position: absolute; - top: 0px; - bottom: 0px; - left: 0px; - right: 0px; -} - -div { - margin: 0px; - padding: 0px; - flex-grow: 0; -} - -div#body { - display: flex; - height: 100%; - width: 100%; - - flex-direction: column; -} + h1,h2,h3,h4,h5,h6 { margin: 0px; padding:2px; + margin-bottom: 8px; } h1 > div { @@ -59,19 +33,7 @@ a { color: inherit; } -table { - border-collapse: collapse; -} - -table > thead { - font-style: italic; - background-color: #A0D0FF; - transition: background-color 1000ms; -} - -table > tbody { -} - +/* table td { vertical-align: top; @@ -98,50 +60,9 @@ table > tbody tr:hover { color: black; transition: background-color 250ms; } +*/ -#header { - top: 0px; - left: 0px; - right: 0px; - - border-bottom: 1px solid black; - background-color: #c7def5; - padding: 4px; - - display: flex; - - flex-direction: row; - flex-wrap: wrap; -} - -#header > div { - margin: 4px; -} - - -#footer { - height: 20px; - padding: 6px; - padding-left: 24px; - background-color: #c7def5; - border-top: 1px solid black; - - flex-grow: 0; - flex-shrink: 0; -} - -#page { - display: flex; - top: 56px; - bottom: 32px; - left: 0px; - right: 0px; - - flex-grow: 1; - - flex-direction: row; -} #nav { display: flex; @@ -186,7 +107,9 @@ table > tbody tr:hover { } .right { - float: right; +/* float: right; + right: 0px;*/ + position: absolute; right: 0px; } @@ -216,6 +139,10 @@ table > tbody tr:hover { display: flex; } +.flex > .grow { + flex-grow: 1; +} + .skylogo { @@ -232,6 +159,10 @@ table > tbody tr:hover { padding: 4px; } +.silver { + color: #808080; +} + .indicator { margin-left: 4px; margin-right: 4px; @@ -263,7 +194,7 @@ table > tbody tr:hover { background-color: #00D000; } .indicator[state="FAILED"] > div { - background-color: #D00000; + background-color: #C00000; } .indicator[state="INITIALIZED"] > div { background-color: #00D0D0; @@ -421,17 +352,20 @@ fieldset > label { .issue-OK { border-color: white; background-color: inherit; - color: green; + color: #008000; } .issue-WARN { - border-color: #C0C000; +/* border-color: #C0C000; background-color: #C0C000; color: black; + */ + color: #C0C000; } .issue-CRITICAL { - border-color: red; - background-color: red; - color: white; +/* border-color: #C00000; + background-color: #C00000; + color: white;*/ + color: #C00000; } #CheckState { @@ -444,7 +378,7 @@ fieldset > label { color: #C0C000; } #CheckState.CRITICAL, span#nCRITICAL{ - color: RED; + color: #C00000; margin-right: 12px; } @@ -468,7 +402,7 @@ fieldset > label { } span#nWARN, span#nCRITICAL, span#nOK { - font-size: 24px; + font-size: 16px; } .performance-value > div { @@ -503,25 +437,19 @@ span#nWARN, span#nCRITICAL, span#nOK { } [bool=false] { border: 1px solid white; - background-color: red; + background-color: #C00000; } .protolink { position: relative; - display: table-cell; + display: inline-block; - width: 64px; - height: 64px; - - border: 3px solid white; - border-radius: 28px; - - text-align: center; - vertical-align: middle; - - background-color: #009ee3; - color: white; + margin-left: 12px; + margin-right: 12px; +} +.protolink::before { + content: ">"; } .protolink > div { diff --git a/templates/static/dist/Chart.min.js b/www/dist/Chart.min.js similarity index 100% rename from templates/static/dist/Chart.min.js rename to www/dist/Chart.min.js diff --git a/templates/static/dist/dataTables.select.min.js b/www/dist/dataTables.select.min.js similarity index 100% rename from templates/static/dist/dataTables.select.min.js rename to www/dist/dataTables.select.min.js diff --git a/templates/static/dist/datatables.min.js b/www/dist/datatables.min.js similarity index 100% rename from templates/static/dist/datatables.min.js rename to www/dist/datatables.min.js diff --git a/templates/static/dist/jquery-ui.min.js b/www/dist/jquery-ui.min.js similarity index 100% rename from templates/static/dist/jquery-ui.min.js rename to www/dist/jquery-ui.min.js diff --git a/templates/static/dist/jquery.min.js b/www/dist/jquery.min.js similarity index 100% rename from templates/static/dist/jquery.min.js rename to www/dist/jquery.min.js diff --git a/templates/static/dist/moment-timezone-with-data.js b/www/dist/moment-timezone-with-data.js similarity index 100% rename from templates/static/dist/moment-timezone-with-data.js rename to www/dist/moment-timezone-with-data.js diff --git a/templates/static/dist/moment-with-locales.js b/www/dist/moment-with-locales.js similarity index 100% rename from templates/static/dist/moment-with-locales.js rename to www/dist/moment-with-locales.js diff --git a/templates/static/dist/percentageBars.js b/www/dist/percentageBars.js similarity index 100% rename from templates/static/dist/percentageBars.js rename to www/dist/percentageBars.js diff --git a/templates/static/dist/select.jqueryui.min.js b/www/dist/select.jqueryui.min.js similarity index 100% rename from templates/static/dist/select.jqueryui.min.js rename to www/dist/select.jqueryui.min.js diff --git a/templates/static/frame.html b/www/frame.html similarity index 60% rename from templates/static/frame.html rename to www/frame.html index c33a8f0..6d358d0 100644 --- a/templates/static/frame.html +++ b/www/frame.html @@ -4,22 +4,22 @@ SkyScanner WebUI (Alpha) - - - + + + - + - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ + +
+ + + + diff --git a/templates/static/workspace.js b/www/workspace.js similarity index 100% rename from templates/static/workspace.js rename to www/workspace.js