2019-04-04 19:34:19 +02:00
|
|
|
|
using System;
|
|
|
|
|
using ln.skyscanner.entities;
|
|
|
|
|
using ln.types;
|
|
|
|
|
using ln.snmp;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using ln.snmp.types;
|
|
|
|
|
using ln.logging;
|
2019-07-08 13:15:35 +02:00
|
|
|
|
using System.Linq;
|
2019-04-04 19:34:19 +02:00
|
|
|
|
|
|
|
|
|
namespace ln.skyscanner.checks
|
|
|
|
|
{
|
2019-06-28 10:01:30 +02:00
|
|
|
|
public class Ubiquiti : SkyCheck
|
2019-04-04 19:34:19 +02:00
|
|
|
|
{
|
2019-06-28 10:01:30 +02:00
|
|
|
|
public Ubiquiti()
|
|
|
|
|
:base("ubiquiti")
|
2019-04-04 19:34:19 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-05 00:59:04 +02:00
|
|
|
|
public override void Check(SkyChecker skyChecker,ref SkyCheckState checkState,Node node)
|
2019-04-04 19:34:19 +02:00
|
|
|
|
{
|
2019-04-05 00:59:04 +02:00
|
|
|
|
UbiquityCheckState ubiquityCheckState = checkState as UbiquityCheckState;
|
|
|
|
|
|
2019-04-04 19:34:19 +02:00
|
|
|
|
foreach (URI snmpUri in node.FindURIs("snmp"))
|
|
|
|
|
{
|
|
|
|
|
using (SnmpInterface snmp = SnmpInterface.FromURI(snmpUri,skyChecker.SNMPEngine))
|
|
|
|
|
{
|
2019-07-08 13:15:35 +02:00
|
|
|
|
List<String> mibs = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
mibs = new List<String>();
|
|
|
|
|
|
|
|
|
|
foreach (Sequence s in snmp.snmpWalk("1.3.6.1.2.1.1.9.1.2"))
|
|
|
|
|
{
|
|
|
|
|
Logging.Log(LogLevel.DEBUG, "Ubiquiti: snmpWalk over OIDs: {0}", (s.Items[1] as ObjectIdentifier).AsString);
|
|
|
|
|
mibs.Add((s.Items[1] as ObjectIdentifier).AsString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (TimeoutException)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mibs.Contains("1.3.6.1.4.1.41112")) // RF Device
|
|
|
|
|
{
|
|
|
|
|
Sequence[][] ptp = snmp.snmpWalk(new string[] {
|
2019-04-04 19:34:19 +02:00
|
|
|
|
"1.3.6.1.4.1.41112.1.3.2.1.5",
|
|
|
|
|
"1.3.6.1.4.1.41112.1.3.2.1.6",
|
|
|
|
|
"1.3.6.1.4.1.41112.1.3.2.1.11",
|
|
|
|
|
"1.3.6.1.4.1.41112.1.3.2.1.14",
|
|
|
|
|
"1.3.6.1.4.1.41112.1.3.3.1.64",
|
|
|
|
|
"1.3.6.1.4.1.41112.1.3.3.1.66"
|
|
|
|
|
});
|
|
|
|
|
|
2019-07-08 13:15:35 +02:00
|
|
|
|
foreach (Sequence[] row in ptp)
|
|
|
|
|
{
|
|
|
|
|
ubiquityCheckState.WritePerformanceValue("ptp_rx_capa", (double)((Integer)(row[0].Items[1])).LongValue);
|
|
|
|
|
ubiquityCheckState.WritePerformanceValue("ptp_tx_capa", (double)((Integer)(row[1].Items[1])).LongValue);
|
|
|
|
|
ubiquityCheckState.WritePerformanceValue("ptp_rx_pwr", (double)((Integer)(row[2].Items[1])).LongValue, -75.0, 0, -80.0, 0);
|
|
|
|
|
ubiquityCheckState.WritePerformanceValue("ptp_tx_pwr", (double)((Integer)(row[3].Items[1])).LongValue);
|
2019-04-04 19:34:19 +02:00
|
|
|
|
|
2019-07-08 13:15:35 +02:00
|
|
|
|
long rxBytes = ((Integer)(row[4].Items[1])).LongValue;
|
|
|
|
|
long txBytes = ((Integer)(row[5].Items[1])).LongValue;
|
2019-04-05 00:59:04 +02:00
|
|
|
|
|
2019-07-08 13:15:35 +02:00
|
|
|
|
ubiquityCheckState.RXRate.Update(rxBytes * 8);
|
|
|
|
|
ubiquityCheckState.TXRate.Update(txBytes * 8);
|
2019-04-05 00:59:04 +02:00
|
|
|
|
|
2019-07-08 13:15:35 +02:00
|
|
|
|
ubiquityCheckState.WritePerformanceValue("ptp_rx_rate", ubiquityCheckState.RXRate.Current);
|
|
|
|
|
ubiquityCheckState.WritePerformanceValue("ptp_tx_rate", ubiquityCheckState.TXRate.Current);
|
|
|
|
|
}
|
2019-04-04 19:34:19 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-08 13:15:35 +02:00
|
|
|
|
break;
|
2019-04-04 19:34:19 +02:00
|
|
|
|
}
|
2019-04-06 09:36:43 +02:00
|
|
|
|
checkState.CheckState = CheckState.OK;
|
2019-04-04 19:34:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsValid(Node node)
|
|
|
|
|
{
|
2019-06-28 10:01:30 +02:00
|
|
|
|
return (node.Vendor != null) && node.Vendor.Equals("Ubiquiti");
|
2019-04-04 19:34:19 +02:00
|
|
|
|
}
|
2019-04-16 18:23:05 +02:00
|
|
|
|
|
|
|
|
|
public override SkyCheckState PrepareCheckState(SkyChecker skyChecker, Node node)
|
|
|
|
|
{
|
|
|
|
|
return new UbiquityCheckState(this, node);
|
|
|
|
|
}
|
2019-04-04 19:34:19 +02:00
|
|
|
|
}
|
2019-04-05 00:59:04 +02:00
|
|
|
|
|
|
|
|
|
class UbiquityCheckState : SkyCheckState
|
|
|
|
|
{
|
|
|
|
|
public dVdT RXRate { get; private set; }
|
|
|
|
|
public dVdT TXRate { get; private set; }
|
|
|
|
|
|
|
|
|
|
public UbiquityCheckState(SkyCheck skyCheck,Node node)
|
|
|
|
|
:base(skyCheck,node)
|
|
|
|
|
{
|
|
|
|
|
RXRate = new dVdT();
|
|
|
|
|
TXRate = new dVdT();
|
|
|
|
|
}
|
|
|
|
|
private UbiquityCheckState()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
}
|
2019-04-04 19:34:19 +02:00
|
|
|
|
}
|