Add "Delay" column to Query Log (#2757)

This commit is contained in:
DL6ER
2023-10-26 16:59:41 +02:00
committed by GitHub
3 changed files with 30 additions and 20 deletions

View File

@@ -165,6 +165,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
<th>Type</th>
<th>Domain</th>
<th>Client</th>
<th><i class="fas fa-stopwatch" title="Query reply time"></i></th>
<th></th>
</tr>
</thead>
@@ -175,6 +176,7 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
<th>Type</th>
<th>Domain</th>
<th>Client</th>
<th><i class="fas fa-stopwatch" title="Query reply time"></i></th>
<th></th>
</tr>
</tfoot>

View File

@@ -208,6 +208,23 @@ function parseQueryStatus(data) {
};
}
function formatReplyTime(replyTime, type) {
if (type === "display") {
// Units:
// - seconds if replytime >= 1 second
// - milliseconds if reply time >= 100 µs
// - microseconds otherwise
return replyTime < 1e-4
? (1e6 * replyTime).toFixed(1) + " µs"
: replyTime < 1
? (1e3 * replyTime).toFixed(1) + " ms"
: replyTime.toFixed(1) + " s";
}
// else: return the number itself (for sorting and searching)
return replyTime;
}
function formatInfo(data) {
// DNSSEC status
var dnssecStatus = data.dnssec,
@@ -303,20 +320,10 @@ function formatInfo(data) {
// Always show reply info, add reply delay if applicable
var replyInfo = "";
if (data.reply.type !== "UNKNOWN") {
replyInfo = divStart + "Reply:&nbsp&nbsp;" + data.reply.type;
if (data.reply.time >= 0 && data.reply.type !== "UNKNOWN") {
replyInfo +=
" (" +
(data.reply.time < 1
? (1e3 * data.reply.time).toFixed(1) + " ms)"
: data.reply.time.toFixed(1) + " s)");
}
replyInfo += "</div>";
} else {
replyInfo = divStart + "Reply:&nbsp;&nbsp;No reply received</div>";
}
replyInfo =
data.reply.type !== "UNKNOWN"
? divStart + "Reply:&nbsp&nbsp;" + data.reply.type + "</div>"
: divStart + "Reply:&nbsp;&nbsp;No reply received</div>";
// Compile extra info for displaying
return (
@@ -515,9 +522,10 @@ $(function () {
},
},
{ data: "status", width: "1%" },
{ data: "type", width: "5%" },
{ data: "type", width: "1%" },
{ data: "domain", width: "45%" },
{ data: "client.ip", width: "29%", type: "ip-address", render: $.fn.dataTable.render.text() },
{ data: "client.ip", width: "29%", type: "ip-address" },
{ data: "reply.time", width: "4%", render: formatReplyTime },
{ data: null, width: "10%", sortable: false, searchable: false },
],
lengthMenu: [
@@ -569,7 +577,7 @@ $(function () {
}
if (querystatus.buttontext !== false) {
$("td:eq(5)", row).html(querystatus.buttontext);
$("td:eq(6)", row).html(querystatus.buttontext);
}
},
});

View File

@@ -80,13 +80,13 @@ td.lookatme {
/* Optimize Queries-Table for small screens */
/* Time column */
#all-queries td:nth-of-type(1),
/* Status column */
#all-queries td:nth-of-type(5) {
/* Reply time column */
#all-queries td:nth-of-type(6) {
white-space: nowrap;
}
/* Domain column */
#all-queries td:nth-of-type(3) {
#all-queries td:nth-of-type(4) {
min-width: 200px;
word-break: break-all;
white-space: pre-wrap;