ln.skyscanner/Program.cs

126 lines
4.2 KiB
C#

// /**
// * 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 Renci.SshNet;
using ln.skyscanner.identify;
using System.Net;
using System.Collections.Generic;
using ln.snmp.types;
using System.IO;
using ln.snmp;
using ln.snmp.channel;
using System.Diagnostics;
using ln.perfdb.storage;
using ln.logging;
namespace ln.skyscanner
{
class MainClass
{
private static void DumpPerfValues(PerfValue[] perfValues)
{
int n = 0;
Logging.Log("----------------------------------------------");
Logging.Log("Dumping {0} perfValues:", perfValues.Length);
foreach (PerfValue perfValue in perfValues)
{
Logging.Log("PerfValue: [{1,6}] {0}", perfValue, n);
n++;
}
Logging.Log("");
}
public static void Main(string[] args)
{
//PerfFile perfFile = new PerfFile("test.lnpv");
//perfFile.Open();
//if (perfFile.FirstSection == null)
//{
// PerfFile.PerfFileSection section = new PerfFile.PerfFileSection(perfFile, null, 1440, 60, AggregationMethod.AVERAGE);
// section = new PerfFile.PerfFileSection(perfFile, section,1728,300, AggregationMethod.AVERAGE);
// section = new PerfFile.PerfFileSection(perfFile, section, 2016, 900, AggregationMethod.AVERAGE);
// section = new PerfFile.PerfFileSection(perfFile, section, 1344, 3600, AggregationMethod.AVERAGE);
// section = new PerfFile.PerfFileSection(perfFile, section, 1344, 10800, AggregationMethod.AVERAGE);
//}
//int n = 10;
//for (long ts = 1000; ts < 160000; ts += 60)
//{
// perfFile.Write(ts, n++);
//}
//PerfValue[] dump = new PerfValue[perfFile.FirstSection.nRecords];
//perfFile.FirstSection.ReadRecords(dump, 0, 0, dump.Length);
//DumpPerfValues(dump);
//DumpPerfValues(perfFile.QueryTime(3600, 0));
//DumpPerfValues(perfFile.QueryTime(3600 * 24, 0));
//DumpPerfValues(perfFile.QueryTime(3600 * 24, 3600));
//perfFile.Close();
//return;
SNMPEngine.DEBUG = true;
SNMPEngine engine = new SNMPEngine();
engine.Timeout = 3000;
SnmpV1Endpoint v1endpoint = new SnmpV1Endpoint(engine, new IPEndPoint(IPAddress.Parse("10.113.254.4"), 161), "ghE7wUmFPoPpkRno");
SnmpV2Endpoint v2endpoint = new SnmpV2Endpoint(engine, new IPEndPoint(IPAddress.Parse("10.113.254.4"), 161), "ghE7wUmFPoPpkRno");
USMEndpoint v3endpoint = new USMEndpoint(engine, new IPEndPoint(IPAddress.Parse("10.255.3.41"), 161));
v3endpoint.AuthMethod = SnmpV3AuthMethod.SHA;
v3endpoint.AuthKey = "qVy3hnZJ2fov";
v3endpoint.Username = "skytron";
SNMPInterface intf = v3endpoint;
Stopwatch stopWatch = Stopwatch.StartNew();
Sequence[][] ifTable = intf.snmpWalk(new String[] {
"1.3.6.1.2.1.2.2.1.2",
"1.3.6.1.2.1.2.2.1.10",
"1.3.6.1.2.1.2.2.1.16",
"1.3.6.1.2.1.2.2.1.14",
"1.3.6.1.2.1.2.2.1.20"
});
stopWatch.Stop();
Console.WriteLine("Time for table walk: {0}ms", stopWatch.ElapsedMilliseconds);
foreach (Sequence[] sequences in ifTable)
{
foreach (Sequence sequence in sequences)
{
Console.Write("{0}\t", sequence?.Items[1].Value);
}
Console.WriteLine("");
}
engine.Close();
//NodeIdentifier identifier = new NodeIdentifier(IPAddress.Parse("10.10.10.1"));
//identifier.Identify();
//foreach (KeyValuePair<string,string> hint in identifier.Hints)
//{
// Console.WriteLine("{0:16} = {1}", hint.Key, hint.Value);
//}
}
}
}