WIP
parent
29d59bc13a
commit
30b9980a51
|
@ -41,6 +41,7 @@ namespace ln.skyscanner
|
|||
nodeCollection = odDatabase.GetCollection<Node>();
|
||||
subnetCollection = odDatabase.GetCollection<Subnet>();
|
||||
|
||||
nodeCollection.EnableStrongCache(true);
|
||||
nodeCollection.EnsureIndex("PrimaryIP");
|
||||
nodeCollection.EnsureIndex("Interfaces[].ConfiguredIPs[].IP");
|
||||
nodeCollection.EnsureIndex("Interfaces[].ConfiguredIPs[].Network");
|
||||
|
|
|
@ -33,6 +33,8 @@ namespace ln.skyscanner.checks
|
|||
SkyCheckState[] skyCheckStates = SkyScanner.Instance.Checker.checkStates.Query(stateQuery).ToArray();
|
||||
foreach (SkyCheckState checkState in skyCheckStates)
|
||||
{
|
||||
//if (checkState.Node == null)
|
||||
//checkState.Node = node;
|
||||
checkStates.Add(checkState.CheckName, checkState);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,11 +54,11 @@ namespace ln.skyscanner.checks
|
|||
|
||||
float fSuccess = (float)success / (float)n;
|
||||
|
||||
skyChecker.WritePerfValue(this,"replies",node,fSuccess);
|
||||
skyChecker.WritePerfValue(this,checkState,"replies",node,fSuccess);
|
||||
if (success > 0)
|
||||
{
|
||||
roundTripTime /= success;
|
||||
skyChecker.WritePerfValue(this, "rta", node, roundTripTime);
|
||||
skyChecker.WritePerfValue(this, checkState, "rta", node, roundTripTime);
|
||||
}
|
||||
SetState(checkState, fSuccess);
|
||||
}
|
||||
|
|
|
@ -14,11 +14,24 @@ using Newtonsoft.Json;
|
|||
using Newtonsoft.Json.Converters;
|
||||
using System.Linq;
|
||||
using ln.types.odb.attributes;
|
||||
using System.Collections.Generic;
|
||||
namespace ln.skyscanner.checks
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum CheckState { OK, WARN, CRITICAL, FAIL, ERROR }
|
||||
|
||||
public struct CheckStateChange
|
||||
{
|
||||
public CheckState NewState;
|
||||
public DateTime Timestamp;
|
||||
|
||||
public CheckStateChange(CheckState checkState)
|
||||
{
|
||||
NewState = checkState;
|
||||
Timestamp = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
public class SkyCheckState
|
||||
{
|
||||
[DocumentID]
|
||||
|
@ -27,8 +40,8 @@ namespace ln.skyscanner.checks
|
|||
public readonly String CheckName;
|
||||
public readonly String UniqueNodeIdentifier;
|
||||
|
||||
[ByReference]
|
||||
public Node Node;
|
||||
public String[] PerformanceValues => performanceValues.ToArray();
|
||||
List<String> performanceValues = new List<String>();
|
||||
|
||||
public DateTime LastCheckTime { get; set; }
|
||||
|
||||
|
@ -37,7 +50,11 @@ namespace ln.skyscanner.checks
|
|||
public double CritLower { get; set; } = Double.MinValue;
|
||||
public double CritUpper { get; set; } = Double.MaxValue;
|
||||
|
||||
public CheckState CheckState { get; set; }
|
||||
public CheckState CheckState { get => currentCheckState; set { if (currentCheckState != value) history.Add(new CheckStateChange(value)); currentCheckState = value; } }
|
||||
CheckState currentCheckState;
|
||||
|
||||
public CheckStateChange[] History => history.ToArray();
|
||||
List<CheckStateChange> history = new List<CheckStateChange>();
|
||||
|
||||
protected SkyCheckState()
|
||||
{
|
||||
|
@ -47,5 +64,21 @@ namespace ln.skyscanner.checks
|
|||
CheckName = skyCheck.Name;
|
||||
UniqueNodeIdentifier = node.UniqueIdentity;
|
||||
}
|
||||
|
||||
public void EnsurePerformanceValue(String perfName)
|
||||
{
|
||||
if (performanceValues == null)
|
||||
performanceValues = new List<string>();
|
||||
|
||||
if (!performanceValues.Contains(perfName))
|
||||
performanceValues.Add(perfName);
|
||||
}
|
||||
|
||||
|
||||
public class PerformanceValue
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,17 @@ namespace ln.skyscanner.checks
|
|||
public string[] PerfNames => perfFiles.Keys.ToArray();
|
||||
public bool ContainsPerfFile(String perfName) => perfFiles.ContainsKey(perfName);
|
||||
|
||||
[Callable]
|
||||
public SkyCheckState[] Issues => checkStates.Query(
|
||||
//Query.Contains<SkyCheckState,CheckState>("CheckState",new CheckState[] { CheckState.CRITICAL, CheckState.WARN, CheckState.ERROR })
|
||||
Query.OR(
|
||||
Query.Equals<SkyCheckState>("currentCheckState", CheckState.CRITICAL),
|
||||
Query.Equals<SkyCheckState>("currentCheckState", CheckState.FAIL),
|
||||
Query.Equals<SkyCheckState>("currentCheckState", CheckState.WARN)
|
||||
)
|
||||
).ToArray();
|
||||
|
||||
|
||||
public SNMPEngine SNMPEngine { get; }
|
||||
|
||||
BTree<string, PerfFile> perfFiles = new BTree<string, PerfFile>();
|
||||
|
@ -62,6 +73,7 @@ namespace ln.skyscanner.checks
|
|||
|
||||
odb = new ODB(Path.Combine(BasePath));
|
||||
checkStates = odb.GetCollection<SkyCheckState>();
|
||||
checkStates.EnableStrongCache(true);
|
||||
checkStates.EnsureIndex("CheckName");
|
||||
checkStates.EnsureIndex("UniqueNodeIdentifier");
|
||||
}
|
||||
|
@ -100,9 +112,9 @@ namespace ln.skyscanner.checks
|
|||
perfFiles.Clear();
|
||||
}
|
||||
|
||||
public void WritePerfValue(SkyCheck skyCheck,String vName,Node node,double value)
|
||||
public void WritePerfValue(SkyCheck skyCheck,SkyCheckState checkState,String vName,Node node,double value)
|
||||
{
|
||||
PerfFile perfFile = GetPerfFile(skyCheck, vName, node);
|
||||
PerfFile perfFile = GetPerfFile(skyCheck, checkState, vName, node);
|
||||
lock (perfFile)
|
||||
{
|
||||
perfFile.EnsureOpen();
|
||||
|
@ -116,7 +128,7 @@ namespace ln.skyscanner.checks
|
|||
return perfFiles[perfName];
|
||||
}
|
||||
|
||||
private PerfFile GetPerfFile(SkyCheck skyCheck, String vName, Node node)
|
||||
private PerfFile GetPerfFile(SkyCheck skyCheck,SkyCheckState checkState,String vName, Node node)
|
||||
{
|
||||
String checkPath = String.Format("{0}_{1}", node.UniqueIdentity, skyCheck.Name);
|
||||
String perfName = String.Format("{0}_{1}",checkPath,vName);
|
||||
|
@ -125,6 +137,7 @@ namespace ln.skyscanner.checks
|
|||
{
|
||||
SkyScanner.Instance.Entities.nodeCollection.Upsert(node);
|
||||
}
|
||||
checkState.EnsurePerformanceValue(perfName);
|
||||
|
||||
lock (this)
|
||||
{
|
||||
|
|
|
@ -39,10 +39,10 @@ namespace ln.skyscanner.checks
|
|||
|
||||
foreach (Sequence[] row in ptp)
|
||||
{
|
||||
skyChecker.WritePerfValue(this, "ptp_rx_capa", node, (double)((Integer)(row[0].Items[1])).LongValue);
|
||||
skyChecker.WritePerfValue(this, "ptp_tx_capa", node, (double)((Integer)(row[1].Items[1])).LongValue);
|
||||
skyChecker.WritePerfValue(this, "ptp_rx_pwr", node, (double)((Integer)(row[2].Items[1])).LongValue);
|
||||
skyChecker.WritePerfValue(this, "ptp_tx_pwr", node, (double)((Integer)(row[3].Items[1])).LongValue);
|
||||
skyChecker.WritePerfValue(this, checkState, "ptp_rx_capa", node, (double)((Integer)(row[0].Items[1])).LongValue);
|
||||
skyChecker.WritePerfValue(this, checkState, "ptp_tx_capa", node, (double)((Integer)(row[1].Items[1])).LongValue);
|
||||
skyChecker.WritePerfValue(this, checkState, "ptp_rx_pwr", node, (double)((Integer)(row[2].Items[1])).LongValue);
|
||||
skyChecker.WritePerfValue(this, checkState, "ptp_tx_pwr", node, (double)((Integer)(row[3].Items[1])).LongValue);
|
||||
|
||||
long rxBytes = ((Integer)(row[4].Items[1])).LongValue;
|
||||
long txBytes = ((Integer)(row[5].Items[1])).LongValue;
|
||||
|
@ -50,8 +50,8 @@ namespace ln.skyscanner.checks
|
|||
ubiquityCheckState.RXRate.Update(rxBytes * 8);
|
||||
ubiquityCheckState.TXRate.Update(txBytes * 8);
|
||||
|
||||
skyChecker.WritePerfValue(this, "ptp_rx_rate", node, ubiquityCheckState.RXRate.Current);
|
||||
skyChecker.WritePerfValue(this, "ptp_tx_rate", node, ubiquityCheckState.TXRate.Current);
|
||||
skyChecker.WritePerfValue(this, checkState, "ptp_rx_rate", node, ubiquityCheckState.RXRate.Current);
|
||||
skyChecker.WritePerfValue(this, checkState, "ptp_tx_rate", node, ubiquityCheckState.TXRate.Current);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -196,6 +196,9 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="templates\static\css\images\ui-icons_6495ED_256x240.png" />
|
||||
<None Include="templates\static\checks\issues.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="identify\" />
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<%frame "frame.html"%>
|
||||
|
||||
<h1>Aktuelle Störfälle</h1>
|
||||
<br/>
|
||||
|
||||
<div class="flex column">
|
||||
<div id="issueList">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="nodetemplate" style="visibility: hidden;">
|
||||
<div class="ui-message" style="margin-bottom: 16px;">
|
||||
<h2 id="UniqueIdentity"></h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var issues = []
|
||||
var nodes = {}
|
||||
var nodeIssues = {}
|
||||
|
||||
function updateIssueList(issueList)
|
||||
{
|
||||
$.each( issueList, function(){
|
||||
if (this.Node)
|
||||
{
|
||||
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(){
|
||||
var ne = $("#" + this.UniqueIdentity );
|
||||
if (!ne.length)
|
||||
ne = $("#nodetemplate div").clone().attr("id",this.UniqueIdentity).appendTo($("#issueList"));
|
||||
|
||||
$("#UniqueIdentity", ne).text(this.UniqueIdentity);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
skyapi().getJson("/checker/Issues", updateIssueList );
|
||||
|
||||
</script>
|
|
@ -1,7 +1,7 @@
|
|||
<div class="popup">Netz Status
|
||||
<div>
|
||||
<div>
|
||||
<a href="/static/summary.html"><div>Störfälle</div></a>
|
||||
<a href="/static/checks/issues.html"><div>Störfälle</div></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue