mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 23:54:44 +02:00
Add default in
This commit is contained in:
parent
d409ff037c
commit
9fc46b9ae5
@ -311,21 +311,28 @@ class Node extends Model
|
|||||||
|
|
||||||
public function statistics()
|
public function statistics()
|
||||||
{
|
{
|
||||||
return Http::daemon($this)->connectTimeout(1)->timeout(1)->get('/api/system/utilization')->json() ?? [];
|
$default = [
|
||||||
|
'memory_total' => 0,
|
||||||
/** Example
|
'memory_used' => 0,
|
||||||
$stats = [
|
'swap_total' => 0,
|
||||||
'memory_total' => 8221675520,
|
|
||||||
'memory_used' => 1670275072,
|
|
||||||
'swap_total' => 1073737728,
|
|
||||||
'swap_used' => 0,
|
'swap_used' => 0,
|
||||||
'load_average1' => 0.67,
|
'load_average1' => 0.00,
|
||||||
'load_average5' => 0.64,
|
'load_average5' => 0.00,
|
||||||
'load_average15' => 0.7,
|
'load_average15' => 0.00,
|
||||||
'cpu_percent' => 0.84361590728896,
|
'cpu_percent' => 0.00,
|
||||||
'disk_total' => 62671097856,
|
'disk_total' => 0,
|
||||||
'disk_used' => 33444728832,
|
'disk_used' => 0,
|
||||||
]; // */
|
];
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Http::daemon($this)
|
||||||
|
->connectTimeout(1)
|
||||||
|
->timeout(1)
|
||||||
|
->get('/api/system/utilization')
|
||||||
|
->json() ?? $default;
|
||||||
|
} catch (Exception) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ipAddresses(): array
|
public function ipAddresses(): array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user