Skip to content

Commit

Permalink
[IM] Dashbord accounts for rate limited ports.
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Nov 14, 2021
1 parent fb155a4 commit ab98fc1
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 9 deletions.
42 changes: 33 additions & 9 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
Customer,
Infrastructure,
Location,
PhysicalInterface,
Vlan,
VlanInterface};

Expand Down Expand Up @@ -100,6 +101,11 @@ private function dashboardStats( Request $r ): array
$custsByInfra = [];
$peeringCusts = [];

// for rate limited ports:
$rateLimitedPorts = [];
$pispeeds = PhysicalInterface::$SPEED;
krsort( $pispeeds, SORT_NUMERIC );


foreach( $vis as $vi ) {
$location = $vi[ 'locationname' ];
Expand Down Expand Up @@ -132,10 +138,27 @@ private function dashboardStats( Request $r ): array
$custsByLocation[ $location ]['cabinets'][$cabinet][ 'custs' ][] = $custid;
}

if ( !isset($speeds[ $vi[ 'speed' ] ])) {
$speeds[ $vi[ 'speed' ] ] = 1;
// Speeds have gotten more complex now that we've add rate limiters, sigh.
// We're not going to go around the houses here to solve odd services - speeds
// should be a multiple of physical speeds.
$speed = $vi[ 'speed' ];
$numports = 1;

if( $vi[ 'rlspeed' ] ) {
foreach( array_keys( $pispeeds ) as $kspeed ) {
if( $vi[ 'rlspeed' ] >= $kspeed ) {
$speed = $kspeed;
$numports = round( $vi[ 'rlspeed' ] / $kspeed );
$rateLimitedPorts[] = [ 'physint' => $vi['speed'], 'numports' => $numports, 'rlspeed' => $speed ];
break;
}
}
}

if ( !isset($speeds[ $speed ])) {
$speeds[ $speed ] = $numports;
} else {
$speeds[ $vi[ 'speed' ] ]++;
$speeds[ $speed ] += $numports;
}

if ( !isset($custsByInfra[ $infrastructure ])) {
Expand All @@ -159,10 +182,10 @@ private function dashboardStats( Request $r ): array
$byLocation[ $location ]['cabinets'][ $cabinet ] = [ 'id' => $vi[ 'cabinetid' ] ];
}

if ( !isset($byLocation[ $vi[ 'locationname' ] ][ $vi[ 'speed' ] ])) {
$byLocation[ $location ][ $vi[ 'speed' ] ] = 1;
if ( !isset($byLocation[ $vi[ 'locationname' ] ][ $speed ])) {
$byLocation[ $location ][ $speed ] = $numports;
} else {
$byLocation[ $location ][ $vi[ 'speed' ] ]++;
$byLocation[ $location ][ $speed ] += $numports;
}

if ( !isset($byLocation[ $location ]['cabinets'][ $cabinet ][ $vi[ 'speed' ] ])) {
Expand All @@ -175,10 +198,10 @@ private function dashboardStats( Request $r ): array
$byLan[ $infrastructure ] = [ 'id' => $vi[ 'infrastructureid' ] ];
}

if ( !isset( $byLan[ $infrastructure ][ $vi[ 'speed' ] ] ) ) {
$byLan[ $infrastructure ][ $vi[ 'speed' ] ] = 1;
if ( !isset( $byLan[ $infrastructure ][ $speed ] ) ) {
$byLan[ $infrastructure ][ $speed ] = $numports;
} else {
$byLan[ $infrastructure ][ $vi[ 'speed' ] ]++;
$byLan[ $infrastructure ][ $speed ] += $numports;
}
}

Expand All @@ -195,6 +218,7 @@ private function dashboardStats( Request $r ): array
$cTypes[ 'byIxp' ] = $byIxp;
$cTypes[ 'custsByInfra' ] = $custsByInfra;
$cTypes[ 'peeringCusts' ] = $peeringCusts;
$cTypes[ 'rateLimitedPorts' ] = $rateLimitedPorts;

// FROM of query is vlaninterface so should be current:
$cTypes[ 'usage' ] = VlanInterface::selectRaw(
Expand Down
1 change: 1 addition & 0 deletions app/Models/Aggregators/VirtualInterfaceAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public static function getByLocation(): array
'cust.id AS customerid',
'vi.id AS id',
'pi.speed AS speed',
'pi.rate_limit AS rlspeed',
'i.id AS infrastructureid',
'i.name AS infrastructure',
'l.id AS locationid',
Expand Down
60 changes: 60 additions & 0 deletions resources/views/admin/dashboard.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@
</tr>
</tbody>
</table>

<?php if( count( $t->stats[ "rateLimitedPorts" ] ) ): ?>
<p>
<i>These statistics take account of rate limited / partial speed ports. See <a href="<?= route('admin@dashboard') ?>#rate_limited_details">
here for details</a>.
</i>
</p>
<?php endif; ?>



</div>
<?php endif; ?>

Expand Down Expand Up @@ -528,6 +539,55 @@



<?php if( count( $t->stats[ "rateLimitedPorts" ] ) ): ?>
<div class="tw-my-12">
<h4 class="tw-mb-6" id="rate_limited_details">
<?= ucfirst( config( 'ixp_fe.lang.customer.one' ) ) ?> Rate Limited / Partial Speed Ports
</h4>

<p>
The above statistics take account of the following rate limited ports. By <i>take account of</i> we
mean that if a 10Gb port is rate limited as 2Gb then the above statistics reflect it as 2 x 1Gb
ports and the 10Gb is ignored.
</p>

<table class="table table-sm table-hover table-striped tw-shadow-md tw-rounded-sm">
<thead class="tw-text-sm">
<tr>
<th>
Physical Port Speed
</th>
<th class="tw-text-sm">
Rate Limit
</th>
<th class="tw-text-sm">
Account For As
</th>
</tr>
</thead>

<tbody class="tw-text-sm">
<?php foreach( $t->stats[ "rateLimitedPorts"] as $rateLimitedPorts => $rlp ): ?>
<tr>
<td>
<?= $t->scaleSpeed( $rlp['physint']) ?>
</td>
<td>
<?= $t->scaleSpeed( $rlp['numports'] * $rlp['rlspeed'] ) ?>
</td>
<td>
<?= $rlp['numports'] ?> x <?= $t->scaleSpeed( $rlp['rlspeed']) ?>
</td>
</tr>
<?php endforeach; ?>

</tbody>
</table>
</div>
<?php endif; ?>





</div>
Expand Down

0 comments on commit ab98fc1

Please sign in to comment.