mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Misc device column cleanups (#15518)
* Misc device column cleanups Update last_ping on poll * Revert inserted change for now
This commit is contained in:
@@ -28,6 +28,7 @@ namespace LibreNMS\Polling;
|
||||
use App\Models\Device;
|
||||
use App\Models\DeviceOutage;
|
||||
use App\Models\Eventlog;
|
||||
use Carbon\Carbon;
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Data\Source\Fping;
|
||||
use LibreNMS\Data\Source\FpingResponse;
|
||||
@@ -207,6 +208,7 @@ class ConnectivityHelper
|
||||
$perf->debug = array_merge($perf->debug, $this->traceroute());
|
||||
}
|
||||
$this->device->perf()->save($perf);
|
||||
$this->device->last_ping = Carbon::now();
|
||||
$this->device->last_ping_timetaken = $ping_response->avg_latency ?: $this->device->last_ping_timetaken;
|
||||
$this->device->save();
|
||||
|
||||
|
@@ -83,7 +83,9 @@ class Device extends BaseModel
|
||||
|
||||
protected $casts = [
|
||||
'inserted' => 'datetime',
|
||||
'last_discovered' => 'datetime',
|
||||
'last_polled' => 'datetime',
|
||||
'last_ping' => 'datetime',
|
||||
'status' => 'boolean',
|
||||
];
|
||||
|
||||
@@ -297,9 +299,9 @@ class Device extends BaseModel
|
||||
return Permissions::canAccessDevice($this->device_id, $user->user_id);
|
||||
}
|
||||
|
||||
public function formatDownUptime($short = false)
|
||||
public function formatDownUptime($short = false): string
|
||||
{
|
||||
$time = ($this->status == 1) ? $this->uptime : time() - strtotime($this->last_polled);
|
||||
$time = ($this->status == 1) ? $this->uptime : $this->last_polled->diffInSeconds();
|
||||
|
||||
return Time::formatInterval($time, $short);
|
||||
}
|
||||
|
Reference in New Issue
Block a user