WIP
parent
624f0589b4
commit
24b956a4a2
|
@ -59,9 +59,13 @@ namespace ln.skyscanner
|
||||||
"uniqueIdentity"
|
"uniqueIdentity"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Network4 n192 = Network4.Parse("192.168.0.0/16");
|
||||||
|
|
||||||
/* Preload all nodes to increase load speed*/
|
/* Preload all nodes to increase load speed*/
|
||||||
foreach (Node node in NodeCollection)
|
foreach (Node node in NodeCollection.ToArray())
|
||||||
{
|
{
|
||||||
|
if (n192.Contains(node.PrimaryIP))
|
||||||
|
NodeCollection.Delete(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubnetCollection = ODB.GetCollection<Subnet>();
|
SubnetCollection = ODB.GetCollection<Subnet>();
|
||||||
|
@ -78,7 +82,13 @@ namespace ln.skyscanner
|
||||||
|
|
||||||
SkyCheckStates = ODB.GetCollection<SkyCheckState>();
|
SkyCheckStates = ODB.GetCollection<SkyCheckState>();
|
||||||
SkyCheckStates.EnableStrongCache(true);
|
SkyCheckStates.EnableStrongCache(true);
|
||||||
SkyCheckStates.EnsureIndeces("CheckName","Node");
|
SkyCheckStates.EnsureIndeces("Node");
|
||||||
|
|
||||||
|
foreach (SkyCheckState checkState in SkyCheckStates.ToArray())
|
||||||
|
{
|
||||||
|
if (object.ReferenceEquals(checkState.Node, null))
|
||||||
|
SkyCheckStates.Delete(checkState);
|
||||||
|
}
|
||||||
|
|
||||||
Logging.Log(LogLevel.INFO, "SkyEntities: initialized");
|
Logging.Log(LogLevel.INFO, "SkyEntities: initialized");
|
||||||
|
|
||||||
|
|
|
@ -28,17 +28,17 @@ namespace ln.skyscanner.checks
|
||||||
{
|
{
|
||||||
Name = String.Format("Interval check: {0} [{1}]",node.UniqueIdentity,node.PrimaryIP.ToString());
|
Name = String.Format("Interval check: {0} [{1}]",node.UniqueIdentity,node.PrimaryIP.ToString());
|
||||||
Node = node;
|
Node = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RunJob()
|
||||||
|
{
|
||||||
Query stateQuery = Query.Equals<SkyCheckState>("Node", Node.ID);
|
Query stateQuery = Query.Equals<SkyCheckState>("Node", Node.ID);
|
||||||
SkyCheckState[] skyCheckStates = SkyScanner.Instance.Entities.SkyCheckStates.Query(stateQuery).ToArray();
|
SkyCheckState[] skyCheckStates = SkyScanner.Instance.Entities.SkyCheckStates.Query(stateQuery).ToArray();
|
||||||
foreach (SkyCheckState checkState in skyCheckStates)
|
foreach (SkyCheckState checkState in skyCheckStates)
|
||||||
{
|
{
|
||||||
checkStates.Add(checkState.CheckName, checkState);
|
checkStates.Add(checkState.CheckName, checkState);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public override void RunJob()
|
|
||||||
{
|
|
||||||
SkyCheck[] checks = SkyCheck.SkyChecks;
|
SkyCheck[] checks = SkyCheck.SkyChecks;
|
||||||
|
|
||||||
for (int n=0;n<checks.Length;n++)
|
for (int n=0;n<checks.Length;n++)
|
||||||
|
@ -59,7 +59,10 @@ namespace ln.skyscanner.checks
|
||||||
|
|
||||||
checks[n].Check(SkyScanner.Instance.Checker, ref checkState, Node);
|
checks[n].Check(SkyScanner.Instance.Checker, ref checkState, Node);
|
||||||
if (checkState != null)
|
if (checkState != null)
|
||||||
|
{
|
||||||
|
checkState.CheckHistory();
|
||||||
SkyScanner.Instance.Checker.Save(checkState);
|
SkyScanner.Instance.Checker.Save(checkState);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +76,6 @@ namespace ln.skyscanner.checks
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
|
|
|
@ -50,11 +50,11 @@ namespace ln.skyscanner.checks
|
||||||
|
|
||||||
float fSuccess = (float)success / (float)n;
|
float fSuccess = (float)success / (float)n;
|
||||||
|
|
||||||
checkState.WritePerformanceValue("replies", fSuccess, 0.8, 1.0, 0.6, 1.0);
|
checkState.WritePerformanceValue("replies", fSuccess, 0.8, double.MaxValue, 0.6, double.MaxValue);
|
||||||
if (success > 0)
|
if (success > 0)
|
||||||
{
|
{
|
||||||
roundTripTime /= success;
|
roundTripTime /= success;
|
||||||
checkState.WritePerformanceValue("rta", roundTripTime, 0, 10, 0, 50);
|
checkState.WritePerformanceValue("rta", roundTripTime, 0, 40, 0, 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkState.BaseCheckState = CheckState.OK;
|
checkState.BaseCheckState = CheckState.OK;
|
||||||
|
|
|
@ -39,14 +39,18 @@ namespace ln.skyscanner.checks
|
||||||
public bool ContainsPerfFile(String perfName) => perfFiles.ContainsKey(perfName);
|
public bool ContainsPerfFile(String perfName) => perfFiles.ContainsKey(perfName);
|
||||||
|
|
||||||
[Callable]
|
[Callable]
|
||||||
public SkyCheckState[] Issues => SkyScanner.Instance.Entities.SkyCheckStates.Query(
|
public SkyCheckState[] Issues
|
||||||
Query.OR(
|
{
|
||||||
Query.Equals<SkyCheckState>("currentCheckState", CheckState.CRITICAL),
|
get
|
||||||
Query.Equals<SkyCheckState>("currentCheckState", CheckState.FAIL),
|
{
|
||||||
Query.Equals<SkyCheckState>("currentCheckState", CheckState.WARN)
|
SkyCheckState[] checkStates = null;
|
||||||
)
|
lock (SkyScanner.Instance.Entities.SkyCheckStates)
|
||||||
).ToArray();
|
{
|
||||||
|
checkStates = SkyScanner.Instance.Entities.SkyCheckStates.ToArray();
|
||||||
|
}
|
||||||
|
return checkStates.Where((cs) => cs.CheckState != CheckState.OK).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SNMPEngine SNMPEngine { get; }
|
public SNMPEngine SNMPEngine { get; }
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ using ln.types.threads;
|
||||||
using ln.perfdb.storage;
|
using ln.perfdb.storage;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using ln.skyscanner.checks;
|
||||||
|
using ln.types.odb;
|
||||||
|
using System.Linq;
|
||||||
namespace ln.skyscanner.http
|
namespace ln.skyscanner.http
|
||||||
{
|
{
|
||||||
public class CheckerApi : JsonCallResource
|
public class CheckerApi : JsonCallResource
|
||||||
|
@ -29,7 +32,15 @@ namespace ln.skyscanner.http
|
||||||
public PoolJob[] CurrentPoolJobs => SkyScanner.Instance.Checker.CurrentJobs;
|
public PoolJob[] CurrentPoolJobs => SkyScanner.Instance.Checker.CurrentJobs;
|
||||||
[Callable]
|
[Callable]
|
||||||
public PoolJob[] QueuedPoolJobs => SkyScanner.Instance.Checker.QueuedJobs;
|
public PoolJob[] QueuedPoolJobs => SkyScanner.Instance.Checker.QueuedJobs;
|
||||||
|
[Callable]
|
||||||
|
public SkyCheckState[] Issues
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
Query issueQuery = Query.EqualsNot<SkyCheckState>("CheckState", CheckState.OK);
|
||||||
|
return SkyScanner.Instance.Entities.SkyCheckStates.Query(issueQuery).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
var chartCTX = $("#perfChart");
|
var chartCTX = $("#perfChart");
|
||||||
var chart = new Chart( chartCTX, {
|
var chart = new Chart( chartCTX, {
|
||||||
type: 'bar',
|
type: 'line',
|
||||||
data: {
|
data: {
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,51 +1,146 @@
|
||||||
<%frame "frame.html"%>
|
<%frame "frame.html"%>
|
||||||
|
|
||||||
<h1>Aktuelle Störfälle</h1>
|
<h1>Aktuelle Störfälle</h1>
|
||||||
|
<span id="nCRITICAL" class="CRITICAL"></span>
|
||||||
|
<span id="nWARN" class="WARN"></span><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
<select id="interval" style="width: 180px;">
|
||||||
|
<option value="3600">1 Stunde</option>
|
||||||
|
<option value="21600">6 Stunden</option>
|
||||||
|
<option value="43200">12 Stunden</option>
|
||||||
|
<option value="86400">1 Tag</option>
|
||||||
|
<option value="604800">1 Woche</option>
|
||||||
|
</select>
|
||||||
|
<button onclick="refresh();">Aktualisieren</button>
|
||||||
|
<br/>
|
||||||
|
|
||||||
<div class="flex column">
|
<div class="flex column">
|
||||||
<div id="issueList">
|
<div id="CRITICAL"></div>
|
||||||
</div>
|
<div id="WARN"></div>
|
||||||
|
<div id="FAIL"></div>
|
||||||
|
<div id="ERROR"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="nodetemplate" style="visibility: hidden;">
|
<div style="visibility: hidden;">
|
||||||
<div class="ui-message" style="margin-bottom: 16px;">
|
<div id="nodetemplate" class="issue-box" style="margin-bottom: 16px;">
|
||||||
<h2 id="UniqueIdentity"></h2>
|
<h2 id="title"></h2>
|
||||||
|
<div>
|
||||||
|
Last Check: <span id="LastCheckTime"></span><br>
|
||||||
|
Current State for: <span id="UnchangedTime"></span><br>
|
||||||
|
</div>
|
||||||
|
<div id="PerfValues">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="pvtemplate" class="performance-value flex">
|
||||||
|
<div>
|
||||||
|
<span id="CheckState"></span><br>
|
||||||
|
<span id="PerfName"></span><br>
|
||||||
|
</div>
|
||||||
|
<div id="chartBox" class="fill"><canvas id="chart"></canvas></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
moment.defaultFormat = "DD.MM.YYYY HH:mm";
|
||||||
|
|
||||||
var issues = []
|
var issues = {}
|
||||||
var nodes = {}
|
|
||||||
var nodeIssues = {}
|
function updateIssue(issue)
|
||||||
|
{
|
||||||
|
var ne = $("#" + issue.ID );
|
||||||
|
if (!ne.length)
|
||||||
|
ne = $("#nodetemplate").clone().attr("id",issue.ID);
|
||||||
|
|
||||||
|
ne.appendTo($("#" + issue.CheckState));
|
||||||
|
ne.addClass("issue-" + issue.CheckState );
|
||||||
|
|
||||||
|
$("h2", ne).text(issue.CheckName + ": " + issue.Node.Name + " ( " + issue.Node.UniqueIdentity + " )");
|
||||||
|
$("#LastCheckTime", ne).text(issue.LastCheckTime);
|
||||||
|
$("#UnchangedTime", ne).text(issue.UnchangedTime);
|
||||||
|
|
||||||
|
$.each( issue.PerformanceValues, function(){
|
||||||
|
var pv = $("#" + this.PerfName.replace(/\//g,"-"));
|
||||||
|
if (!pv.length)
|
||||||
|
pv = $("#pvtemplate").clone().attr("id", this.PerfName.replace(/\//g,"-"));
|
||||||
|
|
||||||
|
$("#PerfName", pv).text(this.PerfName);
|
||||||
|
$("#CheckState", pv).text(this.CheckState).addClass(this.CheckState);
|
||||||
|
|
||||||
|
pv.appendTo($("#PerfValues", ne));
|
||||||
|
|
||||||
|
var chartColor = this.CheckState == "CRITICAL" ? '#FF0000' : (this.CheckState == "WARN") ? '#FFFF00' : '#000000';
|
||||||
|
var chart = new Chart( $("#chart", pv), {
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: "-",
|
||||||
|
data: [],
|
||||||
|
backgroundColor: chartColor,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
yAxes: [
|
||||||
|
{
|
||||||
|
ticks: {
|
||||||
|
callback: ScaleSI,
|
||||||
|
beginAtZero: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
xAxes: [{
|
||||||
|
type: 'time',
|
||||||
|
time: {
|
||||||
|
unit: "minute",
|
||||||
|
tooltipFormat: "DD.MM.YYYY HH:mm",
|
||||||
|
displayFormats: {
|
||||||
|
minute: "DD.MM.YYYY HH:mm"
|
||||||
|
},
|
||||||
|
parser: moment.unix
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: false
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
var perfName = this.PerfName;
|
||||||
|
|
||||||
|
skyapi().getJson("api/checker/checks/" + encodeURIComponent(perfName) + "?interval=" + $("#interval").children("option:selected").val(), function(perfValues){
|
||||||
|
chart.data.labels.length = 0;
|
||||||
|
chart.data.datasets[0].data.length = 0;
|
||||||
|
chart.data.datasets[0].label = perfName;
|
||||||
|
|
||||||
|
$.each( perfValues, function(){
|
||||||
|
if (this.TimeStamp != 0)
|
||||||
|
chart.data.datasets[0].data.push( { x: this.TimeStamp, y: this.Value } );
|
||||||
|
});
|
||||||
|
|
||||||
|
chart.update();
|
||||||
|
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function updateIssueList(issueList)
|
function updateIssueList(issueList)
|
||||||
{
|
{
|
||||||
$.each( issueList, function(){
|
$.each( issueList , function(){
|
||||||
if (this.Node)
|
updateIssue(this);
|
||||||
{
|
|
||||||
if (!nodes[this.Node.UniqueIdentity])
|
|
||||||
nodes[this.Node.UniqueIdentity] = this.Node
|
|
||||||
if (!nodeIssues[this.Node.UniqueIdentity])
|
|
||||||
nodeIssues[this.Node.UniqueIdentity] = {}
|
|
||||||
if (!nodeIssues[this.Node.UniqueIdentity][this.ID])
|
|
||||||
nodeIssues[this.Node.UniqueIdentity][this.ID] = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each( nodes, function(){
|
$("#nCRITICAL").text( $("#CRITICAL > div").length );
|
||||||
var ne = $("#" + this.UniqueIdentity );
|
$("#nWARN").text( $("#WARN > div").length );
|
||||||
if (!ne.length)
|
|
||||||
ne = $("#nodetemplate div").clone().attr("id",this.UniqueIdentity).appendTo($("#issueList"));
|
|
||||||
|
|
||||||
$("#UniqueIdentity", ne).text(this.UniqueIdentity);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
skyapi().getJson("/checker/Issues", updateIssueList );
|
skyapi().getJson("/checker/Issues", updateIssueList );
|
||||||
|
|
||||||
|
function refresh()
|
||||||
|
{
|
||||||
|
skyapi().getJson("/checker/Issues", updateIssueList );
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -145,8 +145,7 @@ button {
|
||||||
}
|
}
|
||||||
|
|
||||||
.flex {
|
.flex {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.flex.row {
|
.flex.row {
|
||||||
|
@ -323,3 +322,66 @@ fieldset > label {
|
||||||
.ui-icon {
|
.ui-icon {
|
||||||
background-image: url(images/ui-icons_6495ED_256x240.png);
|
background-image: url(images/ui-icons_6495ED_256x240.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.issue-box {
|
||||||
|
border-radius: 6px 6px 0px 0px;
|
||||||
|
border: 3px solid silver;
|
||||||
|
}
|
||||||
|
|
||||||
|
.issue-box > h2 {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
.issue-box > div {
|
||||||
|
background-color: white;
|
||||||
|
color: black;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.issue-WARN {
|
||||||
|
border-color: yellow;
|
||||||
|
background-color: yellow;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
.issue-CRITICAL {
|
||||||
|
border-color: red;
|
||||||
|
background-color: red;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#CheckState {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
#CheckState.WARN, span#WARN {
|
||||||
|
color: yellow;
|
||||||
|
}
|
||||||
|
#CheckState.CRITICAL, span#CRITICAL{
|
||||||
|
color: RED;
|
||||||
|
}
|
||||||
|
|
||||||
|
.performance-value > div {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 8px;
|
||||||
|
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.performance-value > div:last {
|
||||||
|
margin-right: 0px;
|
||||||
|
}
|
||||||
|
.performance-value {
|
||||||
|
border-bottom: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.issue-box .performance-value > #chartBox {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.issue-box .performance-value {
|
||||||
|
position: relative;
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
.issue-box:hover .performance-value {
|
||||||
|
height: 250px;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue