Pass loadavg as array from Perfstats

There's no reason we should format the data into a string in the
Perfstats module. Let the recipient do what they want with it instead.

As an example, we reduce the precision of the loadavg stats in the
system status widget. 3 digits precision should be more than enough for
this type of status display.

Project......: Performance Profiling
Sponsored-by.: NLnet NGI0 Commons Fund
This commit is contained in:
Harald Eilertsen
2026-03-01 11:34:28 +01:00
parent 91944da69e
commit 52a2a0d89a
2 changed files with 6 additions and 2 deletions

View File

@@ -54,7 +54,7 @@ class Perfstats extends Controller
$stats = [];
if (function_exists('sys_getloadavg')) {
$stats['loadavg'] = implode(' / ', sys_getloadavg());
$stats['loadavg'] = sys_getloadavg();
}
$stats['dbqueries'] = $this->getNumQueries();

View File

@@ -31,7 +31,11 @@
for (const item in json) {
element = document.getElementById(`perfstat-${item}-value`);
if (element) {
if (item === "dbqueries") {
if (item === "loadavg") {
element.innerText = json['loadavg']
.map((v) => v.toPrecision(3))
.join(" / ");
} else if (item === "dbqueries") {
console.log(`dbqueries = ${json['dbqueries']}, ts = ${json['ts']}`);
if (status_update_ts !== 0) {
let dt = json['ts'] - status_update_ts;