broken
Harald Wolff 2019-04-18 16:34:17 +02:00
parent 2f5b2f9a92
commit 67f69d4b1e
6 changed files with 93 additions and 46 deletions

View File

@ -47,10 +47,11 @@ namespace ln.skyscanner
{
SNMPEngine.DefaultEngine.Timeout = 3500;
if (SkyScanner.Instance.Entities.BlockedNetworks.Count == 0)
{
if (!SkyScanner.Instance.Entities.BlockedNetworks.Contains(Network4.Parse("192.168.0.0/16")))
SkyScanner.Instance.Entities.BlockedNetworks.Insert(Network4.Parse("192.168.0.0/16"));
}
if (!SkyScanner.Instance.Entities.BlockedNetworks.Contains(Network4.Parse("10.200.0.0/16")))
SkyScanner.Instance.Entities.BlockedNetworks.Insert(Network4.Parse("10.200.0.0/16"));
//using (ODB odb = new ODB("odb"))

View File

@ -54,6 +54,9 @@ namespace ln.skyscanner.checks
checkState.WritePerformanceValue("rta", roundTripTime, 0, 80, 0, 140);
}
foreach (PerformanceValue pv in checkState.PerformanceValues)
pv.IgnoreLimits = ((node.DeviceType == DeviceType.UNKNOWN) && (node.DeviceType == DeviceType.PTMP));
checkState.BaseCheckState = CheckState.OK;
}
}

View File

@ -24,6 +24,8 @@ namespace ln.skyscanner.checks
public double CritLower { get; set; } = Double.MinValue;
public double CritUpper { get; set; } = Double.MaxValue;
public bool IgnoreLimits;
private PerformanceValue()
{
}
@ -55,6 +57,9 @@ namespace ln.skyscanner.checks
{
get
{
if (IgnoreLimits)
return CheckState.OK;
if ((LastValue < CritLower) || (LastValue > CritUpper))
return CheckState.CRITICAL;
if ((LastValue < WarnLower) || (LastValue > WarnUpper))

View File

@ -7,23 +7,23 @@
</div>
<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 row">
<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 row">
<div class="">
<div id="CRITICAL"></div>
<div id="WARN"></div>
<div id="FAIL"></div>
<div id="ERROR"></div>
</div>
<div class="grow" style="">
<div id="Charts" class="grow" style="">
</div>
</div>
<div style="visibility: hidden;">
@ -47,19 +47,26 @@
</div>
<div id="chartBox" class="fill"><canvas id="chart"></canvas></div>
</div>
<div id="ChartBoxTemplate" class="fill"><canvas id="chart"></canvas></div>
</div>
<script type="text/javascript">
moment.defaultFormat = "DD.MM.YYYY HH:mm:ss";
var currentUpdateCycle = 0;
var issues = {}
var charts = []
var chartTimeout = null;
function graphLoaded(pv, performanceValue, perfData)
function graphLoaded(performanceValue, perfData)
{
var chartColor = performanceValue.CheckState == "CRITICAL" ? '#FF0000' : (performanceValue.CheckState == "WARN") ? '#C0C000' : '#000000';
var chart = new Chart( $("#chart", pv), {
var perfID = encodeID(performanceValue.PerfName);
var htmlChart = $("#" + perfID );
if (!htmlChart.length)
htmlChart = $("#ChartBoxTemplate").clone().attr("id", perfID ).appendTo( $("#Charts") );
var chart = new Chart( $("#chart", htmlChart) , {
type: 'bar',
data: {
datasets: [
@ -108,6 +115,21 @@
chart.update();
}
function showCharts(issue)
{
var htmlCharts = $("#Charts");
htmlCharts.empty();
$.each( issue.PerformanceValues, function(){
var currentIssue = this;
skyapi().getJson("api/checker/checks/" + encodeURIComponent(this.PerfName) + "?interval=" + $("#interval").children("option:selected").val(), function(perfData){
graphLoaded(currentIssue, perfData);
});
});
}
function updateIssue(issue)
{
var ne = $("#" + issue.ID );
@ -121,10 +143,14 @@
ne.appendTo(p);
}
ne.data( "MyIssue", issue );
ne.attr( "CurrentUpdateCycle", currentUpdateCycle );
ne.removeClass("issue-WARN issue-CRITICAL");
ne.addClass("issue-" + issue.CheckState );
$("h2", ne).text(issue.CheckName + ": " + issue.Node.Name + " ( " + issue.Node.UniqueIdentity + " )");
$("h2", ne).text( issue.Node.DeviceType + " " + issue.CheckName + ": " + issue.Node.Name + " ( " + issue.Node.UniqueIdentity + " )").on("click", function(e){
showCharts($(this).parent().data("MyIssue"));
});
$("#LastCheckTime", ne).text(issue.LastCheckTime);
$("#UnchangedTime", ne).text(issue.UnchangedTime);
@ -147,30 +173,7 @@
$.each( issue.PerformanceValues, function(){
pvparent.append( $("<span class='" + this.CheckState + "'>" + this.PerfName + "</span><br>") );
/*
var pv = $("#" + this.PerfName.replace(/[./]/g,""), ne);
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);
var pvparent = $("#PerfValues", ne);
if (!pvparent.is(pv.parent()))
{
pv.detach();
pv.appendTo(pvparent);
}
var _perfValue = this;
var _pv = pv;
var perfName = this.PerfName;
charts.push( { pv: _pv, performanceValue: this } );
*/
});
//loadNextChart();
});
}
function loadNextChart()
@ -193,11 +196,42 @@
}
}
function updateIssueList(issueList)
{
{
currentUpdateCycle++;
$.each( issueList , function(){
updateIssue(this);
if (this.Node.DeviceType != "UNKNOWN")
updateIssue(this);
});
$.each( $("div#CRITICAL > div"), function(){
var c = $(this);
var cuc = $(this).attr("CurrentUpdateCycle");
if ($(this).attr("CurrentUpdateCycle") != currentUpdateCycle){
$(this).detach();
}
});
$.each( $("div#WARN > div"), function(){
var c = $(this);
var cuc = $(this).attr("CurrentUpdateCycle");
if ($(this).attr("CurrentUpdateCycle") != currentUpdateCycle){
$(this).detach();
}
});
$.each( $("div#FAIL > div"), function(){
var c = $(this);
var cuc = $(this).attr("CurrentUpdateCycle");
if ($(this).attr("CurrentUpdateCycle") != currentUpdateCycle){
$(this).detach();
}
});
$.each( $("div#ERROR > div"), function(){
var c = $(this);
var cuc = $(this).attr("CurrentUpdateCycle");
if ($(this).attr("CurrentUpdateCycle") != currentUpdateCycle){
$(this).detach();
}
});
$("#nCRITICAL").text( $("#CRITICAL > div").length );

View File

@ -22,7 +22,6 @@
<body>
<script type="text/javascript">
$( document ).tooltip();
skyapi().setBaseURL("http://localhost:8080/");
setInterval( updateStatistics, 1000 );
</script>

View File

@ -6,6 +6,11 @@
return values;
}
function encodeID( t )
{
return ("" + t).replace( /[\.\/]/g, "_");
}
function SKYAPI(baseurl){
this.baseurl = baseurl;
@ -175,7 +180,7 @@ function updateStatistics()
}
var __skyapi = new SKYAPI("");
var __skyapi = new SKYAPI("/");
function skyapi()
{