Skip to content

Commit 669a0dc

Browse files
authored
Fix rrdcached directory replacement (librenms#19842)
* Fix rrdcached directory replacement remove duplicate code block, which made it work for most installs * Remove rrdcached tests from RrdtoolTest, will restore them in another PR
1 parent 85d84d3 commit 669a0dc

3 files changed

Lines changed: 2 additions & 39 deletions

File tree

LibreNMS/Data/Store/Rrd.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,17 +395,6 @@ public function buildCommand(string $command, string $filename, array $options =
395395
}
396396
}
397397

398-
if ($this->rrdcached &&
399-
! ($command == 'create' && version_compare($this->version, '1.5.5', '<')) &&
400-
! ($command == 'tune' && version_compare($this->version, '1.5', '<'))
401-
) {
402-
// only relative paths if using rrdcached
403-
$filename = str_replace([$this->rrd_dir . '/', $this->rrd_dir], '', $filename);
404-
$options = str_replace([$this->rrd_dir . '/', $this->rrd_dir], '', $options);
405-
406-
return [$command, $filename, '--daemon', $this->rrdcached, ...$options];
407-
}
408-
409398
return [$command, $filename, ...$options];
410399
}
411400

LibreNMS/RRD/RrdProcess.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace LibreNMS\RRD;
44

55
use App\Facades\LibrenmsConfig;
6+
use Illuminate\Support\Str;
67
use LibreNMS\Exceptions\RrdException;
78
use LibreNMS\Exceptions\RrdNotFoundException;
89
use LibreNMS\Exceptions\RrdUpdateTooFrequentException;
@@ -26,7 +27,7 @@ public function __construct(private readonly LoggerInterface $logger, private re
2627
{
2728
$this->rrdtool_exec = LibrenmsConfig::get('rrdtool', 'rrdtool');
2829
$this->rrdcached = (string) LibrenmsConfig::get('rrdcached', '');
29-
$this->rrd_dir = LibrenmsConfig::get('rrd_dir', LibrenmsConfig::get('install_dir') . '/rrd');
30+
$this->rrd_dir = Str::finish(LibrenmsConfig::get('rrd_dir', LibrenmsConfig::get('install_dir') . '/rrd'), '/');
3031
$this->input = new InputStream();
3132

3233
if ($this->rrdcached) {

tests/RrdtoolTest.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,6 @@ public function testBuildCommandLocal(): void
5858
$this->assertEquals(['update', '/opt/librenms/rrd/f', 'options'], $cmd);
5959
}
6060

61-
public function testBuildCommandRemote(): void
62-
{
63-
LibrenmsConfig::set('rrdcached', 'server:42217');
64-
LibrenmsConfig::set('rrdtool_version', '1.4');
65-
LibrenmsConfig::set('rrd_dir', '/opt/librenms/rrd');
66-
67-
$cmd = $this->buildCommandProxy('create', '/opt/librenms/rrd/f', ['o']);
68-
$this->assertEquals(['create', '/opt/librenms/rrd/f', 'o'], $cmd);
69-
70-
$cmd = $this->buildCommandProxy('tune', '/opt/librenms/rrd/f', ['o']);
71-
$this->assertEquals(['tune', '/opt/librenms/rrd/f', 'o'], $cmd);
72-
73-
$cmd = $this->buildCommandProxy('update', '/opt/librenms/rrd/f', ['o']);
74-
$this->assertEquals(['update', 'f', '--daemon', 'server:42217', 'o'], $cmd);
75-
76-
LibrenmsConfig::set('rrdtool_version', '1.6');
77-
78-
$cmd = $this->buildCommandProxy('create', '/opt/librenms/rrd/f', ['o']);
79-
$this->assertEquals(['create', 'f', '--daemon', 'server:42217', 'o', '-O'], $cmd);
80-
81-
$cmd = $this->buildCommandProxy('tune', '/opt/librenms/rrd/f', ['o']);
82-
$this->assertEquals(['tune', 'f', '--daemon', 'server:42217', 'o'], $cmd);
83-
84-
$cmd = $this->buildCommandProxy('update', '/opt/librenms/rrd/f', ['o']);
85-
$this->assertEquals(['update', 'f', '--daemon', 'server:42217', 'o'], $cmd);
86-
}
87-
8861
public function testBuildCommandException(): void
8962
{
9063
LibrenmsConfig::set('rrdcached', '');

0 commit comments

Comments
 (0)