Add OSPF cost (TOS) (#11929)

* add OspfTos model to include ospfIfMetricEntry data (ospf interface cost)

* remove WIP comment

* add new model and db migration

* update OspfTos relationship to OspfPort and correct cleanup call

* add "Cost" to device\routing\ospf web UI interface

* updated db-schema test unit

* updated db_schema to resolve conflicts

* removed tos metrics from rrd ospf stats due to rrdcached errors

* reorder db_schema.yaml to match upstream

* readd ospf_tos to db_schema

* styleCI changes

* Capture OSPF test data

* add ospf unit tests for iosxr

* ospfAuthType

* update db_schema

* remove extra migrations

* add ospf tests for iosxe

* add ospf test to ios

* merge ospf_tos into ospf_ports

* update db_schema

* update ospf module unit tests for ios, iosxe, iosxr

* fix ospf_ports ospfIfMetricStatus column type

* update db_schema

* more efficient dropColumn in down() migration

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Hayden
2020-11-07 07:27:25 -08:00
committed by GitHub
parent f7f2688125
commit e34b6877fd
11 changed files with 14122 additions and 25 deletions

View File

@@ -56,6 +56,11 @@ class OspfPort extends PortRelatedModel
'ospfIfMulticastForwarding',
'ospfIfDemand',
'ospfIfAuthType',
'ospfIfMetricIpAddress',
'ospfIfMetricAddressLessIf',
'ospfIfMetricTOS',
'ospfIfMetricValue',
'ospfIfMetricStatus',
];
// ---- Define Relationships ----

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTosToOspfPorts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ospf_ports', function (Blueprint $table) {
$table->string('ospfIfMetricIpAddress', 32)->nullable()->after('ospfIfAuthType');
$table->integer('ospfIfMetricAddressLessIf')->nullable()->after('ospfIfMetricIpAddress');
$table->integer('ospfIfMetricTOS')->nullable()->after('ospfIfMetricAddressLessIf');
$table->integer('ospfIfMetricValue')->nullable()->after('ospfIfMetricTOS');
$table->string('ospfIfMetricStatus', 32)->nullable()->after('ospfIfMetricValue');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('ospf_ports', function (Blueprint $table) {
$table->dropColumn(['ospfIfMetricIpAddress', 'ospfIfMetricAddressLessIf', 'ospfIfMetricTOS', 'ospfIfMetricValue', 'ospfIfMetricStatus']);
});
}
}

View File

@@ -93,6 +93,7 @@ foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', [$d
<th>Port</th>
<th>Port Type</th>
<th>Port State</th>
<th>Cost</th>
<th>Status</th>
<th>Area ID</th>
</tr>
@@ -112,6 +113,7 @@ foreach (dbFetchRows('SELECT * FROM `ospf_instances` WHERE `device_id` = ?', [$d
<td>' . generate_port_link($ospfport) . '</td>
<td>' . $ospfport['ospfIfType'] . '</td>
<td>' . $ospfport['ospfIfState'] . '</td>
<td>' . $ospfport['ospfIfMetricValue'] . '</td>
<td><span class="label label-' . $port_status_color . '">' . $ospfport['ospfIfAdminStat'] . '</span></td>
<td>' . $ospfport['ospfIfAreaId'] . '</td>
</tr>

View File

@@ -134,6 +134,30 @@ foreach ($vrfs_lite_cisco as $vrf_lite) {
->whereNotIn('id', $ospf_neighbours->pluck('id'))->delete();
echo $ospf_neighbours->count();
echo ' TOS Metrics: ';
// Pull data from device
$ospf_tos_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfIfMetricEntry', [], 'OSPF-MIB');
d_echo($ospf_tos_poll);
$ospf_tos_metrics = collect();
foreach ($ospf_tos_poll as $ospf_tos_id => $ospf_tos) {
// get ospf_port_id
$ospf_tos['ospf_port_id'] = OspfPort::query()
->where('ospfIfIpAddress', $ospf_tos['ospfIfMetricIpAddress'])
->where('context_name', $device['context_name'])
->value('ospf_port_id');
$tos = OspfPort::updateOrCreate([
'device_id' => $device['device_id'],
'ospf_port_id' => $ospf_tos['ospf_port_id'],
'context_name' => $device['context_name'],
], $ospf_tos);
$ospf_tos_metrics->push($tos);
}
echo $ospf_tos_metrics->count();
}
unset($device['context_name'], $vrfs_lite_cisco, $vrf_lite);
@@ -181,6 +205,9 @@ unset(
$ospf_nbr,
$neighbour,
$ospf_nbr_id,
$ospf_tos,
$tos,
$ospf_tos_id,
$rrd_def,
$fields,
$tags

View File

@@ -1260,6 +1260,11 @@ ospf_ports:
- { Field: ospfIfMulticastForwarding, Type: varchar(32), 'Null': true, Extra: '' }
- { Field: ospfIfDemand, Type: varchar(32), 'Null': true, Extra: '' }
- { Field: ospfIfAuthType, Type: varchar(32), 'Null': true, Extra: '' }
- { Field: ospfIfMetricIpAddress, Type: varchar(32), 'Null': true, Extra: '' }
- { Field: ospfIfMetricAddressLessIf, Type: int, 'Null': true, Extra: '' }
- { Field: ospfIfMetricTOS, Type: int, 'Null': true, Extra: '' }
- { Field: ospfIfMetricValue, Type: int, 'Null': true, Extra: '' }
- { Field: ospfIfMetricStatus, Type: varchar(32), 'Null': true, Extra: '' }
- { Field: context_name, Type: varchar(128), 'Null': true, Extra: '' }
Indexes:
PRIMARY: { Name: PRIMARY, Columns: [id], Unique: true, Type: BTREE }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -28874,5 +28874,140 @@
}
]
}
},
"ospf": {
"poller": {
"ospf_ports": [
{
"ospf_port_id": "0.0.0.3.0",
"ospfIfIpAddress": "0.0.0.3",
"ospfAddressLessIf": 0,
"ospfIfAreaId": "0.0.0.0",
"ospfIfType": "pointToPoint",
"ospfIfAdminStat": "enabled",
"ospfIfRtrPriority": 1,
"ospfIfTransitDelay": 1,
"ospfIfRetransInterval": 5,
"ospfIfHelloInterval": 10,
"ospfIfRtrDeadInterval": 40,
"ospfIfPollInterval": 120,
"ospfIfState": "pointToPoint",
"ospfIfDesignatedRouter": "0.0.0.0",
"ospfIfBackupDesignatedRouter": "0.0.0.0",
"ospfIfEvents": 1,
"ospfIfAuthKey": null,
"ospfIfStatus": "active",
"ospfIfMulticastForwarding": "blocked",
"ospfIfDemand": "false",
"ospfIfAuthType": "none",
"ospfIfMetricIpAddress": "0.0.0.3",
"ospfIfMetricAddressLessIf": 0,
"ospfIfMetricTOS": 0,
"ospfIfMetricValue": 1,
"ospfIfMetricStatus": "active",
"context_name": null,
"ifIndex": null
},
{
"ospf_port_id": "0.0.0.5.0",
"ospfIfIpAddress": "0.0.0.5",
"ospfAddressLessIf": 0,
"ospfIfAreaId": "0.0.0.0",
"ospfIfType": "pointToPoint",
"ospfIfAdminStat": "enabled",
"ospfIfRtrPriority": 1,
"ospfIfTransitDelay": 1,
"ospfIfRetransInterval": 5,
"ospfIfHelloInterval": 10,
"ospfIfRtrDeadInterval": 40,
"ospfIfPollInterval": 120,
"ospfIfState": "pointToPoint",
"ospfIfDesignatedRouter": "0.0.0.0",
"ospfIfBackupDesignatedRouter": "0.0.0.0",
"ospfIfEvents": 1,
"ospfIfAuthKey": null,
"ospfIfStatus": "active",
"ospfIfMulticastForwarding": "blocked",
"ospfIfDemand": "false",
"ospfIfAuthType": "none",
"ospfIfMetricIpAddress": "0.0.0.5",
"ospfIfMetricAddressLessIf": 0,
"ospfIfMetricTOS": 0,
"ospfIfMetricValue": 100,
"ospfIfMetricStatus": "active",
"context_name": null,
"ifIndex": null
}
],
"ospf_instances": [
{
"ospf_instance_id": 0,
"ospfRouterId": "0.0.0.1",
"ospfAdminStat": "enabled",
"ospfVersionNumber": "version2",
"ospfAreaBdrRtrStatus": "false",
"ospfASBdrRtrStatus": "true",
"ospfExternLsaCount": 3452,
"ospfExternLsaCksumSum": 113033774,
"ospfTOSSupport": "false",
"ospfOriginateNewLsas": 14738,
"ospfRxNewLsas": 2460205,
"ospfExtLsdbLimit": 10240,
"ospfMulticastExtensions": 0,
"ospfExitOverflowInterval": 0,
"ospfDemandExtensions": "true",
"context_name": null
}
],
"ospf_areas": [
{
"ospfAreaId": "0.0.0.0",
"ospfAuthType": null,
"ospfImportAsExtern": "importExternal",
"ospfSpfRuns": 1974,
"ospfAreaBdrRtrCount": 3,
"ospfAsBdrRtrCount": 154,
"ospfAreaLsaCount": 705,
"ospfAreaLsaCksumSum": 22790689,
"ospfAreaSummary": "sendAreaSummary",
"ospfAreaStatus": "active",
"context_name": null
}
],
"ospf_nbrs": [
{
"port_id": null,
"ospf_nbr_id": "0.0.0.4.0",
"ospfNbrIpAddr": "0.0.0.4",
"ospfNbrAddressLessIndex": 0,
"ospfNbrRtrId": "0.0.0.2",
"ospfNbrOptions": 82,
"ospfNbrPriority": 0,
"ospfNbrState": "full",
"ospfNbrEvents": 6,
"ospfNbrLsRetransQLen": 0,
"ospfNbmaNbrStatus": "active",
"ospfNbmaNbrPermanence": "dynamic",
"ospfNbrHelloSuppressed": "false",
"context_name": null
},
{
"port_id": null,
"ospf_nbr_id": "0.0.0.6.0",
"ospfNbrIpAddr": "0.0.0.6",
"ospfNbrAddressLessIndex": 0,
"ospfNbrRtrId": "0.0.0.2",
"ospfNbrOptions": 82,
"ospfNbrPriority": 0,
"ospfNbrState": "full",
"ospfNbrEvents": 6,
"ospfNbrLsRetransQLen": 0,
"ospfNbmaNbrStatus": "active",
"ospfNbmaNbrPermanence": "dynamic",
"ospfNbrHelloSuppressed": "false",
"context_name": null
}
]
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -660,6 +660,131 @@
1.3.6.1.2.1.10.7.2.1.19.48|2|3
1.3.6.1.2.1.10.7.2.1.19.49|2|3
1.3.6.1.2.1.10.7.2.1.19.50|2|3
1.3.6.1.2.1.14.1.1.0|64|0.0.0.1
1.3.6.1.2.1.14.1.2.0|2|1
1.3.6.1.2.1.14.1.3.0|2|2
1.3.6.1.2.1.14.1.4.0|2|2
1.3.6.1.2.1.14.1.5.0|2|1
1.3.6.1.2.1.14.1.6.0|66|3452
1.3.6.1.2.1.14.1.7.0|2|113033774
1.3.6.1.2.1.14.1.8.0|2|2
1.3.6.1.2.1.14.1.9.0|65|14738
1.3.6.1.2.1.14.1.10.0|65|2460205
1.3.6.1.2.1.14.1.11.0|2|10240
1.3.6.1.2.1.14.1.12.0|2|0
1.3.6.1.2.1.14.1.13.0|2|0
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