Fix smokeping slave not found causing error (#11799)

This commit is contained in:
Tony Murray
2020-06-09 11:10:07 -05:00
committed by GitHub
parent 4611b19ae5
commit 8ca0309ebf
+20 -14
View File
@@ -86,21 +86,27 @@ class Smokeping
public function otherGraphs($direction)
{
$remote = $direction == 'in' ? 'src' : 'dest';
$data = array_keys(array_filter($this->getFiles()[$direction][$this->device->hostname], function ($file) {
return Str::contains($file, '~');
}));
$data = [];
foreach ($this->getFiles()[$direction][$this->device->hostname] as $remote_host => $file) {
if (Str::contains($file, '~')) {
$device = \DeviceCache::getByHostname($remote_host);
if (empty($device->device_id)) {
\Log::debug('Could not find smokeping slave device in LibreNMS', ['slave' => $remote_host]);
continue;
}
return array_map(function ($other) use ($direction, $remote) {
$device = \DeviceCache::getByHostname($other);
return [
'device' => $device,
'graph' => [
'type' => 'smokeping_' . $direction,
'device' => $this->device->device_id,
$remote => $device->device_id,
]
];
}, $data);
$data[] = [
'device' => $device,
'graph' => [
'type' => 'smokeping_' . $direction,
'device' => $this->device->device_id,
$remote => $device->device_id,
]
];
}
}
return $data;
}
public function hasGraphs()