Merge pull request #830 from pi-hole/new/cacheinfo

Add DNS cache information to Settings page
This commit is contained in:
Mark Drobnak
2018-08-30 16:07:21 -04:00
committed by GitHub
3 changed files with 65 additions and 0 deletions

View File

@@ -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']))

View File

@@ -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

View File

@@ -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">&nbsp;</td>
</tr>
<tr>
<th scope="row">
<span title="Number of cache insertions">DNS cache insertions:</span>
</th>
<td id="cache-inserted">&nbsp;</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">&nbsp;</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 } ?>