From c2dbefecc22134047c62b678a49c33a7c984d132 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 16 Aug 2018 14:29:49 +0200 Subject: [PATCH 1/4] Add new api.php?getCacheInfo callback Signed-off-by: DL6ER --- api_FTL.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api_FTL.php b/api_FTL.php index 19a94f82..c6d149b8 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(); + $querytypes = array(); + foreach($return as $ret) + { + $tmp = explode(": ",$ret); + $querytypes[$tmp[0]] = floatval($tmp[1]); + } + + $result = array('cacheinfo' => $querytypes); + $data = array_merge($data, $result); + } + if (isset($_GET['getAllQueries']) && $auth) { if(isset($_GET['from']) && isset($_GET['until'])) From 77efbac43d3dae049a9e9c18e692e116e0822505 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 21 Aug 2018 15:42:15 +0200 Subject: [PATCH 2/4] Show cache info on Settings page Signed-off-by: DL6ER --- scripts/pi-hole/js/settings.js | 31 +++++++++++++++++++++++++++++++ settings.php | 19 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index 6660c63a..fa5608d5 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 8ff665f1..00c954b7 100644 --- a/settings.php +++ b/settings.php @@ -1221,8 +1221,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!
From a692bdea277d89978f9544c42f9f562e7d61aa04 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 21 Aug 2018 18:39:50 +0200 Subject: [PATCH 3/4] Add missing semicolon Signed-off-by: DL6ER --- scripts/pi-hole/js/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/settings.js b/scripts/pi-hole/js/settings.js index fa5608d5..7e85f310 100644 --- a/scripts/pi-hole/js/settings.js +++ b/scripts/pi-hole/js/settings.js @@ -161,7 +161,7 @@ function loadCacheInfo() } else { - $("#cache-live-freed").parent("tr").removeClass("lookatme") + $("#cache-live-freed").parent("tr").removeClass("lookatme"); } // Update cache info every 10 seconds From 053d28980fd107d189a7893a97c5fa0a2ecefa6e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 25 Aug 2018 14:14:00 +0200 Subject: [PATCH 4/4] Use new variable name for new array in api_FTL.php Signed-off-by: DL6ER --- api_FTL.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api_FTL.php b/api_FTL.php index c6d149b8..7147a979 100644 --- a/api_FTL.php +++ b/api_FTL.php @@ -249,14 +249,14 @@ else { sendRequestFTL("cacheinfo"); $return = getResponseFTL(); - $querytypes = array(); + $cacheinfo = array(); foreach($return as $ret) { $tmp = explode(": ",$ret); - $querytypes[$tmp[0]] = floatval($tmp[1]); + $cacheinfo[$tmp[0]] = floatval($tmp[1]); } - $result = array('cacheinfo' => $querytypes); + $result = array('cacheinfo' => $cacheinfo); $data = array_merge($data, $result); }