diff --git a/database-update.sql b/database-update.sql index fd5504df1f..e7d7127a3b 100644 --- a/database-update.sql +++ b/database-update.sql @@ -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_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 `ports_stack` (`interface_id_high` INT NOT NULL ,`interface_id_low` INT NOT NULL) ENGINE = INNODB; diff --git a/discovery.php b/discovery.php index 938d7c5284..ee9e545f7b 100755 --- a/discovery.php +++ b/discovery.php @@ -175,6 +175,7 @@ while ($device = mysql_fetch_assoc($device_query)) } } else { include("includes/discovery/ports.inc.php"); + include("includes/discovery/ports-stack.inc.php"); include("includes/discovery/entity-physical.inc.php"); include("includes/discovery/processors.inc.php"); include("includes/discovery/mempools.inc.php"); diff --git a/html/includes/print-interface.inc.php b/html/includes/print-interface.inc.php index dddc91d9ab..7de5257a69 100644 --- a/html/includes/print-interface.inc.php +++ b/html/includes/print-interface.inc.php @@ -1,4 +1,4 @@ -"; } +$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 " . generate_port_link($this_port) . ""); + $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 " . generate_port_link($this_port) . ""); + $br = "
"; + } +} + + unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br); echo(""); diff --git a/includes/common.php b/includes/common.php index 2b0fcd61e5..0a10d69dd7 100644 --- a/includes/common.php +++ b/includes/common.php @@ -165,6 +165,14 @@ function getifindexbyid($id) 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) { $sql = mysql_query("SELECT * FROM `ports` WHERE `interface_id` = '$id'"); diff --git a/includes/discovery/ports-stack.inc.php b/includes/discovery/ports-stack.inc.php new file mode 100644 index 0000000000..5b57f77618 --- /dev/null +++ b/includes/discovery/ports-stack.inc.php @@ -0,0 +1,38 @@ + $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()); } + } + } +} + +?> diff --git a/includes/polling/ospf.inc.php b/includes/polling/ospf.inc.php index b16f5f3d54..b6ab293fdc 100644 --- a/includes/polling/ospf.inc.php +++ b/includes/polling/ospf.inc.php @@ -3,7 +3,10 @@ echo("OSPF: "); 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', 'ospfExternLsaCount', 'ospfExternLsaCksumSum', 'ospfTOSSupport', 'ospfOriginateNewLsas', 'ospfRxNewLsas', @@ -135,6 +138,7 @@ if (is_array($ospf_areas_db)) } unset($ospf_area_poll); unset($ospf_area_db); + $ospf_area_count++; } } @@ -213,7 +217,7 @@ if (is_array($ospf_ports_db)){ } unset($ospf_port_poll); unset($ospf_port_db); - + $ospf_port_count++; } else { mysql_query("DELETE FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'"); 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_poll);