mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
add tracking for port-stack
git-svn-id: http://www.observium.org/svn/observer/trunk@2185 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -44,3 +44,4 @@ ALTER TABLE `ports` DROP INDEX `snmpid`;
|
|||||||
CREATE TABLE IF NOT EXISTS `ospf_areas` ( `device_id` int(11) NOT NULL, `ospfAreaId` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfAuthType` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `ospfImportAsExtern` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `ospfSpfRuns` int(11) NOT NULL, `ospfAreaBdrRtrCount` int(11) NOT NULL, `ospfAsBdrRtrCount` int(11) NOT NULL, `ospfAreaLsaCount` int(11) NOT NULL, `ospfAreaLsaCksumSum` int(11) NOT NULL, `ospfAreaSummary` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `ospfAreaStatus` varchar(64) COLLATE utf8_unicode_ci NOT NULL, UNIQUE KEY `device_area` (`device_id`,`ospfAreaId`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
CREATE TABLE IF NOT EXISTS `ospf_areas` ( `device_id` int(11) NOT NULL, `ospfAreaId` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfAuthType` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `ospfImportAsExtern` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `ospfSpfRuns` int(11) NOT NULL, `ospfAreaBdrRtrCount` int(11) NOT NULL, `ospfAsBdrRtrCount` int(11) NOT NULL, `ospfAreaLsaCount` int(11) NOT NULL, `ospfAreaLsaCksumSum` int(11) NOT NULL, `ospfAreaSummary` varchar(64) COLLATE utf8_unicode_ci NOT NULL, `ospfAreaStatus` varchar(64) COLLATE utf8_unicode_ci NOT NULL, UNIQUE KEY `device_area` (`device_id`,`ospfAreaId`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
CREATE TABLE IF NOT EXISTS `ospf_instances` ( `device_id` int(11) NOT NULL, `ospf_instance_id` int(11) NOT NULL, `ospfRouterId` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfAdminStat` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfVersionNumber` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfAreaBdrRtrStatus` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfASBdrRtrStatus` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfExternLsaCount` int(11) NOT NULL, `ospfExternLsaCksumSum` int(11) NOT NULL, `ospfTOSSupport` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfOriginateNewLsas` int(11) NOT NULL, `ospfRxNewLsas` int(11) NOT NULL, `ospfExtLsdbLimit` int(11) DEFAULT NULL, `ospfMulticastExtensions` int(11) DEFAULT NULL, `ospfExitOverflowInterval` int(11) DEFAULT NULL, `ospfDemandExtensions` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, UNIQUE KEY `device_id` (`device_id`,`ospf_instance_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
CREATE TABLE IF NOT EXISTS `ospf_instances` ( `device_id` int(11) NOT NULL, `ospf_instance_id` int(11) NOT NULL, `ospfRouterId` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfAdminStat` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfVersionNumber` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfAreaBdrRtrStatus` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfASBdrRtrStatus` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfExternLsaCount` int(11) NOT NULL, `ospfExternLsaCksumSum` int(11) NOT NULL, `ospfTOSSupport` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfOriginateNewLsas` int(11) NOT NULL, `ospfRxNewLsas` int(11) NOT NULL, `ospfExtLsdbLimit` int(11) DEFAULT NULL, `ospfMulticastExtensions` int(11) DEFAULT NULL, `ospfExitOverflowInterval` int(11) DEFAULT NULL, `ospfDemandExtensions` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, UNIQUE KEY `device_id` (`device_id`,`ospf_instance_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
CREATE TABLE IF NOT EXISTS `ospf_ports` ( `device_id` int(11) NOT NULL, `interface_id` int(11) NOT NULL, `ospf_port_id` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfIfIpAddress` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfAddressLessIf` int(11) NOT NULL, `ospfIfAreaId` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfIfType` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfAdminStat` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfRtrPriority` int(11) DEFAULT NULL, `ospfIfTransitDelay` int(11) DEFAULT NULL, `ospfIfRetransInterval` int(11) DEFAULT NULL, `ospfIfHelloInterval` int(11) DEFAULT NULL, `ospfIfRtrDeadInterval` int(11) DEFAULT NULL, `ospfIfPollInterval` int(11) DEFAULT NULL, `ospfIfState` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfDesignatedRouter` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfBackupDesignatedRouter` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfEvents` int(11) DEFAULT NULL, `ospfIfAuthKey` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfStatus` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfMulticastForwarding` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfDemand` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfAuthType` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, UNIQUE KEY `device_id` (`device_id`,`interface_id`,`ospf_port_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
CREATE TABLE IF NOT EXISTS `ospf_ports` ( `device_id` int(11) NOT NULL, `interface_id` int(11) NOT NULL, `ospf_port_id` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfIfIpAddress` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfAddressLessIf` int(11) NOT NULL, `ospfIfAreaId` varchar(32) COLLATE utf8_unicode_ci NOT NULL, `ospfIfType` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfAdminStat` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfRtrPriority` int(11) DEFAULT NULL, `ospfIfTransitDelay` int(11) DEFAULT NULL, `ospfIfRetransInterval` int(11) DEFAULT NULL, `ospfIfHelloInterval` int(11) DEFAULT NULL, `ospfIfRtrDeadInterval` int(11) DEFAULT NULL, `ospfIfPollInterval` int(11) DEFAULT NULL, `ospfIfState` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfDesignatedRouter` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfBackupDesignatedRouter` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfEvents` int(11) DEFAULT NULL, `ospfIfAuthKey` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfStatus` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfMulticastForwarding` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfDemand` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, `ospfIfAuthType` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, UNIQUE KEY `device_id` (`device_id`,`interface_id`,`ospf_port_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||||
|
CREATE TABLE IF NOT EXISTS `ports_stack` (`interface_id_high` INT NOT NULL ,`interface_id_low` INT NOT NULL) ENGINE = INNODB;
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ while ($device = mysql_fetch_assoc($device_query))
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
include("includes/discovery/ports.inc.php");
|
include("includes/discovery/ports.inc.php");
|
||||||
|
include("includes/discovery/ports-stack.inc.php");
|
||||||
include("includes/discovery/entity-physical.inc.php");
|
include("includes/discovery/entity-physical.inc.php");
|
||||||
include("includes/discovery/processors.inc.php");
|
include("includes/discovery/processors.inc.php");
|
||||||
include("includes/discovery/mempools.inc.php");
|
include("includes/discovery/mempools.inc.php");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
#<?php
|
||||||
|
|
||||||
# This file prints a table row for each interface
|
# This file prints a table row for each interface
|
||||||
|
|
||||||
@@ -224,6 +224,31 @@ if ($interface['pagpGroupIfIndex'] && $interface['pagpGroupIfIndex'] != $interfa
|
|||||||
$br = "<br />";
|
$br = "<br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$higher_ifs = mysql_query("SELECT * FROM `ports_stack` WHERE `interface_id_low` = '".$interface['ifIndex']."' and `device_id` = '".$device['device_id']."'");
|
||||||
|
echo(mysql_error());
|
||||||
|
while ($higher_if = mysql_fetch_assoc($higher_ifs))
|
||||||
|
{
|
||||||
|
if($higher_if['interface_id_high'])
|
||||||
|
{
|
||||||
|
$this_port = get_port_by_ifIndex($device, $higher_if['interface_id_high']);
|
||||||
|
echo("$br<img src='images/16/arrow_divide.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>");
|
||||||
|
$br = "<br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$lower_ifs = mysql_query("SELECT * FROM `ports_stack` WHERE `interface_id_high` = '".$interface['ifIndex']."' and `device_id` = '".$device['device_id']."'");
|
||||||
|
echo(mysql_error());
|
||||||
|
while ($lower_if = mysql_fetch_assoc($lower_ifs))
|
||||||
|
{
|
||||||
|
if($lower_if['interface_id_low'])
|
||||||
|
{
|
||||||
|
$this_port = get_port_by_ifIndex($device, $lower_if['interface_id_low']);
|
||||||
|
echo("$br<img src='images/16/arrow_join.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>");
|
||||||
|
$br = "<br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
|
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
|
||||||
|
|
||||||
echo("</td></tr>");
|
echo("</td></tr>");
|
||||||
|
|||||||
@@ -165,6 +165,14 @@ function getifindexbyid($id)
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_port_by_ifIndex($device, $ifIndex)
|
||||||
|
{
|
||||||
|
$sql = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
|
||||||
|
$result = @mysql_fetch_assoc($sql);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
function getifbyid($id)
|
function getifbyid($id)
|
||||||
{
|
{
|
||||||
$sql = mysql_query("SELECT * FROM `ports` WHERE `interface_id` = '$id'");
|
$sql = mysql_query("SELECT * FROM `ports` WHERE `interface_id` = '$id'");
|
||||||
|
|||||||
38
includes/discovery/ports-stack.inc.php
Normal file
38
includes/discovery/ports-stack.inc.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
echo("Port Stack: ");
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM `ports_stack` WHERE `device_id` = '".$device['device_id']."'";
|
||||||
|
$query = mysql_query($sql);
|
||||||
|
while($entry = mysql_fetch_assoc($query))
|
||||||
|
{
|
||||||
|
$stack_db_array[$entry['interface_id_high']][$entry['interface_id_low']]['ifStackStatus'] = $entry['ifStackStatus'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stack_poll_array = snmpwalk_cache_twopart_oid($device, "ifStackStatus", array());
|
||||||
|
|
||||||
|
foreach($stack_poll_array as $interface_id_high => $entry_high)
|
||||||
|
{
|
||||||
|
foreach($entry_high as $interface_id_low => $entry_low)
|
||||||
|
{
|
||||||
|
$ifStackStatus = $entry_low['ifStackStatus'];
|
||||||
|
if(isset($stack_db_array[$interface_id_high][$interface_id_low]))
|
||||||
|
{
|
||||||
|
if($stack_db_array[$interface_id_high][$interface_id_low]['ifStackStatus'] == $ifStackStatus)
|
||||||
|
{
|
||||||
|
echo(".");
|
||||||
|
} else {
|
||||||
|
mysql_query("UPDATE `ports_stack` SET `ifStackStatus` = '".$ifStackStatus."' WHERE `device_id` = '".$device['device_id']."' AND `interface_id_high` = '".$interface_id_high."' AND `interface_id_low` = '".$interface_id_low."'");
|
||||||
|
echo("U");
|
||||||
|
if($debug) { echo(mysql_error()); }
|
||||||
|
}
|
||||||
|
unset($stack_db_array[$interface_id_high][$interface_id_low]);
|
||||||
|
} else {
|
||||||
|
mysql_query("INSERT INTO `ports_stack` (`device_id`,`interface_id_high`,`interface_id_low`,`ifStackStatus`) VALUES ('".$device['device_id']."','".$interface_id_high."','".$interface_id_low."','".$ifStackStatus."')");
|
||||||
|
echo("+");
|
||||||
|
if($debug) { echo(mysql_error()); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -3,7 +3,10 @@
|
|||||||
echo("OSPF: ");
|
echo("OSPF: ");
|
||||||
echo("Processes: ");
|
echo("Processes: ");
|
||||||
|
|
||||||
$ospf_instance_count = 0;
|
$ospf_instance_count = 0;
|
||||||
|
$ospf_port_count = 0;
|
||||||
|
$ospf_area_count = 0;
|
||||||
|
$ospf_neighbour_count = 0;
|
||||||
|
|
||||||
$ospf_oids_db = array('ospfRouterId', 'ospfAdminStat', 'ospfVersionNumber', 'ospfAreaBdrRtrStatus', 'ospfASBdrRtrStatus',
|
$ospf_oids_db = array('ospfRouterId', 'ospfAdminStat', 'ospfVersionNumber', 'ospfAreaBdrRtrStatus', 'ospfASBdrRtrStatus',
|
||||||
'ospfExternLsaCount', 'ospfExternLsaCksumSum', 'ospfTOSSupport', 'ospfOriginateNewLsas', 'ospfRxNewLsas',
|
'ospfExternLsaCount', 'ospfExternLsaCksumSum', 'ospfTOSSupport', 'ospfOriginateNewLsas', 'ospfRxNewLsas',
|
||||||
@@ -135,6 +138,7 @@ if (is_array($ospf_areas_db))
|
|||||||
}
|
}
|
||||||
unset($ospf_area_poll);
|
unset($ospf_area_poll);
|
||||||
unset($ospf_area_db);
|
unset($ospf_area_db);
|
||||||
|
$ospf_area_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +217,7 @@ if (is_array($ospf_ports_db)){
|
|||||||
}
|
}
|
||||||
unset($ospf_port_poll);
|
unset($ospf_port_poll);
|
||||||
unset($ospf_port_db);
|
unset($ospf_port_db);
|
||||||
|
$ospf_port_count++;
|
||||||
} else {
|
} else {
|
||||||
mysql_query("DELETE FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'");
|
mysql_query("DELETE FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'");
|
||||||
echo("-");
|
echo("-");
|
||||||
@@ -221,6 +225,26 @@ if (is_array($ospf_ports_db)){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Create device-wide statistics RRD
|
||||||
|
|
||||||
|
$filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ospf-statistics.rrd");
|
||||||
|
|
||||||
|
if (!is_file($filename))
|
||||||
|
{
|
||||||
|
rrdtool_create($filename, "--step 300 \
|
||||||
|
DS:instances:GAUGE:600:0:1000000 \
|
||||||
|
DS:areas:GAUGE:600:0:1000000 \
|
||||||
|
DS:ports:GAUGE:600:0:1000000 \
|
||||||
|
DS:neighbours:GAUGE:600:0:1000000 \
|
||||||
|
RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 \
|
||||||
|
RRA:MIN:0.5:1:600 RRA:MIN:0.5:6:700 RRA:MIN:0.5:24:775 RRA:MIN:0.5:288:797 \
|
||||||
|
RRA:MAX:0.5:1:600 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797 \
|
||||||
|
RRA:LAST:0.5:1:600 RRA:LAST:0.5:6:700 RRA:LAST:0.5:24:775 RRA:LAST:0.5:288:797");
|
||||||
|
}
|
||||||
|
|
||||||
|
$rrd_update = "N:".$ospf_instance_count.":".$ospf_area_count.":".$ospf_port_count.":".$ospf_neighbour_count;
|
||||||
|
$ret = rrdtool_update("$filename", $rrd_update);
|
||||||
|
|
||||||
unset($ospf_ports_db);
|
unset($ospf_ports_db);
|
||||||
unset($ospf_ports_poll);
|
unset($ospf_ports_poll);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user