Add new config option misc.hide_dnsmasq_warn for hiding warnings from the Pi-hole diagnosis system

Signed-off-by: Dominik <dl6er@dl6er.de>
This commit is contained in:
Dominik
2025-10-22 22:00:17 +02:00
parent 9f1eb7683a
commit 027ff28367
7 changed files with 31 additions and 22 deletions

View File

@@ -553,6 +553,8 @@ components:
type: boolean
normalizeCPU:
type: boolean
hide_dnsmasq_warn:
type: boolean
check:
type: object
properties:
@@ -837,6 +839,7 @@ components:
extraLogging: false
readOnly: false
normalizeCPU: false
hide_dnsmasq_warn: false
check:
load: true
shmem: 90

View File

@@ -907,29 +907,15 @@ int api_info_version(struct ftl_conn *api)
int api_info_messages_count(struct ftl_conn *api)
{
// Filtering based on GET parameters?
bool filter_dnsmasq_warnings = false;
if(api->request->query_string != NULL)
{
get_bool_var(api->request->query_string, "filter_dnsmasq_warnings", &filter_dnsmasq_warnings);
}
// Send reply
cJSON *json = JSON_NEW_OBJECT();
cJSON_AddNumberToObject(json, "count", count_messages(filter_dnsmasq_warnings));
cJSON_AddNumberToObject(json, "count", count_messages());
JSON_SEND_OBJECT(json);
return 0;
}
static int api_info_messages_GET(struct ftl_conn *api)
{
// Filtering based on GET parameters?
bool filter_dnsmasq_warnings = false;
if(api->request->query_string != NULL)
{
get_bool_var(api->request->query_string, "filter_dnsmasq_warnings", &filter_dnsmasq_warnings);
}
// Create messages array
cJSON *messages = cJSON_CreateArray();
if(!format_messages(messages))
@@ -943,7 +929,7 @@ static int api_info_messages_GET(struct ftl_conn *api)
}
// Filter messages if requested
if(filter_dnsmasq_warnings)
if(config.misc.hide_dnsmasq_warn.v.b)
{
// Create new array
cJSON *filtered = cJSON_CreateArray();

View File

@@ -1422,6 +1422,12 @@ void initConfig(struct config *conf)
conf->misc.normalizeCPU.d.b = true;
conf->misc.normalizeCPU.c = validate_stub; // Only type-based checking
conf->misc.hide_dnsmasq_warn.k = "misc.hide_dnsmasq_warn";
conf->misc.hide_dnsmasq_warn.h = "Should FTL hide warnings coming from dnsmasq?\n\n By default, FTL reports warnings coming from the embedded dnsmasq DNS server to the FTL log file. These warnings can be useful to identify misconfigurations or problems with the DNS server. However, some warnings may be harmless and can be ignored in certain setups. Enabling this setting will hide dnsmasq warnings.";
conf->misc.hide_dnsmasq_warn.t = CONF_BOOL;
conf->misc.hide_dnsmasq_warn.d.b = false;
conf->misc.hide_dnsmasq_warn.c = validate_stub; // Only type-based checking
// sub-struct misc.check
conf->misc.check.load.k = "misc.check.load";
conf->misc.check.load.h = "Pi-hole is very lightweight on resources. Nevertheless, this does not mean that you should run Pi-hole on a server that is otherwise extremely busy as queuing on the system can lead to unnecessary delays in DNS operation as the system becomes less and less usable as the system load increases because all resources are permanently in use. To account for this, FTL regularly checks the system load. To bring this to your attention, FTL warns about excessive load when the 15 minute system load average exceeds the number of cores.\n\n This check can be disabled with this setting.";

View File

@@ -317,6 +317,7 @@ struct config {
struct conf_item extraLogging;
struct conf_item readOnly;
struct conf_item normalizeCPU;
struct conf_item hide_dnsmasq_warn;
struct {
struct conf_item load;
struct conf_item shmem;

View File

@@ -1013,7 +1013,7 @@ static void format_gravity_restored_message(char *plain, const int sizeof_plain,
}
}
int count_messages(const bool filter_dnsmasq_warnings)
int count_messages(void)
{
int count = 0;
@@ -1030,7 +1030,9 @@ int count_messages(const bool filter_dnsmasq_warnings)
// Get message
sqlite3_stmt* stmt = NULL;
const char *querystr = filter_dnsmasq_warnings ? "SELECT COUNT(*) FROM message WHERE type != 'DNSMASQ_WARN'" : "SELECT COUNT(*) FROM message";
const char *querystr = config.misc.hide_dnsmasq_warn.v.b ?
"SELECT COUNT(*) FROM message WHERE type != 'DNSMASQ_WARN'" :
"SELECT COUNT(*) FROM message";
int rc = sqlite3_prepare_v2(db, querystr, -1, &stmt, NULL);
if( rc != SQLITE_OK ){
log_err("count_messages() - SQL error prepare SELECT: %s",

View File

@@ -13,7 +13,7 @@
#include "sqlite3.h"
#include "webserver/cJSON/cJSON.h"
int count_messages(const bool filter_dnsmasq_warnings);
int count_messages(void);
bool format_messages(cJSON *array);
bool create_message_table(sqlite3 *db);
bool delete_message(cJSON *ids, int *deleted);

View File

@@ -1,7 +1,7 @@
# Pi-hole configuration file (v6.2.3-301-gfcee3894-dirty) on branch tweak/api_info_system_ftl
# Pi-hole configuration file (v6.2.3-312-g9f1eb768-dirty) on branch (no branch, rebasing misc_dnsmasq_warn)
# Encoding: UTF-8
# This file is managed by pihole-FTL
# Last updated on 2025-10-06 08:00:17 UTC
# Last updated on 2025-10-23 17:03:51 UTC
[dns]
# Upstream DNS Servers to be used by Pi-hole. If this is not set, Pi-hole will not
@@ -1413,6 +1413,17 @@
# true or false
normalizeCPU = true
# Should FTL hide warnings coming from dnsmasq?
#
# By default, FTL reports warnings coming from the embedded dnsmasq DNS server to the
# FTL log file. These warnings can be useful to identify misconfigurations or problems
# with the DNS server. However, some warnings may be harmless and can be ignored in
# certain setups. Enabling this setting will hide dnsmasq warnings.
#
# Allowed values are:
# true or false
hide_dnsmasq_warn = false
[misc.check]
# Pi-hole is very lightweight on resources. Nevertheless, this does not mean that you
# should run Pi-hole on a server that is otherwise extremely busy as queuing on the
@@ -1662,7 +1673,7 @@
all = true ### CHANGED, default = false
# Configuration statistics:
# 160 total entries out of which 107 entries are default
# 161 total entries out of which 108 entries are default
# --> 53 entries are modified
# 3 entries are forced through environment:
# - misc.nice