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
This commit is contained in:
Tony Murray
2023-10-14 15:29:13 -05:00
committed by GitHub
parent 78a4bfb9d9
commit fcfaded91f
2 changed files with 3 additions and 5 deletions
+2 -4
View File
@@ -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);
}
+1 -1
View File
@@ -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");