diff --git a/api_FTL.php b/api_FTL.php index 23d9f8cd..571fe74b 100644 --- a/api_FTL.php +++ b/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'])) diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index 6660c63a..7e85f310 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -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 diff --git a/settings.php b/settings.php index e27de2d5..1b0b00da 100644 --- a/settings.php +++ b/settings.php @@ -1254,8 +1254,27 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array("sysadmin", "blocklists" + + + DNS cache size: + +   + + + + DNS cache insertions: + +   + + + + DNS cache evictions: + +   + + See also our DNS cache documentation.
The FTL service is offline!