ln.skyscanner/Program.cs

130 lines
3.8 KiB
C#
Raw Normal View History

2019-03-11 09:00:07 +01:00
// /**
// * File: Program.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
using System.Collections.Generic;
using ln.snmp;
using ln.logging;
2019-03-26 12:53:42 +01:00
using ln.skyscanner.entities;
2019-04-01 15:17:41 +02:00
using ln.types.threads;
using ln.types.net;
2019-04-02 13:00:15 +02:00
using ln.types.odb;
2019-04-03 09:19:37 +02:00
using ln.types.odb.index;
2019-03-11 09:00:07 +01:00
namespace ln.skyscanner
{
class MainClass
{
public static void Main(string[] args)
{
2019-04-01 15:17:41 +02:00
new IPv4(0);
2019-03-18 08:12:54 +01:00
FileLogger fileLogger = new FileLogger("skyscanner.log");
2019-03-29 08:55:09 +01:00
fileLogger.MaxLogLevel = LogLevel.INFO;
2019-03-18 08:12:54 +01:00
Logger.Default.Backends.Add(fileLogger);
2019-04-02 01:25:44 +02:00
//Logger.ConsoleLogger.MaxLogLevel = LogLevel.DEBUGDETAIL;
2019-03-11 09:00:07 +01:00
2019-03-21 07:43:32 +01:00
Initialize();
2019-03-13 14:18:05 +01:00
SkyScanner skyScanner = new SkyScanner(args);
skyScanner.Start();
2019-04-01 15:17:41 +02:00
return;
2019-04-03 09:19:37 +02:00
Node coreNode = skyScanner.Entities.GlobalNetwork.FindNodeByIP(IPv4.Parse("10.10.10.2"));
Console.WriteLine("Core Node: {0}", coreNode);
Node coreNode2 = skyScanner.Entities.GlobalNetwork.FindNodeByIP(IPv4.Parse("10.255.7.129"));
Console.WriteLine("Core Node (alt): {0}", coreNode2);
Query nodeByIpQuery = Query.Equals<Node>("Interfaces[].ConfiguredIPs[].IP", IPv4.Parse("10.255.7.129"));
IEnumerable<Node> qnodes = skyScanner.Entities.nodeCollection.Select(nodeByIpQuery);
2019-04-02 01:25:44 +02:00
2019-04-03 09:19:37 +02:00
IEnumerable<Node> neighbors = skyScanner.Entities.GlobalNetwork.FindNeighbors(coreNode);
foreach (Node neigh in neighbors)
2019-04-02 01:25:44 +02:00
{
2019-04-03 09:19:37 +02:00
Console.WriteLine("Neighbor: {0}", neigh);
2019-04-02 01:25:44 +02:00
}
2019-04-03 09:19:37 +02:00
SkyScanner.Instance.Stop();
return;
2019-04-02 01:25:44 +02:00
2019-04-01 15:17:41 +02:00
IEnumerable<Node> nodes = skyScanner.Entities.nodeCollection;
foreach (Node node in nodes)
{
Console.WriteLine("Node: {0}", node);
2019-04-02 01:25:44 +02:00
Timing.Meassure("", () =>
{
foreach (Node neighbor in SkyScanner.Instance.Entities.GlobalNetwork.FindNeighbors(node))
{
Console.WriteLine(" Neighbor: {0}", neighbor);
}
});
Console.WriteLine("");
2019-04-01 15:17:41 +02:00
Console.WriteLine("");
}
2019-03-12 00:55:04 +01:00
2019-04-01 15:17:41 +02:00
throw new Exception();
2019-03-11 09:00:07 +01:00
}
2019-03-12 00:55:04 +01:00
2019-03-21 07:43:32 +01:00
private static void Initialize()
2019-03-12 00:55:04 +01:00
{
2019-03-29 13:57:06 +01:00
SNMPEngine.DefaultEngine.Timeout = 3500;
2019-03-26 12:53:42 +01:00
//using (ODB odb = new ODB("odb"))
//{
2019-03-21 14:06:36 +01:00
2019-03-29 08:55:09 +01:00
//ODBCollection col = odb.GetCollection("test");
2019-03-21 14:06:36 +01:00
2019-03-29 08:55:09 +01:00
//foreach (ODBDocument odoc in col)
//{
// Console.WriteLine("Stored DOC: {0}", odoc);
// if (!odoc.Contains("counter"))
// odoc["counter"] = 0;
// else
// odoc["counter"] = odoc["counter"].AsInt + 1;
2019-03-26 12:53:42 +01:00
2019-03-29 08:55:09 +01:00
// col.Upsert(odoc);
//}
2019-03-26 12:53:42 +01:00
2019-03-29 08:55:09 +01:00
//ODBDocument doc = new ODBDocument();
2019-03-26 12:53:42 +01:00
2019-03-29 08:55:09 +01:00
//doc["snmp.msg"] = "Hallo WelT!";
//doc["name"] = "Harald";
//doc["alter"] = 39;
//doc["genauer"] = 34.5;
//ODBDocument ndoc = new ODBDocument();
//doc["keywords"] = ndoc;
2019-03-26 12:53:42 +01:00
2019-03-29 08:55:09 +01:00
//ndoc["eins"] = 1;
//ndoc["zwei"] = 2;
//ndoc["drei"] = 3;
2019-03-26 12:53:42 +01:00
2019-03-29 08:55:09 +01:00
//Console.WriteLine(doc);
2019-03-26 12:53:42 +01:00
2019-03-29 08:55:09 +01:00
//col.Insert(doc);
2019-03-26 12:53:42 +01:00
2019-03-29 08:55:09 +01:00
//Node node = new Node(CIDR.Parse("1.2.3.4"));
//ODBDocument nodeDoc = ODBMapper.Default.ToODBValue(node).AsDocument;
//Console.WriteLine("Node: {0}", nodeDoc);
2019-03-26 12:53:42 +01:00
2019-03-29 08:55:09 +01:00
//Node node2 = ODBMapper.Default.ToNativeValue<Node>(nodeDoc);
2019-03-26 12:53:42 +01:00
//}
2019-03-12 00:55:04 +01:00
}
2019-03-11 09:00:07 +01:00
}
}