Display latency in milliseconds instead of seconds

This commit is contained in:
TimZ99 2020-05-18 18:53:22 +02:00
parent c314511e2e
commit 8614e7453c
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
2 changed files with 11 additions and 10 deletions

View File

@ -74,7 +74,7 @@ class HistoryGraph
1 => $this->generateGraphHistory($server_id, $last_year, $last_week), 1 => $this->generateGraphHistory($server_id, $last_year, $last_week),
); );
$info_fields = array( $info_fields = array(
'latency_avg' => '%01.4f', 'latency_avg' => '%01.5f',
'uptime' => '%01.3f%%', 'uptime' => '%01.3f%%',
); );
@ -280,11 +280,11 @@ class HistoryGraph
if ($record['status'] == 0) { if ($record['status'] == 0) {
$lines['online'][] = $prev['status'] $lines['online'][] = $prev['status']
// Previous datapoint was online // Previous datapoint was online
? '{ x: ' . ($time * 1000) . ', y: ' . $prev['latency'] . '}' ? '{ x: ' . ($time * 1000) . ', y: ' . $prev['latency'] * 1000 . '}'
// Previous datapoint was offline // Previous datapoint was offline
: '{ x: ' . ($time * 1000) . ', y: null}'; : '{ x: ' . ($time * 1000) . ', y: null}';
// new outage start // new outage start
$lines['offline'][] = '{ x: ' . ($time * 1000) . ', y:0.1}'; $lines['offline'][] = '{ x: ' . ($time * 1000) . ', y:' . $highest_latency . '}';
$prev_downtime != 0 ?: $prev_downtime = $time; $prev_downtime != 0 ?: $prev_downtime = $time;
} else { } else {
@ -294,15 +294,15 @@ class HistoryGraph
// Previous datapoint was online // Previous datapoint was online
? '{ x: ' . ($time * 1000) . ', y:null}' ? '{ x: ' . ($time * 1000) . ', y:null}'
// Previous datapoint was offline // Previous datapoint was offline
: '{ x: ' . ($time * 1000) . ', y:0.1}'; : '{ x: ' . ($time * 1000) . ', y:' . $highest_latency . '}';
$lines['online'][] = '{ x: ' . ($time * 1000) . ', y: ' . $lines['online'][] = '{ x: ' . ($time * 1000) . ', y: ' .
round((float) $record[$key], 4) . '}'; round((float) $record[$key] * 1000, 2) . '}';
$prev_downtime == 0 ?: $downtime += ($time - $prev_downtime); $prev_downtime == 0 ?: $downtime += ($time - $prev_downtime);
$prev_downtime = 0; $prev_downtime = 0;
} }
} else { } else {
$lines[$key][] = '{ x: \'' . $record['date'] . '\', y: ' . $record[$key] . '}'; $lines[$key][] = '{ x: \'' . $record['date'] . '\', y: ' . $record[$key] * 1000 . '}';
} }
$prev = $record; $prev = $record;
} }
@ -312,7 +312,8 @@ class HistoryGraph
// Record the first and last date as a string in the down array // Record the first and last date as a string in the down array
$prev_downtime == 0 ?: $downtime += ($now->getTimestamp() - $prev_downtime); $prev_downtime == 0 ?: $downtime += ($now->getTimestamp() - $prev_downtime);
if ($add_uptime) { if ($add_uptime) {
$prev['status'] ?: $lines['offline'][] = '{ x: ' . ($now->getTimestamp() * 1000) . ', y:0.1}'; $prev['status'] ?: $lines['offline'][] =
'{ x: ' . ($now->getTimestamp() * 1000) . ', y:' . $highest_latency . '}';
$data['uptime'] = 100 - ($downtime / ($end_time->getTimestamp() - $start_time->getTimestamp())); $data['uptime'] = 100 - ($downtime / ($end_time->getTimestamp() - $start_time->getTimestamp()));
} }

View File

@ -20,7 +20,7 @@
<span id="needle" style="transform: rotate({{ ((graph.uptime|round/100)*180)|round }}deg);"></span> <span id="needle" style="transform: rotate({{ ((graph.uptime|round/100)*180)|round }}deg);"></span>
</div><br> </div><br>
{% endif %} {% endif %}
{{ graph.info.0.label }}: {{ graph.info.0.value }}s {{ graph.info.0.label }}: {{ graph.info.0.value * 1000 }} ms
</div> </div>
{% if graph.id == 'history_short' %} {% if graph.id == 'history_short' %}
@ -30,7 +30,7 @@
data: { data: {
datasets: [ datasets: [
{ {
data: [{{ graph.lines.offline.value * 1000 }}], data: [{{ graph.lines.offline.value }}],
label: '{{ graph.lines.offline.name }}', label: '{{ graph.lines.offline.name }}',
backgroundColor: '#dc3545', backgroundColor: '#dc3545',
borderColor: '#dc3545', borderColor: '#dc3545',
@ -41,7 +41,7 @@
spanGaps: false, spanGaps: false,
}, },
{ {
data: [{{ graph.lines.online.value * 1000 }}], data: [{{ graph.lines.online.value }}],
label: '{{graph.lines.online.name }}', label: '{{graph.lines.online.name }}',
fill: false, fill: false,
spanGaps: false, spanGaps: false,