mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix latency tab bugs (#11787)
when there is no latency data fix smokeping error
This commit is contained in:
@@ -48,11 +48,11 @@ class Smokeping
|
||||
{
|
||||
if (is_null($this->files) && Config::has('smokeping.dir')) {
|
||||
$dir = $this->generateFileName();
|
||||
if (is_dir($dir)) {
|
||||
if (is_dir($dir) && is_readable($dir)) {
|
||||
foreach (array_diff(scandir($dir), ['.', '..']) as $file) {
|
||||
if (stripos($file, '.rrd') !== false) {
|
||||
if (strpos($file, '~') !== false) {
|
||||
list($target, $slave) = explode('~', $this->filenameToHostname($file));
|
||||
[$target, $slave] = explode('~', $this->filenameToHostname($file));
|
||||
$this->files['in'][$target][$slave] = $file;
|
||||
$this->files['out'][$slave][$target] = $file;
|
||||
} else {
|
||||
|
||||
@@ -37,7 +37,8 @@ class LatencyController implements DeviceTab
|
||||
{
|
||||
public function visible(Device $device): bool
|
||||
{
|
||||
return true;
|
||||
return Config::get('smokeping.integration') || DB::table('device_perf')
|
||||
->where('device_id', $device->device_id)->exists();
|
||||
}
|
||||
|
||||
public function slug(): string
|
||||
@@ -61,7 +62,11 @@ class LatencyController implements DeviceTab
|
||||
$to = Request::get('dtpickerto', Carbon::now()->format(Config::get('dateformat.byminute')));
|
||||
|
||||
$perf = $this->fetchPerfData($device, $from, $to);
|
||||
$duration = abs(strtotime($perf->first()->date) - strtotime($perf->last()->date)) * 1000;
|
||||
|
||||
$duration = $perf && $perf->isNotEmpty()
|
||||
? abs(strtotime($perf->first()->date) - strtotime($perf->last()->date)) * 1000
|
||||
: 0;
|
||||
|
||||
|
||||
$smokeping = new Smokeping($device);
|
||||
$smokeping_tabs = [];
|
||||
|
||||
Reference in New Issue
Block a user