mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 12:48:29 +00:00
Merge pull request #830 from pi-hole/new/cacheinfo
Add DNS cache information to Settings page
This commit is contained in:
15
api_FTL.php
15
api_FTL.php
@@ -245,6 +245,21 @@ else
|
||||
$data = array_merge($data, $result);
|
||||
}
|
||||
|
||||
if (isset($_GET['getCacheInfo']) && $auth)
|
||||
{
|
||||
sendRequestFTL("cacheinfo");
|
||||
$return = getResponseFTL();
|
||||
$cacheinfo = array();
|
||||
foreach($return as $ret)
|
||||
{
|
||||
$tmp = explode(": ",$ret);
|
||||
$cacheinfo[$tmp[0]] = floatval($tmp[1]);
|
||||
}
|
||||
|
||||
$result = array('cacheinfo' => $cacheinfo);
|
||||
$data = array_merge($data, $result);
|
||||
}
|
||||
|
||||
if (isset($_GET['getAllQueries']) && $auth)
|
||||
{
|
||||
if(isset($_GET['from']) && isset($_GET['until']))
|
||||
|
||||
@@ -140,6 +140,35 @@ $("#DHCPchk").click(function() {
|
||||
$("#dhcpnotice").prop("hidden", !this.checked).addClass("lookatme");
|
||||
});
|
||||
|
||||
function loadCacheInfo()
|
||||
{
|
||||
$.getJSON("api.php?getCacheInfo", function(data) {
|
||||
if("FTLnotrunning" in data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Fill table with obtained values
|
||||
$("#cache-size").text(parseInt(data["cacheinfo"]["cache-size"]));
|
||||
$("#cache-inserted").text(parseInt(data["cacheinfo"]["cache-inserted"]));
|
||||
|
||||
// Highlight early cache removals when present
|
||||
var cachelivefreed = parseInt(data["cacheinfo"]["cache-live-freed"]);
|
||||
$("#cache-live-freed").text(cachelivefreed);
|
||||
if(cachelivefreed > 0)
|
||||
{
|
||||
$("#cache-live-freed").parent("tr").addClass("lookatme");
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#cache-live-freed").parent("tr").removeClass("lookatme");
|
||||
}
|
||||
|
||||
// Update cache info every 10 seconds
|
||||
setTimeout(loadCacheInfo, 10000);
|
||||
});
|
||||
}
|
||||
|
||||
var leasetable, staticleasetable;
|
||||
$(document).ready(function() {
|
||||
if(document.getElementById("DHCPLeasesTable"))
|
||||
@@ -170,6 +199,8 @@ $(document).ready(function() {
|
||||
staticleasetable.draw();
|
||||
});
|
||||
|
||||
loadCacheInfo();
|
||||
|
||||
} );
|
||||
|
||||
// Handle hiding of alerts
|
||||
|
||||
19
settings.php
19
settings.php
@@ -1254,8 +1254,27 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists"
|
||||
</th>
|
||||
<td><?php echo formatSizeUnits(1e3 * floatval(get_FTL_data("rss"))); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<span title="Size of the DNS domain cache">DNS cache size:</span>
|
||||
</th>
|
||||
<td id="cache-size"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<span title="Number of cache insertions">DNS cache insertions:</span>
|
||||
</th>
|
||||
<td id="cache-inserted"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<span title="Number of cache entries that had to be removed although they are not expired (increase cache size to reduce this number)">DNS cache evictions:</span>
|
||||
</th>
|
||||
<td id="cache-live-freed"> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
See also our <a href="https://docs.pi-hole.net/ftldns/dns-cache/" target="_blank">DNS cache documentation</a>.
|
||||
<?php } else { ?>
|
||||
<div>The FTL service is offline!</div>
|
||||
<?php } ?>
|
||||
|
||||
Reference in New Issue
Block a user