WIP
parent
e492e6c7e4
commit
b617a7539e
|
@ -16,6 +16,7 @@ using ln.types.threads;
|
||||||
using ln.types.net;
|
using ln.types.net;
|
||||||
using ln.types.odb;
|
using ln.types.odb;
|
||||||
using ln.types.odb.index;
|
using ln.types.odb.index;
|
||||||
|
using ln.types.odb.values;
|
||||||
|
|
||||||
namespace ln.skyscanner
|
namespace ln.skyscanner
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@ using ln.types.net;
|
||||||
using ln.skyscanner.crawl;
|
using ln.skyscanner.crawl;
|
||||||
using ln.skyscanner.checks;
|
using ln.skyscanner.checks;
|
||||||
using ln.logging;
|
using ln.logging;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ln.skyscanner
|
namespace ln.skyscanner
|
||||||
{
|
{
|
||||||
|
@ -52,11 +53,11 @@ namespace ln.skyscanner
|
||||||
|
|
||||||
NodeCollection = ODB.GetCollection<Node>();
|
NodeCollection = ODB.GetCollection<Node>();
|
||||||
NodeCollection.EnableStrongCache(true);
|
NodeCollection.EnableStrongCache(true);
|
||||||
|
NodeCollection.EnsureIndex("uniqueIdentity", true);
|
||||||
NodeCollection.EnsureIndeces(
|
NodeCollection.EnsureIndeces(
|
||||||
"PrimaryIP",
|
"PrimaryIP",
|
||||||
"Interfaces[].ConfiguredIPs[].IP",
|
"Interfaces[].ConfiguredIPs[].IP",
|
||||||
"Interfaces[].ConfiguredIPs[].Network",
|
"Interfaces[].ConfiguredIPs[].Network"
|
||||||
"uniqueIdentity"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Network4 n192 = Network4.Parse("192.168.0.0/16");
|
Network4 n192 = Network4.Parse("192.168.0.0/16");
|
||||||
|
@ -83,6 +84,7 @@ namespace ln.skyscanner
|
||||||
SkyCheckStates = ODB.GetCollection<SkyCheckState>();
|
SkyCheckStates = ODB.GetCollection<SkyCheckState>();
|
||||||
SkyCheckStates.EnableStrongCache(true);
|
SkyCheckStates.EnableStrongCache(true);
|
||||||
SkyCheckStates.EnsureIndeces("Node");
|
SkyCheckStates.EnsureIndeces("Node");
|
||||||
|
SkyCheckStates.EnsureUniqueness("Node", "CheckName");
|
||||||
|
|
||||||
//foreach (SkyCheckState checkState in SkyCheckStates.ToArray())
|
//foreach (SkyCheckState checkState in SkyCheckStates.ToArray())
|
||||||
//{
|
//{
|
||||||
|
@ -95,6 +97,30 @@ namespace ln.skyscanner
|
||||||
GlobalNetwork = new GlobalNetwork();
|
GlobalNetwork = new GlobalNetwork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PerformanceValue LookupPerformanceValue(String perfName)
|
||||||
|
{
|
||||||
|
string[] resourcePath = perfName.Split('/');
|
||||||
|
|
||||||
|
Node node = NodeCollection.Query("uniqueIdentity", resourcePath[0]).FirstOrDefault();
|
||||||
|
if (node == null)
|
||||||
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
|
SkyCheckState skyCheckState = SkyCheckStates.Query(
|
||||||
|
Query.AND(
|
||||||
|
Query.Equals<SkyCheckState>("Node", node.ID),
|
||||||
|
Query.Equals<SkyCheckState>("CheckName", resourcePath[1])
|
||||||
|
)
|
||||||
|
).FirstOrDefault();
|
||||||
|
if (skyCheckState == null)
|
||||||
|
throw new KeyNotFoundException();
|
||||||
|
|
||||||
|
foreach (PerformanceValue performanceValue in skyCheckState.PerformanceValues)
|
||||||
|
if (performanceValue.PerfName.Equals(perfName))
|
||||||
|
return performanceValue;
|
||||||
|
|
||||||
|
throw new KeyNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,6 @@ namespace ln.skyscanner.checks
|
||||||
|
|
||||||
public override void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node)
|
public override void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node)
|
||||||
{
|
{
|
||||||
if ((checkState == null))
|
|
||||||
{
|
|
||||||
checkState = new SkyCheckState(this, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (URI snmpUri in node.FindURIs("snmp"))
|
foreach (URI snmpUri in node.FindURIs("snmp"))
|
||||||
{
|
{
|
||||||
using (SnmpInterface snmp = SnmpInterface.FromURI(snmpUri,skyChecker.SNMPEngine))
|
using (SnmpInterface snmp = SnmpInterface.FromURI(snmpUri,skyChecker.SNMPEngine))
|
||||||
|
|
|
@ -28,13 +28,22 @@ 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 Prepare()
|
||||||
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
foreach (SkyCheck check in SkyCheck.SkyChecks)
|
||||||
|
if (!checkStates.ContainsKey(check.Name) && check.IsValid(Node))
|
||||||
|
{
|
||||||
|
checkStates.Add(check.Name, check.PrepareCheckState(SkyScanner.Instance.Checker, Node));
|
||||||
|
SkyScanner.Instance.Entities.SkyCheckStates.Insert(checkStates[check.Name]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RunJob()
|
public override void RunJob()
|
||||||
|
|
|
@ -31,9 +31,6 @@ namespace ln.skyscanner.checks
|
||||||
|
|
||||||
public override void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node)
|
public override void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node)
|
||||||
{
|
{
|
||||||
if (checkState == null)
|
|
||||||
checkState = new SkyCheckState(this, node);
|
|
||||||
|
|
||||||
long roundTripTime = 0;
|
long roundTripTime = 0;
|
||||||
int success = 0;
|
int success = 0;
|
||||||
int n;
|
int n;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// **/
|
// **/
|
||||||
using System;
|
using System;
|
||||||
using ln.perfdb.storage;
|
using ln.perfdb.storage;
|
||||||
|
using Newtonsoft.Json;
|
||||||
namespace ln.skyscanner.checks
|
namespace ln.skyscanner.checks
|
||||||
{
|
{
|
||||||
public class PerformanceValue
|
public class PerformanceValue
|
||||||
|
@ -23,7 +24,6 @@ namespace ln.skyscanner.checks
|
||||||
public double CritLower { get; set; } = Double.MinValue;
|
public double CritLower { get; set; } = Double.MinValue;
|
||||||
public double CritUpper { get; set; } = Double.MaxValue;
|
public double CritUpper { get; set; } = Double.MaxValue;
|
||||||
|
|
||||||
|
|
||||||
private PerformanceValue()
|
private PerformanceValue()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,10 @@ namespace ln.skyscanner.checks
|
||||||
|
|
||||||
public abstract bool IsValid(Node node);
|
public abstract bool IsValid(Node node);
|
||||||
public abstract void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node);
|
public abstract void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node);
|
||||||
|
public virtual SkyCheckState PrepareCheckState(SkyChecker skyChecker,Node node)
|
||||||
|
{
|
||||||
|
return new SkyCheckState(this, node);
|
||||||
|
}
|
||||||
|
|
||||||
static SkyCheck()
|
static SkyCheck()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,10 +18,6 @@ namespace ln.skyscanner.checks
|
||||||
|
|
||||||
public override void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node)
|
public override void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node)
|
||||||
{
|
{
|
||||||
if ((checkState == null) || !(checkState is UbiquityCheckState))
|
|
||||||
{
|
|
||||||
checkState = new UbiquityCheckState(this, node);
|
|
||||||
}
|
|
||||||
UbiquityCheckState ubiquityCheckState = checkState as UbiquityCheckState;
|
UbiquityCheckState ubiquityCheckState = checkState as UbiquityCheckState;
|
||||||
|
|
||||||
foreach (URI snmpUri in node.FindURIs("snmp"))
|
foreach (URI snmpUri in node.FindURIs("snmp"))
|
||||||
|
@ -63,6 +59,11 @@ namespace ln.skyscanner.checks
|
||||||
{
|
{
|
||||||
return (node.Vendor != null) && node.Vendor.Equals("Ubiquity");
|
return (node.Vendor != null) && node.Vendor.Equals("Ubiquity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override SkyCheckState PrepareCheckState(SkyChecker skyChecker, Node node)
|
||||||
|
{
|
||||||
|
return new UbiquityCheckState(this, node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UbiquityCheckState : SkyCheckState
|
class UbiquityCheckState : SkyCheckState
|
||||||
|
|
|
@ -6,6 +6,9 @@ using ln.skyscanner.entities;
|
||||||
using ln.skyscanner.checks;
|
using ln.skyscanner.checks;
|
||||||
using ln.skyscanner.crawl;
|
using ln.skyscanner.crawl;
|
||||||
using ln.types.net;
|
using ln.types.net;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using ln.types.odb;
|
||||||
namespace ln.skyscanner.http
|
namespace ln.skyscanner.http
|
||||||
{
|
{
|
||||||
public class SkyScannerHttpApplication : ResourceApplication
|
public class SkyScannerHttpApplication : ResourceApplication
|
||||||
|
@ -48,6 +51,12 @@ namespace ln.skyscanner.http
|
||||||
new CollectionResource<SkyCheckState>(collections, skyScanner.Entities.SkyCheckStates);
|
new CollectionResource<SkyCheckState>(collections, skyScanner.Entities.SkyCheckStates);
|
||||||
|
|
||||||
new CollectionResource<Network4>(collections, skyScanner.Entities.BlockedNetworks);
|
new CollectionResource<Network4>(collections, skyScanner.Entities.BlockedNetworks);
|
||||||
|
|
||||||
|
ObjectContainerResource<PerformanceValue> resPerformanceValues = new ObjectContainerResource<PerformanceValue>(collections);
|
||||||
|
resPerformanceValues.GetResourceName = (pv) => pv.PerfName;
|
||||||
|
resPerformanceValues.Enumeration = () => skyScanner.Entities.SkyCheckStates.SelectMany((checkState) => checkState.PerformanceValues);
|
||||||
|
resPerformanceValues.Lookup = skyScanner.Entities.LookupPerformanceValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Resource ResourceTypeHook(DirectoryResource directoryResource, FileInfo fileInfo)
|
private Resource ResourceTypeHook(DirectoryResource directoryResource, FileInfo fileInfo)
|
||||||
|
|
Loading…
Reference in New Issue