From fcfaded91f3ca7c4534656fcf50aad26d1362d48 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sat, 14 Oct 2023 13:29:13 -0700 Subject: [PATCH] Always create rrd folder on localhost (#15457) for some reason rrdcached cannot create folders when it is running on localhost Always create directories on the local poller in case rrdcached is running on the same machine A few small changes to checkRrdExists() too --- LibreNMS/Data/Store/Rrd.php | 6 ++---- LibreNMS/Poller.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/LibreNMS/Data/Store/Rrd.php b/LibreNMS/Data/Store/Rrd.php index 1b80d3f9c3..43bfb479cf 100644 --- a/LibreNMS/Data/Store/Rrd.php +++ b/LibreNMS/Data/Store/Rrd.php @@ -26,7 +26,6 @@ namespace LibreNMS\Data\Store; use App\Polling\Measure\Measurement; -use Illuminate\Support\Str; use LibreNMS\Config; use LibreNMS\Exceptions\FileExistsException; use LibreNMS\Exceptions\RrdGraphException; @@ -524,10 +523,9 @@ class Rrd extends BaseDatastore public function checkRrdExists($filename) { if ($this->rrdcached && version_compare($this->version, '1.5', '>=')) { - $chk = $this->command('last', $filename, ''); - $filename = str_replace([$this->rrd_dir . '/', $this->rrd_dir], '', $filename); + $check_output = implode($this->command('last', $filename, '')); - return ! Str::contains(implode($chk), "$filename': No such file or directory"); + return ! (str_contains($check_output, $filename) && str_contains($check_output, 'No such file or directory')); } else { return is_file($filename); } diff --git a/LibreNMS/Poller.php b/LibreNMS/Poller.php index d20196f9c5..8f433a71fd 100644 --- a/LibreNMS/Poller.php +++ b/LibreNMS/Poller.php @@ -278,7 +278,7 @@ class Poller private function initRrdDirectory(): void { $host_rrd = \Rrd::name($this->device->hostname, '', ''); - if (Config::get('rrd.enable', true) && ! Config::get('rrdcached') && ! is_dir($host_rrd)) { + if (Config::get('rrd.enable', true) && ! is_dir($host_rrd)) { try { mkdir($host_rrd); $this->logger->info("Created directory : $host_rrd");