forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGraphDetail.php
More file actions
34 lines (27 loc) · 1.16 KB
/
Copy pathGraphDetail.php
File metadata and controls
34 lines (27 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace App\Console\Commands;
use App\Facades\DeviceCache;
use App\Models\Device;
use Illuminate\Console\Command;
use LibreNMS\Data\Graphing\GraphFactory;
class GraphDetail extends Command
{
protected $signature = 'graph:detail {name} {--device=}';
protected $description = 'Show info about a given graph';
public function handle(GraphFactory $graphs): int
{
$device = DeviceCache::get($this->option('device') ?: Device::limit(1)->value('device_id'));
$graph = $graphs->graphFor($this->argument('name'), [
'type' => $this->argument('name'),
'device' => $device->device_id,
]);
$this->line("Type: $graph->type");
$this->line("Subtype: $graph->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));
return 0;
}
}