WIP
parent
895231b820
commit
8ff5178378
|
@ -62,8 +62,8 @@ namespace ln.skyscanner
|
||||||
|
|
||||||
if (Arguments["import-skytron"].IsSet)
|
if (Arguments["import-skytron"].IsSet)
|
||||||
{
|
{
|
||||||
SkytronImport si = new SkytronImport(Arguments["import-skytron"].Value);
|
//SkytronImport si = new SkytronImport(Arguments["import-skytron"].Value);
|
||||||
si.Import();
|
//si.Import();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Arguments["benchmark"].IsSet)
|
if (Arguments["benchmark"].IsSet)
|
||||||
|
@ -103,7 +103,7 @@ namespace ln.skyscanner
|
||||||
|
|
||||||
public class Service : ApplicationServiceBase
|
public class Service : ApplicationServiceBase
|
||||||
{
|
{
|
||||||
public WebSocketInterface webSocketInterface { get; private set; }
|
public ApplicationWebSocket webSocketInterface { get; private set; }
|
||||||
public RPCContainer RPCContainer { get; private set; }
|
public RPCContainer RPCContainer { get; private set; }
|
||||||
|
|
||||||
public Service()
|
public Service()
|
||||||
|
@ -130,7 +130,7 @@ namespace ln.skyscanner
|
||||||
|
|
||||||
rootResource.DefaultResource = staticTemplates;
|
rootResource.DefaultResource = staticTemplates;
|
||||||
|
|
||||||
webSocketInterface = new WebSocketInterface(rootResource, this);
|
webSocketInterface = new ApplicationWebSocket(rootResource, "socket", RPCContainer);
|
||||||
|
|
||||||
RPCContainer.Add("", new SkyScannerRpc(this));
|
RPCContainer.Add("", new SkyScannerRpc(this));
|
||||||
RPCContainer.Add("ServiceContainer",applicationInterface.ServiceContainer.RPC);
|
RPCContainer.Add("ServiceContainer",applicationInterface.ServiceContainer.RPC);
|
||||||
|
@ -200,62 +200,62 @@ namespace ln.skyscanner
|
||||||
|
|
||||||
public void BenchmarkODB()
|
public void BenchmarkODB()
|
||||||
{
|
{
|
||||||
int maxIterations = 10000;
|
//int maxIterations = 10000;
|
||||||
|
|
||||||
for (int i = 0; i < maxIterations; i++)
|
//for (int i = 0; i < maxIterations; i++)
|
||||||
{
|
//{
|
||||||
int n = 0;
|
// int n = 0;
|
||||||
Logging.Log(LogLevel.INFO, "Benchmark ODB: Iteration {0} of {1}", i, maxIterations);
|
// Logging.Log(LogLevel.INFO, "Benchmark ODB: Iteration {0} of {1}", i, maxIterations);
|
||||||
|
|
||||||
foreach (SkyCheckState checkState in SkyScanner.Instance.Entities.SkyCheckStates.ToArray())
|
// foreach (SkyCheckState checkState in SkyScanner.Instance.Entities.SkyCheckStates.ToArray())
|
||||||
{
|
// {
|
||||||
SkyScanner.Instance.Entities.SkyCheckStates.Upsert(checkState);
|
// SkyScanner.Instance.Entities.SkyCheckStates.Upsert(checkState);
|
||||||
n++;
|
// n++;
|
||||||
}
|
// }
|
||||||
|
|
||||||
Logging.Log(LogLevel.INFO, "Saved {0} SkyCheckStates", n);
|
// Logging.Log(LogLevel.INFO, "Saved {0} SkyCheckStates", n);
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CrawlHost(IPv4 ip)
|
public void CrawlHost(IPv4 ip)
|
||||||
{
|
{
|
||||||
Logger.ConsoleLogger.MaxLogLevel = LogLevel.DEBUGFULL;
|
//Logger.ConsoleLogger.MaxLogLevel = LogLevel.DEBUGFULL;
|
||||||
|
|
||||||
CrawledHost crawledHost = new CrawledHost();
|
//CrawledHost crawledHost = new CrawledHost();
|
||||||
crawledHost.Name = ip.ToString();
|
//crawledHost.Name = ip.ToString();
|
||||||
crawledHost.PrimaryIP = ip;
|
//crawledHost.PrimaryIP = ip;
|
||||||
crawledHost.IPAddresses = new IPv4[] { ip };
|
//crawledHost.IPAddresses = new IPv4[] { ip };
|
||||||
|
|
||||||
Crawl crawl = new Crawl(Crawler, crawledHost);
|
//Crawl crawl = new Crawl(Crawler, crawledHost);
|
||||||
crawl.Prepare();
|
//crawl.Prepare();
|
||||||
crawl.RunJob();
|
//crawl.RunJob();
|
||||||
|
|
||||||
Logging.Log(LogLevel.INFO, "CrawledHost: {0}", JSONObject.From(crawledHost).ToString());
|
//Logging.Log(LogLevel.INFO, "CrawledHost: {0}", JSONObject.From(crawledHost).ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DebugCheck(String uniqueID)
|
public void DebugCheck(String uniqueID)
|
||||||
{
|
{
|
||||||
Logger.ConsoleLogger.MaxLogLevel = LogLevel.DEBUGFULL;
|
//Logger.ConsoleLogger.MaxLogLevel = LogLevel.DEBUGFULL;
|
||||||
|
|
||||||
Node node = Entities.NodeCollection.Query("uniqueIdentity", uniqueID).FirstOrDefault();
|
//Node node = Entities.NodeCollection.Query("uniqueIdentity", uniqueID).FirstOrDefault();
|
||||||
if (node == null)
|
//if (node == null)
|
||||||
{
|
//{
|
||||||
Logging.Log(LogLevel.INFO, "DebugCheck(): Node not found: uniqueIdentity={0}", uniqueID);
|
// Logging.Log(LogLevel.INFO, "DebugCheck(): Node not found: uniqueIdentity={0}", uniqueID);
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
Logging.Log(LogLevel.INFO, "DebugCheck(): Node: {0}",JSONObject.From(node).ToString());
|
// Logging.Log(LogLevel.INFO, "DebugCheck(): Node: {0}",JSONObject.From(node).ToString());
|
||||||
CheckJob checkJob = new CheckJob(null, node);
|
// CheckJob checkJob = new CheckJob(null, node);
|
||||||
|
|
||||||
Logging.Log(LogLevel.INFO, "Prepare...");
|
// Logging.Log(LogLevel.INFO, "Prepare...");
|
||||||
checkJob.Prepare();
|
// checkJob.Prepare();
|
||||||
|
|
||||||
Logging.Log(LogLevel.INFO, "Check...");
|
// Logging.Log(LogLevel.INFO, "Check...");
|
||||||
checkJob.RunJob();
|
// checkJob.RunJob();
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,6 @@ namespace ln.skyscanner.entities
|
||||||
public IEnumerable<IPv4> IPAdresses => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.IP));
|
public IEnumerable<IPv4> IPAdresses => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.IP));
|
||||||
[JSONMapping(Private = true)]
|
[JSONMapping(Private = true)]
|
||||||
public IEnumerable<Network4> Networks => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.Network)).Distinct();
|
public IEnumerable<Network4> Networks => Interfaces.SelectMany(intf => intf.ConfiguredIPs.Select(nip => nip.Network)).Distinct();
|
||||||
[JSONMapping(Private = true)]
|
|
||||||
public IEnumerable<Subnet> Subnets => SkyScanner.Instance.Entities.SubnetCollection.Query(Query.Equals<Network4>("Network", Networks.Select(net => net.Network)));
|
|
||||||
|
|
||||||
private string uniqueIdentity;
|
private string uniqueIdentity;
|
||||||
public String UniqueIdentity {
|
public String UniqueIdentity {
|
||||||
|
|
|
@ -36,6 +36,10 @@ namespace ln.skyscanner.entities
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("[PointOfPresence ID={0} Name={1} ForeignName={2}]",ID,Name,ForeignName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,29 +37,7 @@ namespace ln.skyscanner.http
|
||||||
|
|
||||||
RootResource.DefaultResource = staticTemplates;
|
RootResource.DefaultResource = staticTemplates;
|
||||||
|
|
||||||
refEntities = new ReflectiveResource(RootResource, "entities", SkyScanner.Entities);
|
|
||||||
refChecker = new ReflectiveResource(RootResource, "checker", SkyScanner.Checker);
|
|
||||||
|
|
||||||
SkyScannerHttpApi api = new SkyScannerHttpApi(this);
|
SkyScannerHttpApi api = new SkyScannerHttpApi(this);
|
||||||
|
|
||||||
BaseResource collections = new BaseResource(RootResource, "collections");
|
|
||||||
|
|
||||||
new CollectionResource<Node>(collections, skyScanner.Entities.NodeCollection);
|
|
||||||
new CollectionResource<Subnet>(collections, skyScanner.Entities.SubnetCollection);
|
|
||||||
new CollectionResource<PointOfPresence>(collections, skyScanner.Entities.PointOfPresenceCollection);
|
|
||||||
|
|
||||||
new CollectionResource<CrawledHost>(collections, skyScanner.Entities.CrawledHosts);
|
|
||||||
new CollectionResource<CrawledSubnet>(collections, skyScanner.Entities.CrawledSubnets);
|
|
||||||
|
|
||||||
new CollectionResource<SkyCheckState>(collections, skyScanner.Entities.SkyCheckStates);
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
using System;
|
|
||||||
using ln.http.resources.websocket;
|
|
||||||
using ln.http.resources;
|
|
||||||
using ln.logging;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using ln.http.websocket;
|
|
||||||
using System.Linq;
|
|
||||||
using ln.types.rpc;
|
|
||||||
using ln.json;
|
|
||||||
using ln.json.mapping;
|
|
||||||
|
|
||||||
namespace ln.skyscanner.http
|
|
||||||
{
|
|
||||||
public class WebSocketInterface : WebsocketResource
|
|
||||||
{
|
|
||||||
SkyScanner.Service SkyScannerService { get; }
|
|
||||||
|
|
||||||
public WebSocket[] CurrentWebSockets {
|
|
||||||
get
|
|
||||||
{
|
|
||||||
lock (currentWebSockets)
|
|
||||||
{
|
|
||||||
return currentWebSockets.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HashSet<WebSocket> currentWebSockets = new HashSet<WebSocket>();
|
|
||||||
|
|
||||||
public WebSocketInterface(Resource container,SkyScanner.Service skyscannerService)
|
|
||||||
:base(container,"socket")
|
|
||||||
{
|
|
||||||
SkyScannerService = skyscannerService;
|
|
||||||
Connection += WebSocketInterface_Connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebSocketInterface_Connection(WebsocketResource webSocketResource, ln.http.websocket.WebSocket webSocket, WSREvent ev)
|
|
||||||
{
|
|
||||||
lock (currentWebSockets)
|
|
||||||
{
|
|
||||||
switch (ev)
|
|
||||||
{
|
|
||||||
case WSREvent.CONNECT:
|
|
||||||
currentWebSockets.Add(webSocket);
|
|
||||||
break;
|
|
||||||
case WSREvent.CLOSE:
|
|
||||||
currentWebSockets.Remove(webSocket);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Broadcast(JSONObject json)
|
|
||||||
{
|
|
||||||
Broadcast(json.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Broadcast(String text)
|
|
||||||
{
|
|
||||||
foreach (WebSocket webSocket in CurrentWebSockets)
|
|
||||||
{
|
|
||||||
webSocket.Send(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void MessageReceived(WebSocketResourceRequestContext requestContext, string textMessage)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
JSONObject json = (JSONObject)JSONParser.Parse(textMessage);
|
|
||||||
RPCCall rpcCall = json.ToObject<RPCCall>();
|
|
||||||
|
|
||||||
RPCResult rpcResult = SkyScannerService.RPCContainer.Invoke(rpcCall);
|
|
||||||
|
|
||||||
requestContext.WebSocket.Send(
|
|
||||||
JSONObject.From(rpcResult).ToString()
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Logging.Log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||||
using ln.types.net;
|
using ln.types.net;
|
||||||
using ln.types;
|
using ln.types;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using ln.types.odb.ng;
|
||||||
namespace ln.skyscanner.import.skytron
|
namespace ln.skyscanner.import.skytron
|
||||||
{
|
{
|
||||||
public class SkytronImport
|
public class SkytronImport
|
||||||
|
@ -17,15 +18,15 @@ namespace ln.skyscanner.import.skytron
|
||||||
mysql = new MySqlConnection(connectionString);
|
mysql = new MySqlConnection(connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Import()
|
public void Import(Mapper mapper)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mysql.Open();
|
mysql.Open();
|
||||||
|
|
||||||
ImportStammdaten();
|
ImportStammdaten(mapper);
|
||||||
ImportNodes();
|
ImportNodes(mapper);
|
||||||
ImportL2Segmente();
|
ImportL2Segmente(mapper);
|
||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -38,7 +39,7 @@ namespace ln.skyscanner.import.skytron
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImportStammdaten()
|
public void ImportStammdaten(Mapper mapper)
|
||||||
{
|
{
|
||||||
MySqlCommand command = mysql.CreateCommand();
|
MySqlCommand command = mysql.CreateCommand();
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ namespace ln.skyscanner.import.skytron
|
||||||
|
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
PointOfPresence pop = SkyScanner.Instance.Entities.PointOfPresenceCollection.Query("ForeignName", reader.GetInt32("senderid").ToString()).FirstOrDefault();
|
PointOfPresence pop = mapper.Load<PointOfPresence>(Query.Equals<PointOfPresence>("ForeignName", reader.GetInt32("senderid").ToString())).FirstOrDefault();
|
||||||
if (pop == null)
|
if (pop == null)
|
||||||
{
|
{
|
||||||
Logging.Log(LogLevel.INFO, "New PoP: {0} / {1}", reader.GetInt32("senderid"), reader.GetString("stationsname"));
|
Logging.Log(LogLevel.INFO, "New PoP: {0} / {1}", reader.GetInt32("senderid"), reader.GetString("stationsname"));
|
||||||
|
@ -63,13 +64,18 @@ namespace ln.skyscanner.import.skytron
|
||||||
if (!String.Empty.Equals(lati) && !String.Empty.Equals(longi))
|
if (!String.Empty.Equals(lati) && !String.Empty.Equals(longi))
|
||||||
pop.GeoLocation = new GeoLocation(float.Parse(lati,CultureInfo.InvariantCulture.NumberFormat),float.Parse(longi, CultureInfo.InvariantCulture.NumberFormat));
|
pop.GeoLocation = new GeoLocation(float.Parse(lati,CultureInfo.InvariantCulture.NumberFormat),float.Parse(longi, CultureInfo.InvariantCulture.NumberFormat));
|
||||||
|
|
||||||
SkyScanner.Instance.Entities.PointOfPresenceCollection.Insert(pop);
|
mapper.Save(pop);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logging.Log(LogLevel.INFO, "Known PoP: {0}",pop);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImportNodes()
|
public void ImportNodes(Mapper mapper)
|
||||||
{
|
{
|
||||||
MySqlCommand command = mysql.CreateCommand();
|
MySqlCommand command = mysql.CreateCommand();
|
||||||
|
|
||||||
|
@ -82,7 +88,7 @@ namespace ln.skyscanner.import.skytron
|
||||||
String id = reader.GetString("id");
|
String id = reader.GetString("id");
|
||||||
IPv4 primaryIP = IPv4.Parse(reader.GetString("ip"));
|
IPv4 primaryIP = IPv4.Parse(reader.GetString("ip"));
|
||||||
|
|
||||||
Node node = SkyScanner.Instance.Entities.NodeCollection.Query("uniqueIdentity", id).FirstOrDefault();
|
Node node = mapper.Load<Node>(Query.Equals<Node>("uniqueIdentity", id)).FirstOrDefault();
|
||||||
if (node == null)
|
if (node == null)
|
||||||
{
|
{
|
||||||
node = new Node(primaryIP);
|
node = new Node(primaryIP);
|
||||||
|
@ -136,13 +142,12 @@ namespace ln.skyscanner.import.skytron
|
||||||
|
|
||||||
node.Severity = CheckSeverity.PRODUCTION;
|
node.Severity = CheckSeverity.PRODUCTION;
|
||||||
|
|
||||||
SkyScanner.Instance.Entities.NodeCollection.Upsert(node);
|
mapper.Save(node);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImportL2Segmente()
|
public void ImportL2Segmente(Mapper mapper)
|
||||||
{
|
{
|
||||||
MySqlCommand command = mysql.CreateCommand();
|
MySqlCommand command = mysql.CreateCommand();
|
||||||
|
|
||||||
|
@ -153,7 +158,7 @@ namespace ln.skyscanner.import.skytron
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
Network4 net4 = Network4.Parse(reader.GetString("cidr"));
|
Network4 net4 = Network4.Parse(reader.GetString("cidr"));
|
||||||
L2Segment l2 = SkyScanner.Instance.Entities.L2SegmentCollection.Query("Network", net4).FirstOrDefault();
|
L2Segment l2 = mapper.Load<L2Segment>(Query.Equals<L2Segment>("Network", net4)).FirstOrDefault();
|
||||||
if (l2 == null)
|
if (l2 == null)
|
||||||
{
|
{
|
||||||
l2 = new L2Segment();
|
l2 = new L2Segment();
|
||||||
|
@ -166,33 +171,33 @@ namespace ln.skyscanner.import.skytron
|
||||||
String sid = reader.GetString("senderid1");
|
String sid = reader.GetString("senderid1");
|
||||||
if ((sid != null) && !String.Empty.Equals(sid))
|
if ((sid != null) && !String.Empty.Equals(sid))
|
||||||
{
|
{
|
||||||
PointOfPresence pop = SkyScanner.Instance.Entities.PointOfPresenceCollection.Query("ForeignName", sid).FirstOrDefault();
|
PointOfPresence pop = mapper.Load<PointOfPresence>(Query.Equals<PointOfPresence>("ForeignName", sid)).FirstOrDefault();
|
||||||
if (pop != null)
|
if (pop != null)
|
||||||
l2.PoPs.Add(pop);
|
l2.PoPs.Add(pop);
|
||||||
}
|
}
|
||||||
sid = reader.GetString("senderid2");
|
sid = reader.GetString("senderid2");
|
||||||
if ((sid != null) && !String.Empty.Equals(sid))
|
if ((sid != null) && !String.Empty.Equals(sid))
|
||||||
{
|
{
|
||||||
PointOfPresence pop = SkyScanner.Instance.Entities.PointOfPresenceCollection.Query("ForeignName", sid).FirstOrDefault();
|
PointOfPresence pop = mapper.Load<PointOfPresence>(Query.Equals<PointOfPresence>("ForeignName", sid)).FirstOrDefault();
|
||||||
if (pop != null)
|
if (pop != null)
|
||||||
l2.PoPs.Add(pop);
|
l2.PoPs.Add(pop);
|
||||||
}
|
}
|
||||||
sid = reader.GetString("senderid3");
|
sid = reader.GetString("senderid3");
|
||||||
if ((sid != null) && !String.Empty.Equals(sid))
|
if ((sid != null) && !String.Empty.Equals(sid))
|
||||||
{
|
{
|
||||||
PointOfPresence pop = SkyScanner.Instance.Entities.PointOfPresenceCollection.Query("ForeignName", sid).FirstOrDefault();
|
PointOfPresence pop = mapper.Load<PointOfPresence>(Query.Equals<PointOfPresence>("ForeignName", sid)).FirstOrDefault();
|
||||||
if (pop != null)
|
if (pop != null)
|
||||||
l2.PoPs.Add(pop);
|
l2.PoPs.Add(pop);
|
||||||
}
|
}
|
||||||
sid = reader.GetString("senderid4");
|
sid = reader.GetString("senderid4");
|
||||||
if ((sid != null) && !String.Empty.Equals(sid))
|
if ((sid != null) && !String.Empty.Equals(sid))
|
||||||
{
|
{
|
||||||
PointOfPresence pop = SkyScanner.Instance.Entities.PointOfPresenceCollection.Query("ForeignName", sid).FirstOrDefault();
|
PointOfPresence pop = mapper.Load<PointOfPresence>(Query.Equals<PointOfPresence>("ForeignName", sid)).FirstOrDefault();
|
||||||
if (pop != null)
|
if (pop != null)
|
||||||
l2.PoPs.Add(pop);
|
l2.PoPs.Add(pop);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkyScanner.Instance.Entities.L2SegmentCollection.Insert(l2);
|
mapper.Save(l2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,20 +30,8 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="Renci.SshNet">
|
|
||||||
<HintPath>..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="BouncyCastle.Crypto">
|
|
||||||
<HintPath>..\packages\BouncyCastle.1.8.5\lib\BouncyCastle.Crypto.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Google.Protobuf">
|
|
||||||
<HintPath>..\packages\Google.Protobuf.3.9.1\lib\net45\Google.Protobuf.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="MySql.Data">
|
|
||||||
<HintPath>..\packages\MySql.Data.8.0.17\lib\net452\MySql.Data.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.ComponentModel" />
|
<Reference Include="System.ComponentModel" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
|
@ -55,6 +43,18 @@
|
||||||
<Reference Include="System.Transactions" />
|
<Reference Include="System.Transactions" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="System.Net.Http.WebRequest" />
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
|
<Reference Include="BouncyCastle.Crypto">
|
||||||
|
<HintPath>packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Google.Protobuf">
|
||||||
|
<HintPath>packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Renci.SshNet">
|
||||||
|
<HintPath>packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MySql.Data">
|
||||||
|
<HintPath>packages\MySql.Data.8.0.17\lib\net452\MySql.Data.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
|
@ -88,7 +88,6 @@
|
||||||
<Compile Include="checks\Mimosa.cs" />
|
<Compile Include="checks\Mimosa.cs" />
|
||||||
<Compile Include="checks\SikluCheck.cs" />
|
<Compile Include="checks\SikluCheck.cs" />
|
||||||
<Compile Include="devices\Siklu.cs" />
|
<Compile Include="devices\Siklu.cs" />
|
||||||
<Compile Include="http\WebSocketInterface.cs" />
|
|
||||||
<Compile Include="services\CheckService.cs" />
|
<Compile Include="services\CheckService.cs" />
|
||||||
<Compile Include="services\CrawlService.cs" />
|
<Compile Include="services\CrawlService.cs" />
|
||||||
<Compile Include="services\EntityService.cs" />
|
<Compile Include="services\EntityService.cs" />
|
||||||
|
@ -96,7 +95,6 @@
|
||||||
<Compile Include="perfvalue\PerformanceValue.cs" />
|
<Compile Include="perfvalue\PerformanceValue.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
|
||||||
<None Include="templates\static\index.html">
|
<None Include="templates\static\index.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
@ -240,6 +238,7 @@
|
||||||
<None Include="crawl\service\SNMP.cs" />
|
<None Include="crawl\service\SNMP.cs" />
|
||||||
<None Include="crawl\service\TCP.cs" />
|
<None Include="crawl\service\TCP.cs" />
|
||||||
<None Include="crawl\service\Ubiquity.cs" />
|
<None Include="crawl\service\Ubiquity.cs" />
|
||||||
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="identify\" />
|
<Folder Include="identify\" />
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.skyscanner", "ln.skyscanner.csproj", "{8456AFA0-20E9-4566-A81A-3C0EDB12356F}"
|
||||||
|
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.http", "..\ln.http\ln.http.csproj", "{CEEEEB41-3059-46A2-A871-2ADE22C013D9}"
|
||||||
|
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.json", "..\ln.json\ln.json.csproj", "{D9342117-3249-4D8B-87C9-51A50676B158}"
|
||||||
|
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.perfdb", "..\ln.perfdb\ln.perfdb.csproj", "{D934C1E8-9215-4D8D-83B3-A296E4912792}"
|
||||||
|
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.templates", "..\ln.templates\ln.templates.csproj", "{AD0267BB-F08C-4BE1-A88D-010D49041761}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ln.types", "..\ln.types\ln.types.csproj", "{8D9AB9A5-E513-4BA7-A450-534F6456BF28}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="BouncyCastle" version="1.8.5" targetFramework="net47" />
|
<package id="BouncyCastle" version="1.8.3.1" targetFramework="net47" />
|
||||||
<package id="Google.Protobuf" version="3.9.1" targetFramework="net47" />
|
<package id="Google.Protobuf" version="3.6.1" targetFramework="net47" />
|
||||||
<package id="MySql.Data" version="8.0.17" targetFramework="net47" />
|
<package id="MySql.Data" version="8.0.17" targetFramework="net47" />
|
||||||
<package id="SSH.NET" version="2016.1.0" targetFramework="net47" />
|
<package id="SSH.NET" version="2016.1.0" targetFramework="net47" />
|
||||||
</packages>
|
</packages>
|
|
@ -10,6 +10,7 @@ using ln.types.threads;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ln.snmp;
|
using ln.snmp;
|
||||||
using ln.types.odb.ng;
|
using ln.types.odb.ng;
|
||||||
|
|
||||||
namespace ln.skyscanner.services
|
namespace ln.skyscanner.services
|
||||||
{
|
{
|
||||||
public class CheckService : ApplicationServiceBase
|
public class CheckService : ApplicationServiceBase
|
||||||
|
@ -28,6 +29,10 @@ namespace ln.skyscanner.services
|
||||||
SkyScanner.Service coreService;
|
SkyScanner.Service coreService;
|
||||||
CheckServiceRPC RPC;
|
CheckServiceRPC RPC;
|
||||||
|
|
||||||
|
Mapper SessionMapper { get; set; }
|
||||||
|
|
||||||
|
Dictionary<Node, CheckJob> checkJobs = new Dictionary<Node, CheckJob>();
|
||||||
|
|
||||||
public CheckService()
|
public CheckService()
|
||||||
:base("Check Service")
|
:base("Check Service")
|
||||||
{
|
{
|
||||||
|
@ -42,10 +47,10 @@ namespace ln.skyscanner.services
|
||||||
entityService = Dependency<EntityService>();
|
entityService = Dependency<EntityService>();
|
||||||
performanceValueService = Dependency<PerformanceValueService>();
|
performanceValueService = Dependency<PerformanceValueService>();
|
||||||
|
|
||||||
Dictionary<Node, CheckJob> checkJobs = new Dictionary<Node, CheckJob>();
|
|
||||||
HashSet<Node> currentNodes = new HashSet<Node>();
|
HashSet<Node> currentNodes = new HashSet<Node>();
|
||||||
|
|
||||||
checkPool = new Pool(96);
|
checkPool = new Pool(96);
|
||||||
|
checkPool.PoolJobFinished += PoolJobFinished;
|
||||||
|
|
||||||
SNMPEngine = new SNMPEngine();
|
SNMPEngine = new SNMPEngine();
|
||||||
SNMPEngine.Timeout = 2000;
|
SNMPEngine.Timeout = 2000;
|
||||||
|
@ -55,40 +60,20 @@ namespace ln.skyscanner.services
|
||||||
RPC = new CheckServiceRPC(this);
|
RPC = new CheckServiceRPC(this);
|
||||||
coreService.RPCContainer.Add("CheckService",RPC);
|
coreService.RPCContainer.Add("CheckService",RPC);
|
||||||
|
|
||||||
|
using (Session session = new Session(entityService.StorageContainer))
|
||||||
|
{
|
||||||
|
SessionMapper = new Mapper(session);
|
||||||
|
|
||||||
Ready();
|
Ready();
|
||||||
|
|
||||||
while (!StopRequested)
|
while (!StopRequested)
|
||||||
{
|
{
|
||||||
Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): scheduler starts");
|
Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): scheduler starts");
|
||||||
|
|
||||||
currentNodes.Clear();
|
UpdateNodeList();
|
||||||
foreach (Node node in entityService.NodeCollection)
|
|
||||||
{
|
|
||||||
currentNodes.Add(node);
|
|
||||||
if (!checkJobs.ContainsKey(node))
|
|
||||||
{
|
|
||||||
CheckJob checkJob = new CheckJob(this,node);
|
|
||||||
checkJobs.Add(node, checkJob);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (Node node in checkJobs.Keys.ToArray())
|
|
||||||
{
|
|
||||||
currentNodes.Remove(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentNodes.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (Node node in currentNodes)
|
|
||||||
{
|
|
||||||
checkJobs.Remove(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentNodes.Clear();
|
|
||||||
|
|
||||||
foreach (CheckJob checkJob in checkJobs.Values)
|
foreach (CheckJob checkJob in checkJobs.Values)
|
||||||
{
|
|
||||||
checkJob.Prepare();
|
checkJob.Prepare();
|
||||||
}
|
|
||||||
|
|
||||||
Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): currently knows {0} checks", checkJobs.Count);
|
Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): currently knows {0} checks", checkJobs.Count);
|
||||||
Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): currently {0} checks alive", checkPool.NumQueuedJobs);
|
Logging.Log(LogLevel.INFO, "SkyChecker.scheduler(): currently {0} checks alive", checkPool.NumQueuedJobs);
|
||||||
|
@ -104,7 +89,8 @@ namespace ln.skyscanner.services
|
||||||
{
|
{
|
||||||
Thread.Sleep((int)(nextMinute - DateTimeOffset.Now.ToUnixTimeMilliseconds()));
|
Thread.Sleep((int)(nextMinute - DateTimeOffset.Now.ToUnixTimeMilliseconds()));
|
||||||
break;
|
break;
|
||||||
} catch (ThreadInterruptedException)
|
}
|
||||||
|
catch (ThreadInterruptedException)
|
||||||
{
|
{
|
||||||
Logging.Log(LogLevel.INFO, "CheckService: scheduler was interrupted");
|
Logging.Log(LogLevel.INFO, "CheckService: scheduler was interrupted");
|
||||||
if (StopRequested)
|
if (StopRequested)
|
||||||
|
@ -112,6 +98,7 @@ namespace ln.skyscanner.services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
coreService.RPCContainer.Remove("CheckService");
|
coreService.RPCContainer.Remove("CheckService");
|
||||||
entityService = null;
|
entityService = null;
|
||||||
|
@ -119,10 +106,44 @@ namespace ln.skyscanner.services
|
||||||
coreService = null;
|
coreService = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateNodeList()
|
||||||
|
{
|
||||||
|
lock (this)
|
||||||
|
{
|
||||||
|
Logging.Log(LogLevel.DEBUG, "CheckService: Synchronizing CheckJobs");
|
||||||
|
|
||||||
|
HashSet<Node> knownNodes = new HashSet<Node>(SessionMapper.Load<Node>());
|
||||||
|
HashSet<Node> currentNodes = new HashSet<Node>(checkJobs.Keys);
|
||||||
|
|
||||||
|
foreach (Node node in knownNodes)
|
||||||
|
{
|
||||||
|
if (!currentNodes.Contains(node))
|
||||||
|
{
|
||||||
|
CheckJob checkJob = new CheckJob(this, node);
|
||||||
|
checkJobs.Add(node, checkJob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (Node node in currentNodes)
|
||||||
|
{
|
||||||
|
if (!knownNodes.Contains(node))
|
||||||
|
{
|
||||||
|
checkJobs.Remove(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PoolJobFinished(Pool pool, PoolJob job)
|
||||||
|
{
|
||||||
|
CheckJob checkJob = job as CheckJob;
|
||||||
|
SessionMapper.Save<Node>(checkJob.Node);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public SkyCheckState[] GetCheckStates(Node node)
|
public SkyCheckState[] GetCheckStates(Node node)
|
||||||
{
|
{
|
||||||
Query stateQuery = Query.Equals<SkyCheckState>("Node", node.ID);
|
Query stateQuery = Query.Equals<SkyCheckState>("Node", node.ID);
|
||||||
SkyCheckState[] skyCheckStates = entityService.SkyCheckStates.SelectQuery(stateQuery).ToArray();
|
SkyCheckState[] skyCheckStates = SessionMapper.Load<SkyCheckState>(stateQuery).ToArray();
|
||||||
Dictionary<string, SkyCheckState> checkStates = new Dictionary<string, SkyCheckState>();
|
Dictionary<string, SkyCheckState> checkStates = new Dictionary<string, SkyCheckState>();
|
||||||
|
|
||||||
foreach (SkyCheckState checkState in skyCheckStates)
|
foreach (SkyCheckState checkState in skyCheckStates)
|
||||||
|
@ -134,7 +155,7 @@ namespace ln.skyscanner.services
|
||||||
if (!checkStates.ContainsKey(check.Name) && check.IsValid(node))
|
if (!checkStates.ContainsKey(check.Name) && check.IsValid(node))
|
||||||
{
|
{
|
||||||
checkStates.Add(check.Name, check.PrepareCheckState(this, node));
|
checkStates.Add(check.Name, check.PrepareCheckState(this, node));
|
||||||
entityService.SkyCheckStates.Insert(checkStates[check.Name]);
|
SessionMapper.Save<SkyCheckState>(checkStates[check.Name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +176,7 @@ namespace ln.skyscanner.services
|
||||||
{
|
{
|
||||||
List<Node> nodes = new List<Node>();
|
List<Node> nodes = new List<Node>();
|
||||||
|
|
||||||
foreach (Node node in checkService.EntityService.NodeCollection)
|
foreach (Node node in checkService.SessionMapper.Load<Node>())
|
||||||
{
|
{
|
||||||
foreach (SkyCheckState checkState in node.CheckStates)
|
foreach (SkyCheckState checkState in node.CheckStates)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,6 @@ namespace ln.skyscanner.services
|
||||||
EntityService entityService = Dependency<EntityService>();
|
EntityService entityService = Dependency<EntityService>();
|
||||||
|
|
||||||
Ready();
|
Ready();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@ using ln.skyscanner.entities;
|
||||||
using ln.logging;
|
using ln.logging;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using ln.types.odb.ng.storage;
|
using ln.types.odb.ng.storage;
|
||||||
|
using System.Linq;
|
||||||
|
using ln.types.net;
|
||||||
|
using ln.skyscanner.import.skytron;
|
||||||
namespace ln.skyscanner.services
|
namespace ln.skyscanner.services
|
||||||
{
|
{
|
||||||
public class EntityService : ApplicationServiceBase
|
public class EntityService : ApplicationServiceBase
|
||||||
|
@ -111,10 +114,27 @@ namespace ln.skyscanner.services
|
||||||
|
|
||||||
public Node GetNode(Guid nodeID)
|
public Node GetNode(Guid nodeID)
|
||||||
{
|
{
|
||||||
return EntityService.SessionMapper.Load<Node>(nodeID);
|
return EntityService.SessionMapper.Load<Node>(Query.Equals<Node>("ID", nodeID)).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Node[] GetNodes()
|
||||||
|
{
|
||||||
|
return EntityService.SessionMapper.Load<Node>().ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node CreateNode()
|
||||||
|
{
|
||||||
|
Node node = new Node(IPv4.ANY);
|
||||||
|
EntityService.SessionMapper.Save<Node>(node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SyncSkytron()
|
||||||
|
{
|
||||||
|
SkytronImport skytronImport = new SkytronImport(EntityService.CurrentApplicationInterface.Arguments["import-skytron"].Value);
|
||||||
|
ThreadPool.QueueUserWorkItem((state) => skytronImport.Import(EntityService.SessionMapper));
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
alert("WebSocket caught error: " + e.date);
|
alert("WebSocket caught error: " + e.date);
|
||||||
}
|
}
|
||||||
this.websocket.onmessage = function(e){
|
this.websocket.onmessage = function(e){
|
||||||
|
try{
|
||||||
var j = JSON.parse(e.data);
|
var j = JSON.parse(e.data);
|
||||||
if (j.state){
|
if (j.state){
|
||||||
updateState(j.state);
|
updateState(j.state);
|
||||||
|
@ -44,6 +45,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(exc){
|
||||||
|
console.log("websocket malformed message" + JSON.stringify(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
<%frame "frame.html"%>
|
||||||
|
|
||||||
|
<h1>Network Overview</h1>
|
||||||
|
<h2>Hosts / Nodes
|
||||||
|
<span class="ui-icon ui-icon-refresh" onclick="$('#nodeTable').DataTable().ajax.reload(null, false);"></span>
|
||||||
|
<a href="" onclick="LN().rpc('entities','SyncSkytron',[],function(r,e){}); return false;">Sync with Skytron CRM</a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<table id="nodeTable"></table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Details</h2>
|
||||||
|
<div class="flex row">
|
||||||
|
<fieldset style="max-width: 500px;">
|
||||||
|
<label for="dName">Bezeichnung</label><input type="text" id="dName"><br>
|
||||||
|
<label for="dPrimaryIP">Primäre IP</label><input type="text" id="dPrimaryIP"><br>
|
||||||
|
<label for="dPrimaryMac">Primäre MAC</label><input type="text" id="dPrimaryMac"><br>
|
||||||
|
<label for="dCreated">Erstellt</label><input type="text" id="dCreated" readonly="true"><br>
|
||||||
|
<label for="dLastUpdate">Letztes Update</label><input type="text" id="dLastUpdate" readonly="true">
|
||||||
|
</fieldset>
|
||||||
|
<fieldset style="max-width: 500px;">
|
||||||
|
<label for="dVendor">Hersteller</label><input type="text" id="dVendor"><br>
|
||||||
|
<label for="dProduct">Modell</label><input type="text" id="dProduct"><br>
|
||||||
|
<label for="dProductLine">Modellzeile</label><input type="text" id="dProductLine"><br>
|
||||||
|
<label for="dDeviceType">Gerätetyp</label><select id="dDeviceType">
|
||||||
|
<option value="UNKNOWN">-</option>
|
||||||
|
<option value="ROUTER">Router</option>
|
||||||
|
<option value="PTP">PtP</option>
|
||||||
|
<option value="PTMP">PtmP</option>
|
||||||
|
<option value="UPS">USV</option>
|
||||||
|
<option value="SERVER">Server</option>
|
||||||
|
</select>
|
||||||
|
<label for="dLocation">Lokalisation</label><input type="text" id="dLocation"><br>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset id="dURIs">
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<select id="dInterfaces" size="12">
|
||||||
|
</select>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function showNode(node)
|
||||||
|
{
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
$("#dName").prop("disabled", true).val("");
|
||||||
|
$("#dPrimaryIP").prop("disabled", true).val("");
|
||||||
|
$("#dPrimaryMac").prop("disabled", true).val("");
|
||||||
|
$("#dCreated").prop("disabled", true).val("");
|
||||||
|
$("#dLastUpdate").prop("disabled", true).val("");
|
||||||
|
|
||||||
|
$("#dVendor").prop("disabled", true).val("");
|
||||||
|
$("#dProduct").prop("disabled", true).val("");
|
||||||
|
$("#dProductLine").prop("disabled", true).val("");
|
||||||
|
$("#dLocation").prop("disabled", true).val("");
|
||||||
|
|
||||||
|
$("#dURIs").empty();
|
||||||
|
$("#dInterfaces").empty();
|
||||||
|
$("#dDeviceType").prop("disabled",true).selectmenu().val("");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$("#dName").prop("disabled", false).val(node.Name);
|
||||||
|
$("#dPrimaryIP").prop("disabled", true).val(node.PrimaryIP);
|
||||||
|
$("#dPrimaryMac").prop("disabled", true).val(node.PrimaryMac);
|
||||||
|
$("#dCreated").prop("disabled", true).val(node.Created);
|
||||||
|
$("#dLastUpdate").prop("disabled", true).val(node.LastUpdate);
|
||||||
|
|
||||||
|
$("#dVendor").prop("disabled", false).val(node.Vendor);
|
||||||
|
$("#dProduct").prop("disabled", false).val(node.Product);
|
||||||
|
$("#dProductLine").prop("disabled", false).val(node.ProductLine);
|
||||||
|
$("#dLocation").prop("disabled", false).val(node.Location.Latitude + " / " + node.Location.Longitude);
|
||||||
|
|
||||||
|
$("#dURIs").empty();
|
||||||
|
$.each( node.URIs, function(){ $("#dURIs").append($("<span>" + this.Scheme + "://" + this.Host + ":" + this.Port + (this.Fragment ? "#" + this.Fragment : "") + "</span><br>")); } );
|
||||||
|
|
||||||
|
$("#dInterfaces").empty();
|
||||||
|
$.each( node.Interfaces, function(){
|
||||||
|
var intf = this;
|
||||||
|
$.each( intf.ConfiguredIPs, function(){
|
||||||
|
$("#dInterfaces").append( $( "<option value='"+ this.Network +"'>" + this.IP + "[ " + intf.Name + " ]</option>" ) );
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#dDeviceType").prop("disabled",false).selectmenu().val(this.DeviceType);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#dInterfaces").change( function(e){
|
||||||
|
skyapi().call("api/network","GetHostsInSubnet", [ $(this).children("option:selected").val() ], function(neighbors){
|
||||||
|
$("#nodeTable").DataTable().clear().rows.add( neighbors ).draw();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#nodeTable").DataTable({
|
||||||
|
columns: [
|
||||||
|
{ title: "", data: null },
|
||||||
|
{ title: "Bezeichnung", data: "Name" },
|
||||||
|
{ title: "Primäre IP", data: "PrimaryIP" },
|
||||||
|
{ title: "Primäre MAC", data: "PrimaryMac" },
|
||||||
|
{ title: "Erstellt", data: "Created" },
|
||||||
|
{ title: "Letztes Update", data: "LastUpdate" },
|
||||||
|
{ title: "Hersteller", data: "Vendor" },
|
||||||
|
{ title: "Produkt", data: "Product" },
|
||||||
|
{ title: "Gerätetyp", data: "DeviceType" },
|
||||||
|
{ title: "Standort", data: "Location", render: function(d,t,r){ return d.Latitude + "/" + d.Longitude; } },
|
||||||
|
{ title: "UniqueIdentity", data: "UniqueIdentity" }
|
||||||
|
],
|
||||||
|
columnDefs: [
|
||||||
|
{ targets: 0, data: null, defaultContent: "<button>?</button>" }
|
||||||
|
],
|
||||||
|
select: "single",
|
||||||
|
height: 300,
|
||||||
|
fixedHeader: true,
|
||||||
|
})
|
||||||
|
.on( "select", function(e,dt,type,indexes){
|
||||||
|
if (indexes.length > 0)
|
||||||
|
{
|
||||||
|
var selNode = dt.rows( indexes ).data()[0];
|
||||||
|
showNode(selNode);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.on( "deselect", function(e,dt,type,indexes){
|
||||||
|
showNode(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
function refreshNodeTable()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
showNode(null);
|
||||||
|
//refreshNodeTable();
|
||||||
|
|
||||||
|
LN().rpc("entities","GetNodes",[],function(r,e){
|
||||||
|
console.log("received " + r.length + " nodes");
|
||||||
|
|
||||||
|
$("#nodeTable").DataTable()
|
||||||
|
.clear()
|
||||||
|
.rows
|
||||||
|
.add(r);
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
<div class="popup">Netz Struktur
|
<div class="popup">Netz Struktur
|
||||||
<div>
|
<div>
|
||||||
|
<div>
|
||||||
|
<a href="/static/network/nodes.html"><div>Knoten</div></a>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a href="/static/network/pops.html"><div>PoP Liste</div></a>
|
<a href="/static/network/pops.html"><div>PoP Liste</div></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue