[Dnsmasq-discuss] [PATCH] expose the stale and unanswered metrics through CHAOS records
Karavelov, Luben
luben at amazon.com
Wed Jun 7 13:28:17 UTC 2023
Adding two new CHAOS names:
- stale.bind
- unanswered.bind
that expose the dns_stale_answered and dns_unanswered metrics.
---
src/cache.c | 8 ++++++++
src/dnsmasq.h | 2 ++
src/option.c | 2 ++
3 files changed, 12 insertions(+)
diff --git a/src/cache.c b/src/cache.c
index 1c0e250..daacbaa 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -1725,6 +1725,14 @@ int cache_make_stat(struct txt_record *t)
break;
#endif
+ case TXT_STAT_STALE:
+ sprintf(buff+1, "%u", daemon->metrics[METRIC_DNS_STALE_ANSWERED]);
+ break;
+
+ case TXT_STAT_UNANSWERED:
+ sprintf(buff+1, "%u", daemon->metrics[METRIC_DNS_UNANSWERED_QUERY]);
+ break;
+
case TXT_STAT_SERVERS:
/* sum counts from different records for same server */
for (serv = daemon->servers; serv; serv = serv->next)
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
index 2f95c12..08e6888 100644
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
@@ -380,6 +380,8 @@ struct naptr {
#define TXT_STAT_HITS 5
#define TXT_STAT_AUTH 6
#define TXT_STAT_SERVERS 7
+#define TXT_STAT_STALE 8
+#define TXT_STAT_UNANSWERED 9
#endif
struct txt_record {
diff --git a/src/option.c b/src/option.c
index 8322725..2b2705e 100644
--- a/src/option.c
+++ b/src/option.c
@@ -5947,6 +5947,8 @@ void read_opts(int argc, char **argv, char *compile_opts)
add_txt("auth.bind", NULL, TXT_STAT_AUTH);
#endif
add_txt("servers.bind", NULL, TXT_STAT_SERVERS);
+ add_txt("stale.bind", NULL, TXT_STAT_STALE);
+ add_txt("unanswered.bind", NULL, TXT_STAT_UNANSWERED);
}
#endif
--
2.25.1
More information about the Dnsmasq-discuss
mailing list