Skip to content

Commit

Permalink
Ignore reseller ports when generting MRTG configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Jun 19, 2023
1 parent d50e45b commit e40be75
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions app/Services/Grapher/Backend/Mrtg.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,19 @@ public function getPeeringPorts(): array
continue;
}

/** @var PhysicalInterface $pi */
foreach( $vi->physicalInterfaces as $pi ) {
if( $pi->id > $maxPiID ) {
$maxPiID = $pi->id;
}

// per inex/IXP-Manager##746 - added ifIndex check to skip manually added dummy ports
if( !$pi->isConnectedOrQuarantine() || !$pi->switchPort->ifIndex || !( $pi->switchPort->switcher->active && $pi->switchPort->switcher->poll ) ) {
if( !$pi->isConnectedOrQuarantine()
|| !$pi->switchPort->ifIndex
|| !( $pi->switchPort->switcher->active && $pi->switchPort->switcher->poll )
|| $pi->switchPort->typeReseller()
|| $pi->switchPort->typeFanout()
) {
continue;
}

Expand Down Expand Up @@ -211,6 +217,7 @@ public function getPeeringPorts(): array
$data['infraports_maxbytes'][ $i->id ] = 0;
}


$data[ 'custports' ][ $c->id ][] = $pi->id;

if( $vi->physicalInterfaces->count() > 1 ) {
Expand Down Expand Up @@ -276,7 +283,7 @@ public function getPeeringPorts(): array
}
}

// include core switch ports.
// include core + fanout + reseller switch ports in switch aggregates ("how much work is the switch doing?")
// This is a slight hack as the template requires PhysicalInterfaces so we wrap core SwitchPorts in temporary PhyInts.
foreach( Infrastructure::all() as $infra ) {
foreach( $infra->switchers as $switch ) {
Expand All @@ -285,10 +292,17 @@ public function getPeeringPorts(): array
continue;
}

/** @var SwitchPort $sp */
foreach( $switch->switchPorts as $sp ) {
if( $sp->typeCore() ) {
if( $sp->typeCore() || $sp->typeReseller() || $sp->typeFanout() ) {

// this needs to be wrapped in a physical interface for the template
$pi = $this->wrapSwitchPortInPhysicalInterface( $sp, ++$maxPiID );
// [TODO 2023-06 is this necessary with CoreBundles? Probably for anyone not using them...]
if( $sp->physicalInterface ) {
$pi = $sp->physicalInterface;
} else {
$pi = $this->wrapSwitchPortInPhysicalInterface( $sp, ++$maxPiID );
}
$data[ 'pis' ][ $pi->id ] = $pi;
$data[ 'swports' ][ $switch->id ][] = $pi->id;

Expand Down

0 comments on commit e40be75

Please sign in to comment.