mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #1080 from NURDspace/issue-1011
Add additional support for Mikrotiks
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip_forward.rrd";
|
||||
|
||||
$stats = array('ipCidrRouteNumber' => array());
|
||||
|
||||
$i=0;
|
||||
foreach ($stats as $stat => $array)
|
||||
{
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = str_replace("ip", "", $stat);
|
||||
$rrd_list[$i]['ds'] = $stat;
|
||||
}
|
||||
|
||||
$colours='mixed';
|
||||
|
||||
$scale_min = "0";
|
||||
$nototal = 1;
|
||||
$simple_rrd = TRUE;
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if (is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/netstats-ip_forward.rrd"))
|
||||
{
|
||||
$graph_title = "IP Forward statistics";
|
||||
$graph_type = "device_ip_forward";
|
||||
|
||||
include("includes/print-device-graph.php");
|
||||
|
||||
}
|
||||
|
||||
@@ -1560,6 +1560,10 @@ $config['graph_types']['device']['netstat_snmp_pkt']['section'] = 'netstats';
|
||||
$config['graph_types']['device']['netstat_snmp_pkt']['order'] = '0';
|
||||
$config['graph_types']['device']['netstat_snmp_pkt']['descr'] = 'SNMP Packet Type Statistics';
|
||||
|
||||
$config['graph_types']['device']['netstat_ip_forward']['section'] = 'netstats';
|
||||
$config['graph_types']['device']['netstat_ip_forward']['order'] = '0';
|
||||
$config['graph_types']['device']['netstat_ip_forward']['descr'] = 'IP Forwarding Statistics';
|
||||
|
||||
$config['graph_types']['device']['netstat_tcp']['section'] = 'netstats';
|
||||
$config['graph_types']['device']['netstat_tcp']['order'] = '0';
|
||||
$config['graph_types']['device']['netstat_tcp']['descr'] = 'TCP Statistics';
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "routeros")
|
||||
{
|
||||
$oids = snmp_walk($device, "mtxrHlActiveFan", "-OsqnU", "MIKROTIK-MIB");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
if ($oids !== false) echo("MIKROTIK-MIB ");
|
||||
$divisor = 1;
|
||||
$type = "mikrotik";
|
||||
|
||||
foreach (explode("\n", $oids) as $data)
|
||||
{
|
||||
$data = trim($data);
|
||||
if ($data)
|
||||
{
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$descr = "Fan " . $index;
|
||||
$oid = ".1.3.6.1.4.1.14988.1.1.3.9." . $index;
|
||||
$fanspeed = snmp_get($device, $oid, "-Oqv") / $divisor;
|
||||
if ($fanspeed > 0)
|
||||
{
|
||||
discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $fanspeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "routeros")
|
||||
{
|
||||
$oids = snmp_walk($device, "mtxrHlTemperature", "-OsqnU", "MIKROTIK-MIB");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
if ($oids !== false) echo("MIKROTIK-MIB ");
|
||||
$divisor = 10.0;
|
||||
$type = "mikrotik";
|
||||
|
||||
foreach (explode("\n", $oids) as $data)
|
||||
{
|
||||
$data = trim($data);
|
||||
if ($data)
|
||||
{
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$descr = "Temperature " . $index;
|
||||
$oid = ".1.3.6.1.4.1.14988.1.1.3.10." . $index;
|
||||
$temperature = snmp_get($device, $oid, "-Oqv") / $divisor;
|
||||
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $temperature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "routeros")
|
||||
{
|
||||
$oids = snmp_walk($device, "mtxrHlVoltage", "-OsqnU", "MIKROTIK-MIB");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
if ($oids !== false) echo("MIKROTIK-MIB ");
|
||||
$divisor = 10.0;
|
||||
$type = "mikrotik";
|
||||
|
||||
foreach (explode("\n", $oids) as $data)
|
||||
{
|
||||
$data = trim($data);
|
||||
if ($data)
|
||||
{
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$descr = "Voltage " . $index;
|
||||
$oid = ".1.3.6.1.4.1.14988.1.1.3.8." . $index;
|
||||
$voltage = snmp_get($device, $oid, "-Oqv") / $divisor;
|
||||
|
||||
discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $voltage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" IP-FORWARD");
|
||||
|
||||
// Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
|
||||
$oids = array ('ipCidrRouteNumber');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip_forward.rrd";
|
||||
|
||||
$rrd_create = $config['rrd_rra'];
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:GAUGE:600:U:1000000"; // Limit to 1MPPS?
|
||||
$snmpstring .= " IP-FORWARD-MIB::".$oid.".0";
|
||||
}
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring, "-OQUs", "IP-FORWARD-MIB");
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "U";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data[0]['ipCidrRouteNumber']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_ip_forward'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos, $snmpstring);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
include("netstats-udp.inc.php");
|
||||
include("netstats-icmp.inc.php");
|
||||
include("netstats-snmp.inc.php");
|
||||
include("netstats-ip_forward.inc.php");
|
||||
|
||||
echo("\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user