Skip to content

Commit 717cfeb

Browse files
authored
Merge branch 'master' into always-configure-command-output
2 parents f2b24d0 + 874e458 commit 717cfeb

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

LibreNMS/RRD/RrdProcess.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ public function run(string $command, string $waitFor = self::COMMAND_COMPLETE):
8989
public function runAsync(string $command): void
9090
{
9191
$this->start();
92+
93+
// clean directory path when using rrdcached
94+
if ($this->rrdcached) {
95+
$command = str_replace($this->rrd_dir, '', $command);
96+
}
97+
9298
$this->logger->debug("RRD[%g$command%n]", ['color' => true]);
9399
$this->input->write("$command\n");
94100
}

app/Console/Commands/MaintenanceRrdStep.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ class MaintenanceRrdStep extends LnmsCommand
1515
{
1616
protected $name = 'maintenance:rrd-step';
1717

18-
private int $systemStep;
19-
private int $icmpStep;
20-
private int $systemHeartbeat;
21-
2218
public function __construct()
2319
{
2420
parent::__construct();
@@ -28,9 +24,9 @@ public function __construct()
2824

2925
public function handle(RrdProcess $rrdProcess): int
3026
{
31-
$this->systemStep = (int) LibrenmsConfig::get('rrd.step', 300);
32-
$this->icmpStep = (int) LibrenmsConfig::get('ping_rrd_step', $this->systemStep);
33-
$this->systemHeartbeat = (int) LibrenmsConfig::get('rrd.heartbeat', $this->systemStep * 2);
27+
$systemStep = (int) LibrenmsConfig::get('rrd.step', 300);
28+
$icmpStep = (int) LibrenmsConfig::get('ping_rrd_step', $systemStep);
29+
$systemHeartbeat = (int) LibrenmsConfig::get('rrd.heartbeat', $systemStep * 2);
3430

3531
$hostname = (string) $this->argument('device');
3632
if ($hostname !== 'all') {
@@ -53,8 +49,8 @@ public function handle(RrdProcess $rrdProcess): int
5349
$rrdFile = basename($file, '.rrd');
5450

5551
[$step, $heartbeat] = $rrdFile === 'icmp-perf'
56-
? [$this->icmpStep, $this->icmpStep * 2]
57-
: [$this->systemStep, $this->systemHeartbeat];
52+
? [$icmpStep, $icmpStep * 2]
53+
: [$systemStep, $systemHeartbeat];
5854

5955
try {
6056
$this->checkRrdFile($rrdProcess, $file, $step, $heartbeat);
@@ -133,7 +129,9 @@ private function modifyXml(string $xmlContent, int $step, int $heartbeat): strin
133129
*/
134130
private function listFiles(string $hostname, RrdProcess $rrdProcess): array
135131
{
136-
$command = $hostname === 'all' ? ['list -r .', ''] : "list ./$hostname";
132+
$rrd_dir = LibrenmsConfig::get('rrd_dir', LibrenmsConfig::get('install_dir') . '/rrd');
133+
134+
$command = $hostname === 'all' ? "list -r $rrd_dir" : "list $rrd_dir/$hostname";
137135
$output = rtrim($rrdProcess->run($command));
138136

139137
if (empty($output)) {

0 commit comments

Comments
 (0)