mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Report queries/sec in system status widget
The total number of queries is not that interesting for performance measurements, so let's do queries pr/second instead. Adds a timestamp column to the dataset, which could be useful for other purposes as well (like making a graph over time etc.) Project......: Performance Profiling Sponsored-by.: NLnet NGI0 Commons Fund
This commit is contained in:
@@ -64,6 +64,11 @@ class Perfstats extends Controller
|
||||
$stats['queueworkers'] = $qwstats->active;
|
||||
$stats['workqsz'] = $qwstats->size;
|
||||
|
||||
// Return a timestamp, so that it is possible to infer
|
||||
// changes of the stats over time. A resolution of
|
||||
// seconds should be good enough for our purposes.
|
||||
$stats['ts'] = time();
|
||||
|
||||
return $stats;
|
||||
}
|
||||
|
||||
|
||||
@@ -264,11 +264,12 @@ class Channel_activities {
|
||||
'outqueue' => 0,
|
||||
'queueworkers' => 0,
|
||||
'workqsz' => 0,
|
||||
'ts' => time(),
|
||||
],
|
||||
'tpl' => 'system_status_widget.tpl',
|
||||
'labels' => [
|
||||
'loadavg' => t('Load average'),
|
||||
'dbqueries' => t('DB queries'),
|
||||
'dbqueries' => t('DB queries/sec'),
|
||||
'outqueue' => t('Output queue'),
|
||||
'queueworkers' => t('Queue workers'),
|
||||
'workqsz' => t('Work queue size'),
|
||||
|
||||
@@ -5,31 +5,48 @@
|
||||
<div class="card-body clearfix">
|
||||
<table>
|
||||
{{foreach $items as $id => $item}}
|
||||
{{if $id != 'ts'}}
|
||||
<tr>
|
||||
<td id="perfstat-{{$id}}-label" class="perfstat-label">{{$labels.$id|escape}}:</td>
|
||||
<td id="perfstat-{{$id}}-value" class="perfstat-value">{{$item|escape}}</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
setInterval(() => {
|
||||
fetch('/perfstats', {
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
for (const item in json) {
|
||||
//console.log(`${item}: ${json[item]}`);
|
||||
element = document.getElementById(`perfstat-${item}-value`);
|
||||
if (element) {
|
||||
element.innerText = json[item];
|
||||
status_update_ts = 0;
|
||||
status_update_last_q = 0;
|
||||
|
||||
setInterval(() => {
|
||||
fetch('/perfstats', {
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
for (const item in json) {
|
||||
element = document.getElementById(`perfstat-${item}-value`);
|
||||
if (element) {
|
||||
if (item === "dbqueries") {
|
||||
console.log(`dbqueries = ${json['dbqueries']}, ts = ${json['ts']}`);
|
||||
if (status_update_ts !== 0) {
|
||||
let dt = json['ts'] - status_update_ts;
|
||||
let dq = json['dbqueries'] - status_update_last_q;
|
||||
|
||||
element.innerText = dq / dt;
|
||||
}
|
||||
|
||||
status_update_ts = json['ts'];
|
||||
status_update_last_q = json['dbqueries'];
|
||||
} else if (item !== 'ts') {
|
||||
element.innerText = json[item];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 5000);
|
||||
});
|
||||
}, 5000);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user