mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 19:15:22 +00:00
system: add load average back to system info widget
The API call is not fitting too well, but since it fetches a sysctl this is the right spot to do it.
This commit is contained in:
parent
52ccee13f5
commit
cbd97eaccb
@ -131,15 +131,22 @@ class SystemController extends ApiControllerBase
|
||||
public function systemTimeAction()
|
||||
{
|
||||
$config = Config::getInstance()->object();
|
||||
$boottime = json_decode((new Backend())->configdRun('system sysctl values kern.boottime'), true);
|
||||
$boottime = json_decode((new Backend())->configdRun('system sysctl values kern.boottime,vm.loadavg'), true);
|
||||
preg_match("/sec = (\d+)/", $boottime['kern.boottime'], $matches);
|
||||
|
||||
$last_change = date("D M j G:i:s T Y", !empty($config->revision->time) ? intval($config->revision->time) : 0);
|
||||
$loadavg = explode(' ', $boottime['vm.loadavg']);
|
||||
if (count($loadavg) == 5 && $loadavg[0] == '{' && $loadavg[4] == '}') {
|
||||
$loadavg = join(', ', [$loadavg[1], $loadavg[2], $loadavg[3]]);
|
||||
} else {
|
||||
$loadavg = gettext('N/A');
|
||||
}
|
||||
|
||||
$response = [
|
||||
'uptime' => $this->formatUptime(time() - $matches[1]),
|
||||
'datetime' => date("D M j G:i:s T Y"),
|
||||
'config' => $last_change,
|
||||
'loadavg' => $loadavg,
|
||||
];
|
||||
|
||||
return $response;
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
<versions>Versions</versions>
|
||||
<updates>Updates</updates>
|
||||
<datetime>Current date/time</datetime>
|
||||
<loadavg>Load average</loadavg>
|
||||
<uptime>Uptime</uptime>
|
||||
<config>Last configuration change</config>
|
||||
</translations>
|
||||
|
||||
@ -42,8 +42,9 @@ export default class SystemInformation extends BaseTableWidget {
|
||||
|
||||
async onWidgetTick() {
|
||||
const data = await this.ajaxCall('/api/diagnostics/system/systemTime');
|
||||
$('#datetime').text(data['datetime']);
|
||||
$('#uptime').text(data['uptime']);
|
||||
$('#loadavg').text(data['loadavg']);
|
||||
$('#datetime').text(data['datetime']);
|
||||
$('#config').text(data['config']);
|
||||
}
|
||||
|
||||
@ -64,6 +65,7 @@ export default class SystemInformation extends BaseTableWidget {
|
||||
}
|
||||
|
||||
rows.push([[this.translations['uptime']], $('<span id="uptime">').prop('outerHTML')]);
|
||||
rows.push([[this.translations['loadavg']], $('<span id="loadavg">').prop('outerHTML')]);
|
||||
rows.push([[this.translations['datetime']], $('<span id="datetime">').prop('outerHTML')]);
|
||||
rows.push([[this.translations['config']], $('<span id="config">').prop('outerHTML')]);
|
||||
super.updateTable('sysinfo-table', rows);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user