Skip to content

Commit 874e458

Browse files
authored
A couple more maintenance:rrd-step fixes (librenms#18670)
1 parent 8a199e4 commit 874e458

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();
@@ -30,9 +26,9 @@ public function handle(RrdProcess $rrdProcess): int
3026
{
3127
$this->configureOutputOptions();
3228

33-
$this->systemStep = (int) LibrenmsConfig::get('rrd.step', 300);
34-
$this->icmpStep = (int) LibrenmsConfig::get('ping_rrd_step', $this->systemStep);
35-
$this->systemHeartbeat = (int) LibrenmsConfig::get('rrd.heartbeat', $this->systemStep * 2);
29+
$systemStep = (int) LibrenmsConfig::get('rrd.step', 300);
30+
$icmpStep = (int) LibrenmsConfig::get('ping_rrd_step', $systemStep);
31+
$systemHeartbeat = (int) LibrenmsConfig::get('rrd.heartbeat', $systemStep * 2);
3632

3733
$hostname = (string) $this->argument('device');
3834
if ($hostname !== 'all') {
@@ -55,8 +51,8 @@ public function handle(RrdProcess $rrdProcess): int
5551
$rrdFile = basename($file, '.rrd');
5652

5753
[$step, $heartbeat] = $rrdFile === 'icmp-perf'
58-
? [$this->icmpStep, $this->icmpStep * 2]
59-
: [$this->systemStep, $this->systemHeartbeat];
54+
? [$icmpStep, $icmpStep * 2]
55+
: [$systemStep, $systemHeartbeat];
6056

6157
try {
6258
$this->checkRrdFile($rrdProcess, $file, $step, $heartbeat);
@@ -135,7 +131,9 @@ private function modifyXml(string $xmlContent, int $step, int $heartbeat): strin
135131
*/
136132
private function listFiles(string $hostname, RrdProcess $rrdProcess): array
137133
{
138-
$command = $hostname === 'all' ? ['list -r .', ''] : "list ./$hostname";
134+
$rrd_dir = LibrenmsConfig::get('rrd_dir', LibrenmsConfig::get('install_dir') . '/rrd');
135+
136+
$command = $hostname === 'all' ? "list -r $rrd_dir" : "list $rrd_dir/$hostname";
139137
$output = rtrim($rrdProcess->run($command));
140138

141139
if (empty($output)) {

0 commit comments

Comments
 (0)