Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LibreNMS/Data/Graphing/AbstractGraph.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* AbstractGraph.php
*
Expand Down Expand Up @@ -53,6 +54,7 @@ public function fill(array $vars): self
}
}
}

return $this;
}
}
10 changes: 10 additions & 0 deletions LibreNMS/Data/Graphing/Builders/MultiLineGraphBuilder.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* MultiLineGraphBuilder.php
*
Expand Down Expand Up @@ -33,7 +34,7 @@
{
private string $unitText = '';
private string $units = '';
private string $totalUnits = '%';

Check failure on line 37 in LibreNMS/Data/Graphing/Builders/MultiLineGraphBuilder.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Property LibreNMS\Data\Graphing\Builders\MultiLineGraphBuilder::$totalUnits is never read, only written.
private string $colours = 'mixed';
private ?float $scaleMin = null;
private ?float $scaleMax = null;
Expand All @@ -45,48 +46,56 @@
public function unitText(string $unitText): self
{
$this->unitText = $unitText;

return $this;
}

public function units(string $units): self
{
$this->units = $units;

return $this;
}

public function totalUnits(string $totalUnits): self
{
$this->totalUnits = $totalUnits;

return $this;
}

public function colours(string $colours): self
{
$this->colours = $colours;

return $this;
}

public function scaleMin(float $scaleMin): self
{
$this->scaleMin = $scaleMin;

return $this;
}

public function scaleMax(float $scaleMax): self
{
$this->scaleMax = $scaleMax;

return $this;
}

public function noTotal(bool $noTotal = true): self
{
$this->nototal = $noTotal;

return $this;
}

public function descrLen(int $descrLen): self
{
$this->descrLen = $descrLen;

return $this;
}

Expand All @@ -108,6 +117,7 @@
'areacolour' => $areaColour,
'invert' => $invert,
];

return $this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* MultiSimplexSeparatedGraphBuilder.php
*
Expand Down Expand Up @@ -32,7 +33,7 @@
class MultiSimplexSeparatedGraphBuilder
{
private string $unitText = '';
private string $units = '';

Check failure on line 36 in LibreNMS/Data/Graphing/Builders/MultiSimplexSeparatedGraphBuilder.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Property LibreNMS\Data\Graphing\Builders\MultiSimplexSeparatedGraphBuilder::$units is never read, only written.
private string $totalUnits = '';
private string $colours = 'mixed';
private ?float $scaleMin = null;
Expand All @@ -48,66 +49,77 @@
public function unitText(string $unitText): self
{
$this->unitText = $unitText;

return $this;
}

public function units(string $units): self
{
$this->units = $units;

return $this;
}

public function totalUnits(string $totalUnits): self
{
$this->totalUnits = $totalUnits;

return $this;
}

public function colours(string $colours): self
{
$this->colours = $colours;

return $this;
}

public function scaleMin(float $scaleMin): self
{
$this->scaleMin = $scaleMin;

return $this;
}

public function scaleMax(float $scaleMax): self
{
$this->scaleMax = $scaleMax;

return $this;
}

public function divider(float $divider): self
{
$this->divider = $divider;

return $this;
}

public function multiplier(float $multiplier): self
{
$this->multiplier = $multiplier;

return $this;
}

public function textOrig(bool $textOrig = true): self
{
$this->textOrig = $textOrig;

return $this;
}

public function noTotal(bool $noTotal = true): self
{
$this->nototal = $noTotal;

return $this;
}

public function descrLen(int $descrLen): self
{
$this->descrLen = $descrLen;

return $this;
}

Expand All @@ -123,6 +135,7 @@
'descr' => $description,
'colour' => $colour,
];

return $this;
}

Expand Down
2 changes: 2 additions & 0 deletions LibreNMS/Data/Graphing/Device/ProcessorGraph.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* ProcessorGraph.php
*
Expand Down Expand Up @@ -71,6 +72,7 @@ public function getRrdFiles(): array
foreach ($this->processors as $proc) {
$files[] = Rrd::name($this->device->hostname, ['processor', $proc->processor_type, $proc->processor_index]);
}

return $files;
}

Expand Down
3 changes: 2 additions & 1 deletion LibreNMS/Data/Graphing/GraphFactory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* GraphFactory.php
*
Expand Down Expand Up @@ -45,7 +46,7 @@ public function graphFor(string $name, array $vars = []): GraphInterface
$vars['type'] ??= $name;

// Look for a modern class, e.g. LibreNMS\Data\Graphing\Device\ProcessorSeparateGraph
$className = "LibreNMS\\Data\\Graphing\\" . ucfirst($type) . "\\" . \Illuminate\Support\Str::studly($subtype) . "Graph";
$className = 'LibreNMS\\Data\\Graphing\\' . ucfirst($type) . '\\' . \Illuminate\Support\Str::studly($subtype) . 'Graph';
if (class_exists($className)) {
return app($className, ['vars' => $vars]);
}
Expand Down
8 changes: 7 additions & 1 deletion LibreNMS/Data/Graphing/LegacyGraph.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* LegacyGraph.php
*
Expand Down Expand Up @@ -29,6 +30,7 @@
use App\Models\Device;
use App\Models\Port;
use LibreNMS\Exceptions\InvalidGraph;

use function base_path;

class LegacyGraph extends AbstractGraph
Expand Down Expand Up @@ -104,6 +106,7 @@ private function load(array $vars = []): void

if (! $auth) {
$this->loaded = true;

return;
}

Expand Down Expand Up @@ -145,19 +148,21 @@ private function load(array $vars = []): void
public function authorize(): bool
{
$this->load();

return $this->authorized;
}


public function definition(GraphParameters $graph_params): array
{
$this->load($graph_params->all());

return $this->rrdOptions;
}

public function getPageTitle(): string
{
$this->load();

return $this->pageTitle ?? $this->getGraphTitle();
}

Expand All @@ -179,6 +184,7 @@ public function getGraphTitle(): string
public function getRrdFiles(): array
{
$this->load();

return $this->rrdFiles;
}
}
9 changes: 5 additions & 4 deletions LibreNMS/Exceptions/InvalidGraph.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* InvalidGraph.php
*
Expand Down Expand Up @@ -29,8 +30,8 @@

class InvalidGraph extends RrdException
{
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message ?: "Invalid Graph", $code, $previous);
}
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message ?: 'Invalid Graph', $code, $previous);
}
}
6 changes: 6 additions & 0 deletions LibreNMS/Interfaces/Data/Graphing/GraphInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* GraphInterface.php
*
Expand Down Expand Up @@ -30,9 +31,14 @@
interface GraphInterface
{
public function authorize(): bool;

public function validation(): array;

public function definition(GraphParameters $graph_params): array;

public function getPageTitle(): string;

public function getGraphTitle(): string;

public function getRrdFiles(): array;
}
9 changes: 4 additions & 5 deletions app/Console/Commands/GraphDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
'device' => $device->device_id,
]);

$this->line("Type: $graph->type");

Check failure on line 24 in app/Console/Commands/GraphDetail.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Access to an undefined property LibreNMS\Interfaces\Data\Graphing\GraphInterface::$type.
$this->line("Subtype: $graph->subtype");

Check failure on line 25 in app/Console/Commands/GraphDetail.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Access to an undefined property LibreNMS\Interfaces\Data\Graphing\GraphInterface::$subtype.
$this->line('Authorized: ' . ($graph->authorize() ? 'true' : 'false'));
$this->line("Graph Title: " . $graph->getGraphTitle());
$this->line("Page Title: " . substr($graph->getPageTitle(), 0, 80));
$this->line("Rrd Files: " . implode(', ', array_map(fn($f) => basename($f), $graph->getRrdFiles())));
$this->line("Definition: " . substr(implode(' ', $graph->definition()), 80));

$this->line('Graph Title: ' . $graph->getGraphTitle());
$this->line('Page Title: ' . substr($graph->getPageTitle(), 0, 80));
$this->line('Rrd Files: ' . implode(', ', array_map(fn ($f) => basename($f), $graph->getRrdFiles())));
$this->line('Definition: ' . substr(implode(' ', $graph->definition()), 80));

Check failure on line 30 in app/Console/Commands/GraphDetail.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method LibreNMS\Interfaces\Data\Graphing\GraphInterface::definition() invoked with 0 parameters, 1 required.

return 0;
}
Expand Down
Loading