-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'zf-migration-stats' of github.com:islandbridgenetworks/…
…IXP-Manager into zf-migration-stats
- Loading branch information
Showing
8 changed files
with
60 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
use Entities\IXP; | ||
|
||
/** | ||
* Grapher Backend -> Mrtg | ||
* Grapher Backend -> Dummy | ||
* | ||
* @author Barry O'Donovan <[email protected]> | ||
* @category Grapher | ||
|
@@ -194,7 +194,10 @@ public function data( Graph $graph ): array { | |
* {inheritDoc} | ||
* | ||
* @param Graph $graph | ||
* | ||
* @return string | ||
* | ||
* @throws | ||
*/ | ||
public function png( Graph $graph ): string { | ||
return @file_get_contents( $this->resolveFilePath( $graph, 'png' ) ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
*/ | ||
|
||
use IXP\Contracts\Grapher\Backend as GrapherBackendContract; | ||
use IXP\Exceptions\Services\Grapher\CannotHandleRequestException; | ||
use IXP\Services\Grapher\Backend as GrapherBackend; | ||
|
||
use IXP\Services\Grapher\Graph; | ||
|
@@ -37,7 +38,7 @@ | |
use Log; | ||
|
||
/** | ||
* Grapher Backend -> Mrtg | ||
* Grapher Backend -> Sflow | ||
* | ||
* @author Barry O'Donovan <[email protected]> | ||
* @category Grapher | ||
|
@@ -92,7 +93,7 @@ public function isMultiFileConfigurationSupported(): bool { | |
* | ||
* {inheritDoc} | ||
* | ||
* @param int $config_type The type of configuration to generate | ||
* @param int $type The type of configuration to generate | ||
* @return array | ||
*/ | ||
public function generateConfiguration( int $type = self::GENERATED_CONFIG_TYPE_MONOLITHIC ): array | ||
|
@@ -140,7 +141,10 @@ public static function supports(): array { | |
* {inheritDoc} | ||
* | ||
* @param \IXP\Services\Grapher\Graph $graph | ||
* | ||
* @return array | ||
* | ||
* @throws | ||
*/ | ||
public function data( Graph $graph ): array { | ||
try { | ||
|
@@ -158,7 +162,10 @@ public function data( Graph $graph ): array { | |
* {inheritDoc} | ||
* | ||
* @param Graph $graph | ||
* | ||
* @return string | ||
* | ||
* @throws | ||
*/ | ||
public function png( Graph $graph ): string { | ||
try { | ||
|
@@ -176,7 +183,10 @@ public function png( Graph $graph ): string { | |
* {inheritDoc} | ||
* | ||
* @param Graph $graph | ||
* | ||
* @return string | ||
* | ||
* @throws | ||
*/ | ||
public function rrd( Graph $graph ): string { | ||
try { | ||
|
@@ -206,26 +216,31 @@ private function translateCategory( $c ): string { | |
* For a given graph, return the filename where the appropriate data | ||
* will be found. | ||
* | ||
* @param Graph $graph | ||
* @param Graph $graph | ||
* @param string $type | ||
* | ||
* @return string | ||
* | ||
* @throws | ||
*/ | ||
private function resolveFileName( Graph $graph, $type ): string { | ||
$config = config('grapher.backends.sflow'); | ||
|
||
switch( $graph->classType() ) { | ||
case 'Vlan': | ||
/** @var Graph\Vlan $graph */ | ||
return sprintf( "aggregate.%s.%s.vlan%05d.%s", | ||
$graph->protocol(), $this->translateCategory( $graph->category() ), | ||
$graph->vlan()->getNumber(), $type ); | ||
break; | ||
|
||
case 'VlanInterface': | ||
/** @var Graph\VlanInterface $graph */ | ||
return sprintf( "individual.%s.%s.src-%05d.%s", | ||
$graph->protocol(), $this->translateCategory( $graph->category() ), | ||
$graph->vlanInterface()->getId(), $type ); | ||
break; | ||
|
||
case 'P2p': | ||
/** @var Graph\P2p $graph */ | ||
return sprintf( "p2p.%s.%s.src-%05d.dst-%05d.%s", | ||
$graph->protocol(), $this->translateCategory( $graph->category() ), | ||
$graph->svli()->getId(), $graph->dvli()->getId(), $type ); | ||
|
@@ -241,25 +256,31 @@ private function resolveFileName( Graph $graph, $type ): string { | |
* will be found. | ||
* | ||
* @param Graph $graph | ||
* | ||
* @return string | ||
* | ||
* @throws | ||
*/ | ||
private function resolveFilePath( Graph $graph, $type ): string { | ||
$config = config('grapher.backends.sflow'); | ||
|
||
switch( $graph->classType() ) { | ||
case 'Vlan': | ||
/** @var Graph\Vlan $graph */ | ||
return sprintf( "%s/%s/%s/aggregate/%s", $config['root'], | ||
$graph->protocol(), $this->translateCategory( $graph->category() ), | ||
$this->resolveFileName( $graph, $type ) ); | ||
break; | ||
|
||
case 'VlanInterface': | ||
/** @var Graph\VlanInterface $graph */ | ||
return sprintf( "%s/%s/%s/individual/%s", $config['root'], | ||
$graph->protocol(), $this->translateCategory( $graph->category() ), | ||
$this->resolveFileName( $graph, $type ) ); | ||
break; | ||
|
||
case 'P2p': | ||
/** @var Graph\P2p $graph */ | ||
return sprintf( "%s/%s/%s/p2p/src-%05d/%s", $config['root'], | ||
$graph->protocol(), $this->translateCategory( $graph->category() ), | ||
$graph->svli()->getId(), $this->resolveFileName( $graph, $type ) ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters