Skip to content

Commit

Permalink
[IM] Potential fix for #855
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Jul 1, 2023
1 parent 855e258 commit 4cc2d2f
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions app/Services/Grapher/Backend/Mrtg.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,14 @@ public function getPeeringPorts(): array
if( !$pi->isConnectedOrQuarantine()
|| !$pi->switchPort->ifIndex
|| !( $pi->switchPort->switcher->active && $pi->switchPort->switcher->poll )
|| $pi->switchPort->typeReseller()
|| $pi->switchPort->typeFanout()
) {
continue;
}

$data[ 'pis' ][ $pi->id ] = $pi;

if( !isset( $data[ 'custs' ][ $c->id ] ) ) {
$data[ 'custs' ][ $c->id ] = $c;
$data[ 'custs' ][ $c->id ] = $c;
}

if( !isset( $data['sws'][ $pi->switchPort->switcher->id ] ) ) {
Expand Down Expand Up @@ -224,18 +222,23 @@ public function getPeeringPorts(): array
$data[ 'custlags' ][ $c->id ][ $vi->id ][] = $pi->id;
}

$data['swports'][ $pi->switchPort->switcher->id ][] = $pi->id;
$data['locports'][ $pi->switchPort->switcher->cabinet->location->id ][] = $pi->id;
$data['infraports'][ $pi->switchPort->switcher->infrastructureModel->id ][] = $pi->id;
$data['ixpports'][] = $pi->id;

$maxbytes = $pi->detectedSpeed() * 1000000 / 8; // Mbps * bps / to bytes
$switcher = $pi->switchPort->switcher;
$location = $pi->switchPort->switcher->cabinet->location;
$data['swports_maxbytes' ][ $switcher->id ] += $maxbytes;
$data['locports_maxbytes' ][ $location->id ] += $maxbytes;
$data['infraports_maxbytes'][ $switcher->infrastructureModel->id ] += $maxbytes;
$data['ixpports_maxbytes'] += $maxbytes;

// don't count reseller ports or fanout ports in agregates
if( !$pi->switchPort->typeReseller() && !$pi->switchPort->typeFanout() ) {
$data[ 'swports' ][ $pi->switchPort->switcher->id ][] = $pi->id;
$data[ 'locports' ][ $pi->switchPort->switcher->cabinet->location->id ][] = $pi->id;
$data[ 'infraports' ][ $pi->switchPort->switcher->infrastructureModel->id ][] = $pi->id;
$data[ 'ixpports' ][] = $pi->id;

$data['swports_maxbytes' ][ $switcher->id ] += $maxbytes;
$data['locports_maxbytes' ][ $location->id ] += $maxbytes;
$data['infraports_maxbytes'][ $switcher->infrastructureModel->id ] += $maxbytes;
$data['ixpports_maxbytes'] += $maxbytes;
}

}
}
}
Expand Down

0 comments on commit 4cc2d2f

Please sign in to comment.