mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
OSPF poller. may get split into discovery/poller at some point. no RRDs yet. no web interface.
git-svn-id: http://www.observium.org/svn/observer/trunk@2175 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@ -38,3 +38,9 @@ ALTER TABLE `mac_accounting` DROP `peer_ip`, DROP `peer_desc`, DROP `peer_asn
|
||||
UPDATE sensors SET sensor_class='frequency' WHERE sensor_class='freq';
|
||||
ALTER TABLE `cef_switching` ADD `cef_switching_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
|
||||
ALTER TABLE `mempools` ADD `mempool_perc` INT NOT NULL AFTER `device_id`;
|
||||
ALTER TABLE `observer_dev`.`ports` ADD UNIQUE `device_ifIndex` ( `device_id` , `ifIndex` );
|
||||
ALTER TABLE `ports` DROP INDEX `host`;
|
||||
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;
|
||||
|
190
includes/polling/ospf.inc.php
Normal file
190
includes/polling/ospf.inc.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
echo("OSPF: ");
|
||||
echo("Processes: ");
|
||||
|
||||
$ospf_oids_db = array('ospfRouterId', 'ospfAdminStat', 'ospfVersionNumber', 'ospfAreaBdrRtrStatus', 'ospfASBdrRtrStatus',
|
||||
'ospfExternLsaCount', 'ospfExternLsaCksumSum', 'ospfTOSSupport', 'ospfOriginateNewLsas', 'ospfRxNewLsas',
|
||||
'ospfExtLsdbLimit', 'ospfMulticastExtensions', 'ospfExitOverflowInterval', 'ospfDemandExtensions');
|
||||
|
||||
### Build array of existing entries
|
||||
$query = mysql_query("SELECT * FROM `ospf_instances` WHERE `device_id` = '".$device['device_id']."'");
|
||||
while($entry = mysql_fetch_assoc($query))
|
||||
{
|
||||
$ospf[$entry['ospf_instances_id']] = $entry;
|
||||
}
|
||||
|
||||
### Pull data from device
|
||||
$ospf_data = snmpwalk_cache_oid($device, "OSPF-MIB::ospfGeneralGroup", array(), "OSPF-MIB");
|
||||
foreach($ospf_data as $ospf_instances => $ospf_entry)
|
||||
{
|
||||
### If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
if(!isset($ospf[$ospf_instances]))
|
||||
{
|
||||
mysql_query("INSERT INTO `ospf_instances` (`device_id`, `ospf_instances_id`) VALUES ('".$device['device_id']."','".$ospf_instances."') ");
|
||||
echo("+");
|
||||
$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_instances` WHERE `device_id` = '".$device['device_id']."' AND `ospf_instances_id` = '".$ospf_instances."'"));
|
||||
$ospf[$entry['ospf_instances_id']] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
### Loop array of entries and update
|
||||
if (is_array($ospf)){ foreach($ospf as $ospf_db)
|
||||
{
|
||||
$ospf_poll = $ospf_data[$ospf_db['ospf_instances_id']];
|
||||
foreach ($ospf_oids_db as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($ospf_db[$oid] != $ospf_poll[$oid])
|
||||
{ // If data has changed, build a query
|
||||
$update .= ", `$oid` = '".mres($ospf_poll[$oid])."'";
|
||||
#log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
if($update)
|
||||
{
|
||||
mysql_query("UPDATE `ospf_instances` SET `ospf_instances_id` = '".$ospf_db['ospf_instances_id']."'".$update." WHERE `device_id` = '".$device['device_id']."' AND `ospf_instances_id` = '".$ospf_instances."'");
|
||||
echo("UPDATE `ospf_instances` SET `ospf_instances_id` = '".$ospf_db['ospf_instances_id']."'".$update." WHERE `device_id` = '".$device['device_id']."' AND `ospf_instances_id` = '".$ospf_instances."'");
|
||||
echo("U");
|
||||
unset($update);
|
||||
} else {
|
||||
echo(".");
|
||||
}
|
||||
unset($ospf_poll);
|
||||
unset($ospf_db);
|
||||
}}
|
||||
|
||||
unset($ospf_data);
|
||||
unset($ospf);
|
||||
|
||||
echo(" Areas: ");
|
||||
|
||||
$ospf_area_oids = array('ospfAuthType','ospfImportAsExtern','ospfSpfRuns','ospfAreaBdrRtrCount','ospfAsBdrRtrCount','ospfAreaLsaCount','ospfAreaLsaCksumSum','ospfAreaSummary','ospfAreaStatus');
|
||||
|
||||
### Build array of existing entries
|
||||
$query = mysql_query("SELECT * FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."'");
|
||||
while($entry = mysql_fetch_assoc($query))
|
||||
{
|
||||
$ospf_areas_db[$entry['ospfAreaId']] = $entry;
|
||||
}
|
||||
|
||||
### Pull data from device
|
||||
$ospf_areas_poll = snmpwalk_cache_oid($device, "OSPF-MIB::ospfAreaEntry", array(), "OSPF-MIB");
|
||||
|
||||
foreach($ospf_areas_poll as $ospf_area_id => $ospf_area)
|
||||
{
|
||||
### If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
if(!isset($ospf_areas_db[$ospf_area_id]))
|
||||
{
|
||||
mysql_query("INSERT INTO `ospf_areas` (`device_id`, `ospfAreaId`) VALUES ('".$device['device_id']."','".$ospf_area_id."') ");
|
||||
echo("+");
|
||||
$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_areas` WHERE `device_id` = '".$device['device_id']."' AND `ospfAreaId` = '".$ospf_area_id."'"));
|
||||
$ospf_areas_db[$entry['ospf_area_id']] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
### Loop array of entries and update
|
||||
if (is_array($ospf_areas_db)){ foreach($ospf_areas_db as $ospf_area_db)
|
||||
{
|
||||
$ospf_area_poll = $ospf_areas_poll[$ospf_area_db['ospfAreaId']];
|
||||
foreach ($ospf_area_oids as $oid)
|
||||
{ ## Loop the OIDs
|
||||
if ($ospf_area_db[$oid] != $ospf_area_poll[$oid])
|
||||
{ ## If data has changed, build a query
|
||||
$update .= ", `$oid` = '".mres($ospf_area_poll[$oid])."'";
|
||||
# log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
if($update)
|
||||
{
|
||||
mysql_query("UPDATE `ospf_areas` SET `ospfAreaId` = '".$ospf_area_db['ospfAreaId']."'".$update." WHERE `device_id` = '".$device['device_id']."' AND `ospfAreaId` = '".$ospf_area_id."'");
|
||||
echo("UPDATE `ospf_instances` SET `ospfAreaId` = '".$ospf_area_db['ospfAreaId']."'".$update." WHERE `device_id` = '".$device['device_id']."' AND `ospfAreaId` = '".$ospf_area_id."'");
|
||||
echo("U");
|
||||
unset($update);
|
||||
} else {
|
||||
echo(".");
|
||||
}
|
||||
unset($ospf_area_poll);
|
||||
unset($ospf_area_db);
|
||||
}}
|
||||
|
||||
unset($ospf_areas_db);
|
||||
unset($ospf_areas_poll);
|
||||
|
||||
|
||||
#$ospf_ports = snmpwalk_cache_oid($device, "OSPF-MIB::ospfIfEntry", array(), "OSPF-MIB");
|
||||
#print_r($ospf_ports);
|
||||
|
||||
echo(" Ports: ");
|
||||
|
||||
$ospf_port_oids = array('ospfIfIpAddress','interface_id','ospfAddressLessIf','ospfIfAreaId','ospfIfType','ospfIfAdminStat','ospfIfRtrPriority','ospfIfTransitDelay','ospfIfRetransInterval','ospfIfHelloInterval','ospfIfRtrDeadInterval','ospfIfPollInterval','ospfIfState','ospfIfDesignatedRouter','ospfIfBackupDesignatedRouter','ospfIfEvents','ospfIfAuthKey','ospfIfStatus','ospfIfMulticastForwarding','ospfIfDemand','ospfIfAuthType');
|
||||
|
||||
### Build array of existing entries
|
||||
$query = mysql_query("SELECT * FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."'");
|
||||
while($entry = mysql_fetch_assoc($query))
|
||||
{
|
||||
$ospf_ports_db[$entry['ospf_port_id']] = $entry;
|
||||
}
|
||||
|
||||
### Pull data from device
|
||||
$ospf_ports_poll = snmpwalk_cache_oid($device, "OSPF-MIB::ospfIfEntry", array(), "OSPF-MIB");
|
||||
|
||||
foreach($ospf_ports_poll as $ospf_port_id => $ospf_port)
|
||||
{
|
||||
### If the entry doesn't already exist in the prebuilt array, insert into the database and put into the array
|
||||
if(!isset($ospf_ports_db[$ospf_port_id]))
|
||||
{
|
||||
mysql_query("INSERT INTO `ospf_ports` (`device_id`, `ospf_port_id`) VALUES ('".$device['device_id']."','".$ospf_port_id."') ");
|
||||
echo("+");
|
||||
$entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_id."'"));
|
||||
$ospf_ports_db[$entry['ospf_port_id']] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
print_r($ospf_ports_poll);
|
||||
print_r($ospf_ports_db);
|
||||
### Loop array of entries and update
|
||||
if (is_array($ospf_ports_db)){
|
||||
foreach($ospf_ports_db as $ospf_port_db)
|
||||
{
|
||||
if(is_array($ospf_ports_poll[$ospf_port_db['ospf_port_id']])) {
|
||||
$ospf_port_poll = $ospf_ports_poll[$ospf_port_db['ospf_port_id']];
|
||||
|
||||
if($ospf_port_poll['ospfAddressLessIf'])
|
||||
{
|
||||
$ospf_port_poll['interface_id'] = mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$ospf_port_poll['ospfAddressLessIf']."'"),0);
|
||||
} else {
|
||||
$ospf_port_poll['interface_id'] = mysql_result(mysql_query("SELECT A.`interface_id` FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$ospf_port_poll['ospfIfIpAddress']."' AND I.interface_id = A.interface_id AND I.device_id = '".$device['device_id']."'"),0);
|
||||
}
|
||||
|
||||
foreach ($ospf_port_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($ospf_port_db[$oid] != $ospf_port_poll[$oid])
|
||||
{ // If data has changed, build a query
|
||||
$update .= ", `$oid` = '".mres($ospf_port_poll[$oid])."'";
|
||||
# log_event("$oid -> ".$this_port[$oid], $device, 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
if($update)
|
||||
{
|
||||
$update = "UPDATE `ospf_ports` SET `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'".$update." WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_id."'";
|
||||
mysql_query($update);
|
||||
echo("$update");
|
||||
echo("U");
|
||||
unset($update);
|
||||
} else {
|
||||
echo(".");
|
||||
}
|
||||
unset($ospf_port_poll);
|
||||
unset($ospf_port_db);
|
||||
|
||||
} else {
|
||||
mysql_query("DELETE FROM `ospf_ports` WHERE `device_id` = '".$device['device_id']."' AND `ospf_port_id` = '".$ospf_port_db['ospf_port_id']."'");
|
||||
echo("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($ospf_ports_db);
|
||||
unset($ospf_ports_poll);
|
||||
|
||||
?>
|
@ -348,7 +348,7 @@ function snmpwalk_cache_oid($device, $oid, $array, $mib = NULL, $mibdir = NULL)
|
||||
{
|
||||
list($oid,$value) = explode("=", $entry);
|
||||
$oid = trim($oid); $value = trim($value);
|
||||
list($oid, $index) = explode(".", $oid);
|
||||
list($oid, $index) = explode(".", $oid, 2);
|
||||
if (!strstr($value, "at this OID") && isset($oid) && isset($index))
|
||||
{
|
||||
$array[$index][$oid] = $value;
|
||||
|
@ -239,7 +239,7 @@ while ($device = mysql_fetch_assoc($device_query))
|
||||
include("includes/polling/ucd-diskio.inc.php");
|
||||
include("includes/polling/applications.inc.php");
|
||||
include("includes/polling/wifi.inc.php");
|
||||
|
||||
include("includes/polling/ospf.inc.php");
|
||||
#include("includes/polling/altiga-ssl.inc.php");
|
||||
include("includes/polling/cisco-ipsec-flow-monitor.inc.php");
|
||||
include("includes/polling/cisco-remote-access-monitor.inc.php");
|
||||
|
Reference in New Issue
Block a user