-
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.
[REVIEW] - [ZF] Migrate remaining statistics / smokeping controllers - …
…closes islandbridgenetworks/IXP-Manager#119
- Loading branch information
Showing
10 changed files
with
67 additions
and
46 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 | ||
|
@@ -195,7 +195,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,8 +93,9 @@ public function isMultiFileConfigurationSupported(): bool { | |
* | ||
* {inheritDoc} | ||
* | ||
* @param IXP $ixp The IXP to generate the config for (multi-IXP mode) | ||
* @param int $config_type The type of configuration to generate | ||
* @param IXP $ixp The IXP to generate the config for (multi-IXP mode) | ||
* @param int $type The type of configuration to generate | ||
* | ||
* @return array | ||
*/ | ||
public function generateConfiguration( IXP $ixp, int $type = self::GENERATED_CONFIG_TYPE_MONOLITHIC ): array | ||
|
@@ -141,7 +143,10 @@ public static function supports(): array { | |
* {inheritDoc} | ||
* | ||
* @param \IXP\Services\Grapher\Graph $graph | ||
* | ||
* @return array | ||
* | ||
* @throws | ||
*/ | ||
public function data( Graph $graph ): array { | ||
try { | ||
|
@@ -159,7 +164,10 @@ public function data( Graph $graph ): array { | |
* {inheritDoc} | ||
* | ||
* @param Graph $graph | ||
* | ||
* @return string | ||
* | ||
* @throws | ||
*/ | ||
public function png( Graph $graph ): string { | ||
try { | ||
|
@@ -177,7 +185,10 @@ public function png( Graph $graph ): string { | |
* {inheritDoc} | ||
* | ||
* @param Graph $graph | ||
* | ||
* @return string | ||
* | ||
* @throws | ||
*/ | ||
public function rrd( Graph $graph ): string { | ||
try { | ||
|
@@ -207,26 +218,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 ); | ||
|
@@ -242,25 +258,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