static const char *tcpinsizestats_desc[dns_sizecounter_in_max];
static const char *tcpoutsizestats_desc[dns_sizecounter_out_max];
static const char *dnstapstats_desc[dns_dnstapcounter_max];
+static const char *gluecachestats_desc[dns_gluecachestatscounter_max];
#if defined(EXTENDED_STATS)
static const char *nsstats_xmldesc[ns_statscounter_max];
static const char *resstats_xmldesc[dns_resstatscounter_max];
static const char *tcpinsizestats_xmldesc[dns_sizecounter_in_max];
static const char *tcpoutsizestats_xmldesc[dns_sizecounter_out_max];
static const char *dnstapstats_xmldesc[dns_dnstapcounter_max];
+static const char *gluecachestats_xmldesc[dns_gluecachestatscounter_max];
#else
#define nsstats_xmldesc NULL
#define resstats_xmldesc NULL
#define tcpinsizestats_xmldesc NULL
#define tcpoutsizestats_xmldesc NULL
#define dnstapstats_xmldesc NULL
+#define gluecachestats_xmldesc NULL
#endif /* EXTENDED_STATS */
#define TRY0(a) do { xmlrc = (a); if (xmlrc < 0) goto error; } while(0)
static int tcpinsizestats_index[dns_sizecounter_in_max];
static int tcpoutsizestats_index[dns_sizecounter_out_max];
static int dnstapstats_index[dns_dnstapcounter_max];
+static int gluecachestats_index[dns_gluecachestatscounter_max];
static inline void
set_desc(int counter, int maxcounter, const char *fdesc, const char **fdescs,
SET_DNSTAPSTATDESC(drop, "dnstap messages dropped", "DNSTAPdropped");
INSIST(i == dns_dnstapcounter_max);
+#define SET_GLUECACHESTATDESC(counterid, desc, xmldesc) \
+ do { \
+ set_desc(dns_gluecachestatscounter_ ## counterid, \
+ dns_gluecachestatscounter_max, \
+ desc, gluecachestats_desc, \
+ xmldesc, gluecachestats_xmldesc); \
+ gluecachestats_index[i++] = \
+ dns_gluecachestatscounter_ ## counterid; \
+ } while (0)
+ i = 0;
+ SET_GLUECACHESTATDESC(hits_present,
+ "Hits for present glue (cached)",
+ "GLUECACHEhitspresent");
+ SET_GLUECACHESTATDESC(hits_absent,
+ "Hits for non-existent glue (cached)",
+ "GLUECACHEhitsabsent");
+ SET_GLUECACHESTATDESC(inserts_present,
+ "Miss-plus-cache-inserts for present glue",
+ "GLUECACHEinsertspresent");
+ SET_GLUECACHESTATDESC(inserts_absent,
+ "Miss-plus-cache-inserts for non-existent glue",
+ "GLUECACHEinsertsabsent");
+ INSIST(i == dns_gluecachestatscounter_max);
+
/* Sanity check */
for (i = 0; i < ns_statscounter_max; i++)
INSIST(nsstats_desc[i] != NULL);
INSIST(dnssecstats_desc[i] != NULL);
for (i = 0; i < dns_dnstapcounter_max; i++)
INSIST(dnstapstats_desc[i] != NULL);
+ for (i = 0; i < dns_gluecachestatscounter_max; i++)
+ INSIST(gluecachestats_desc[i] != NULL);
#if defined(EXTENDED_STATS)
for (i = 0; i < ns_statscounter_max; i++)
INSIST(nsstats_xmldesc[i] != NULL);
INSIST(dnssecstats_xmldesc[i] != NULL);
for (i = 0; i < dns_dnstapcounter_max; i++)
INSIST(dnstapstats_xmldesc[i] != NULL);
+ for (i = 0; i < dns_gluecachestatscounter_max; i++)
+ INSIST(gluecachestats_xmldesc[i] != NULL);
#endif
/* Initialize traffic size statistics */
dns_rdataclass_t rdclass;
isc_uint32_t serial;
xmlTextWriterPtr writer = arg;
- isc_stats_t *zonestats;
- dns_stats_t *rcvquerystats;
dns_zonestat_level_t statlevel;
- isc_uint64_t nsstat_values[ns_statscounter_max];
int xmlrc;
stats_dumparg_t dumparg;
const char *ztype;
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR "-"));
TRY0(xmlTextWriterEndElement(writer)); /* serial */
- zonestats = dns_zone_getrequeststats(zone);
- rcvquerystats = dns_zone_getrcvquerystats(zone);
- if (statlevel == dns_zonestat_full && zonestats != NULL) {
- TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counters"));
- TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type",
- ISC_XMLCHAR "rcode"));
+ if (statlevel == dns_zonestat_full) {
+ isc_stats_t *zonestats;
+ isc_stats_t *gluecachestats;
+ dns_stats_t *rcvquerystats;
+ isc_uint64_t nsstat_values[ns_statscounter_max];
+ isc_uint64_t gluecachestats_values[dns_gluecachestatscounter_max];
- result = dump_counters(zonestats, isc_statsformat_xml, writer,
- NULL, nsstats_xmldesc,
- ns_statscounter_max, nsstats_index,
- nsstat_values, ISC_STATSDUMP_VERBOSE);
- if (result != ISC_R_SUCCESS)
- goto error;
- /* counters type="rcode"*/
- TRY0(xmlTextWriterEndElement(writer));
- }
+ zonestats = dns_zone_getrequeststats(zone);
+ if (zonestats != NULL) {
+ TRY0(xmlTextWriterStartElement(writer,
+ ISC_XMLCHAR "counters"));
+ TRY0(xmlTextWriterWriteAttribute(writer,
+ ISC_XMLCHAR "type",
+ ISC_XMLCHAR "rcode"));
- if (statlevel == dns_zonestat_full && rcvquerystats != NULL) {
- TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counters"));
- TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type",
- ISC_XMLCHAR "qtype"));
+ result = dump_counters(zonestats, isc_statsformat_xml,
+ writer, NULL, nsstats_xmldesc,
+ ns_statscounter_max,
+ nsstats_index, nsstat_values,
+ ISC_STATSDUMP_VERBOSE);
+ if (result != ISC_R_SUCCESS)
+ goto error;
+ /* counters type="rcode"*/
+ TRY0(xmlTextWriterEndElement(writer));
+ }
- dumparg.result = ISC_R_SUCCESS;
- dns_rdatatypestats_dump(rcvquerystats, rdtypestat_dump,
- &dumparg, 0);
- if(dumparg.result != ISC_R_SUCCESS)
- goto error;
+ gluecachestats = dns_zone_getgluecachestats(zone);
+ if (gluecachestats != NULL) {
+ TRY0(xmlTextWriterStartElement(writer,
+ ISC_XMLCHAR "counters"));
+ TRY0(xmlTextWriterWriteAttribute(writer,
+ ISC_XMLCHAR "type",
+ ISC_XMLCHAR "gluecache"));
+
+ result = dump_counters(gluecachestats,
+ isc_statsformat_xml,
+ writer, NULL,
+ gluecachestats_xmldesc,
+ dns_gluecachestatscounter_max,
+ gluecachestats_index,
+ gluecachestats_values,
+ ISC_STATSDUMP_VERBOSE);
+ if (result != ISC_R_SUCCESS)
+ goto error;
+ /* counters type="rcode"*/
+ TRY0(xmlTextWriterEndElement(writer));
+ }
- /* counters type="qtype"*/
- TRY0(xmlTextWriterEndElement(writer));
+ rcvquerystats = dns_zone_getrcvquerystats(zone);
+ if (rcvquerystats != NULL) {
+ TRY0(xmlTextWriterStartElement(writer,
+ ISC_XMLCHAR "counters"));
+ TRY0(xmlTextWriterWriteAttribute(writer,
+ ISC_XMLCHAR "type",
+ ISC_XMLCHAR "qtype"));
+
+ dumparg.result = ISC_R_SUCCESS;
+ dns_rdatatypestats_dump(rcvquerystats, rdtypestat_dump,
+ &dumparg, 0);
+ if(dumparg.result != ISC_R_SUCCESS)
+ goto error;
+
+ /* counters type="qtype"*/
+ TRY0(xmlTextWriterEndElement(writer));
+ }
}
TRY0(xmlTextWriterEndElement(writer)); /* zone */
char *class_only = NULL;
dns_rdataclass_t rdclass;
isc_uint32_t serial;
- isc_uint64_t nsstat_values[ns_statscounter_max];
- isc_stats_t *zonestats;
- dns_stats_t *rcvquerystats;
json_object *zonearray = (json_object *) arg;
json_object *zoneobj = NULL;
dns_zonestat_level_t statlevel;
if (zoneobj == NULL)
return (ISC_R_NOMEMORY);
- zonestats = dns_zone_getrequeststats(zone);
- rcvquerystats = dns_zone_getrcvquerystats(zone);
- if (statlevel == dns_zonestat_full && zonestats != NULL) {
- json_object *counters = json_object_new_object();
- if (counters == NULL) {
- result = ISC_R_NOMEMORY;
- goto error;
- }
+ if (statlevel == dns_zonestat_full) {
+ isc_stats_t *zonestats;
+ isc_stats_t *gluecachestats;
+ dns_stats_t *rcvquerystats;
+ isc_uint64_t nsstat_values[ns_statscounter_max];
+ isc_uint64_t gluecachestats_values[dns_gluecachestatscounter_max];
- result = dump_counters(zonestats, isc_statsformat_json,
- counters, NULL, nsstats_xmldesc,
- ns_statscounter_max, nsstats_index,
- nsstat_values, 0);
- if (result != ISC_R_SUCCESS) {
- json_object_put(counters);
- goto error;
+ zonestats = dns_zone_getrequeststats(zone);
+ if (zonestats != NULL) {
+ json_object *counters = json_object_new_object();
+ if (counters == NULL) {
+ result = ISC_R_NOMEMORY;
+ goto error;
+ }
+
+ result = dump_counters(zonestats, isc_statsformat_json,
+ counters, NULL, nsstats_xmldesc,
+ ns_statscounter_max,
+ nsstats_index,
+ nsstat_values, 0);
+ if (result != ISC_R_SUCCESS) {
+ json_object_put(counters);
+ goto error;
+ }
+
+ if (json_object_get_object(counters)->count != 0)
+ json_object_object_add(zoneobj,
+ "rcodes", counters);
+ else
+ json_object_put(counters);
}
- if (json_object_get_object(counters)->count != 0)
- json_object_object_add(zoneobj, "rcodes", counters);
- else
- json_object_put(counters);
- }
+ gluecachestats = dns_zone_getgluecachestats(zone);
+ if (gluecachestats != NULL) {
+ json_object *counters = json_object_new_object();
+ if (counters == NULL) {
+ result = ISC_R_NOMEMORY;
+ goto error;
+ }
- if (statlevel == dns_zonestat_full && rcvquerystats != NULL) {
- stats_dumparg_t dumparg;
- json_object *counters = json_object_new_object();
- CHECKMEM(counters);
+ result = dump_counters(gluecachestats,
+ isc_statsformat_json,
+ counters, NULL,
+ gluecachestats_xmldesc,
+ dns_gluecachestatscounter_max,
+ gluecachestats_index,
+ gluecachestats_values, 0);
+ if (result != ISC_R_SUCCESS) {
+ json_object_put(counters);
+ goto error;
+ }
- dumparg.type = isc_statsformat_json;
- dumparg.arg = counters;
- dumparg.result = ISC_R_SUCCESS;
- dns_rdatatypestats_dump(rcvquerystats, rdtypestat_dump,
- &dumparg, 0);
- if (dumparg.result != ISC_R_SUCCESS) {
- json_object_put(counters);
- goto error;
+ if (json_object_get_object(counters)->count != 0)
+ json_object_object_add(zoneobj,
+ "gluecache", counters);
+ else
+ json_object_put(counters);
}
- if (json_object_get_object(counters)->count != 0)
- json_object_object_add(zoneobj, "qtypes", counters);
- else
- json_object_put(counters);
+ rcvquerystats = dns_zone_getrcvquerystats(zone);
+ if (rcvquerystats != NULL) {
+ stats_dumparg_t dumparg;
+ json_object *counters = json_object_new_object();
+ CHECKMEM(counters);
+
+ dumparg.type = isc_statsformat_json;
+ dumparg.arg = counters;
+ dumparg.result = ISC_R_SUCCESS;
+ dns_rdatatypestats_dump(rcvquerystats, rdtypestat_dump,
+ &dumparg, 0);
+ if (dumparg.result != ISC_R_SUCCESS) {
+ json_object_put(counters);
+ goto error;
+ }
+
+ if (json_object_get_object(counters)->count != 0)
+ json_object_object_add(zoneobj,
+ "qtypes", counters);
+ else
+ json_object_put(counters);
+ }
}
json_object_array_add(zonearray, zoneobj);
isc_uint64_t adbstat_values[dns_adbstats_max];
isc_uint64_t zonestat_values[dns_zonestatscounter_max];
isc_uint64_t sockstat_values[isc_sockstatscounter_max];
+ isc_uint64_t gluecachestats_values[dns_gluecachestatscounter_max];
RUNTIME_CHECK(isc_once_do(&once, init_desc) == ISC_R_SUCCESS);
}
}
+ fprintf(fp, "++ Per Zone Glue Cache Statistics ++\n");
+ zone = NULL;
+ for (result = dns_zone_first(server->zonemgr, &zone);
+ result == ISC_R_SUCCESS;
+ next = NULL, result = dns_zone_next(zone, &next), zone = next)
+ {
+ isc_stats_t *gluecachestats = dns_zone_getgluecachestats(zone);
+ if (gluecachestats != NULL) {
+ char zonename[DNS_NAME_FORMATSIZE];
+
+ view = dns_zone_getview(zone);
+ if (view == NULL)
+ continue;
+
+ dns_name_format(dns_zone_getorigin(zone),
+ zonename, sizeof(zonename));
+ fprintf(fp, "[%s", zonename);
+ if (strcmp(view->name, "_default") != 0)
+ fprintf(fp, " (view: %s)", view->name);
+ fprintf(fp, "]\n");
+
+ (void) dump_counters(gluecachestats,
+ isc_statsformat_file,
+ fp, NULL, gluecachestats_desc,
+ dns_gluecachestatscounter_max,
+ gluecachestats_index,
+ gluecachestats_values, 0);
+ }
+ }
+
fprintf(fp, "--- Statistics Dump --- (%lu)\n", (unsigned long)now);
return (ISC_R_SUCCESS); /* this function currently always succeeds */
#define set_index set_index64
#define set_ttl set_ttl64
#define setcachestats setcachestats64
+#define setgluecachestats setgluecachestats64
#define setownercase setownercase64
#define setservestalettl setservestalettl64
#define setsigningtime setsigningtime64
dns_rbtnode_t * nsec3_origin_node;
dns_stats_t * rrsetstats; /* cache DB only */
isc_stats_t * cachestats; /* cache DB only */
+ isc_stats_t * gluecachestats; /* zone DB only */
/* Locked by lock. */
unsigned int active;
isc_refcount_t references;
dns_stats_detach(&rbtdb->rrsetstats);
if (rbtdb->cachestats != NULL)
isc_stats_detach(&rbtdb->cachestats);
+ if (rbtdb->gluecachestats != NULL)
+ isc_stats_detach(&rbtdb->gluecachestats);
isc_mem_put(rbtdb->common.mctx, rbtdb->node_locks,
rbtdb->node_lock_count * sizeof(rbtdb_nodelock_t));
return (ISC_R_SUCCESS);
}
+static isc_result_t
+setgluecachestats(dns_db_t *db, isc_stats_t *stats) {
+ dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
+
+ REQUIRE(VALID_RBTDB(rbtdb));
+ REQUIRE(!IS_CACHE(rbtdb) && !IS_STUB(rbtdb));
+ REQUIRE(stats != NULL);
+
+ isc_stats_attach(stats, &rbtdb->gluecachestats);
+ return (ISC_R_SUCCESS);
+}
+
static dns_stats_t *
getrrsetstats(dns_db_t *db) {
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
nodefullname,
getsize,
NULL,
- NULL
+ NULL,
+ setgluecachestats
};
static dns_dbmethods_t cache_methods = {
nodefullname,
NULL,
setservestalettl,
- getservestalettl
+ getservestalettl,
+ NULL
};
isc_result_t
}
rbtdb->cachestats = NULL;
+ rbtdb->gluecachestats = NULL;
+
rbtdb->rrsetstats = NULL;
if (IS_CACHE(rbtdb)) {
result = dns_rdatasetstats_create(mctx, &rbtdb->rrsetstats);
rbtdb_glue_additionaldata_ctx_t ctx;
isc_result_t result;
- INSIST(rdataset->type == dns_rdatatype_ns);
- INSIST(rbtdb == rbtversion->rbtdb);
- INSIST(!IS_CACHE(rbtdb) && !IS_STUB(rbtdb));
+ REQUIRE(rdataset->type == dns_rdatatype_ns);
+ REQUIRE(rbtdb == rbtversion->rbtdb);
+ REQUIRE(!IS_CACHE(rbtdb) && !IS_STUB(rbtdb));
/*
* The glue table cache that forms a part of the DB version
* (void *) -1 is a special value that means no glue is
* present in the zone.
*/
- if (ge == (void *) -1)
+ if (ge == (void *) -1) {
+ if (!restarted && (rbtdb->gluecachestats != NULL)) {
+ isc_stats_increment
+ (rbtdb->gluecachestats,
+ dns_gluecachestatscounter_hits_absent);
+ }
goto no_glue;
+ } else {
+ if (!restarted && (rbtdb->gluecachestats != NULL)) {
+ isc_stats_increment
+ (rbtdb->gluecachestats,
+ dns_gluecachestatscounter_hits_present);
+ }
+ }
for (; ge != NULL; ge = ge->next) {
isc_buffer_t *buffer = NULL;
* No glue was found. Cache it so.
*/
cur->glue_list = (void *) -1;
+ if (rbtdb->gluecachestats != NULL) {
+ isc_stats_increment
+ (rbtdb->gluecachestats,
+ dns_gluecachestatscounter_inserts_absent);
+ }
} else {
cur->glue_list = ctx.glue_list;
+ if (rbtdb->gluecachestats != NULL) {
+ isc_stats_increment
+ (rbtdb->gluecachestats,
+ dns_gluecachestatscounter_inserts_present);
+ }
}
cur->next = rbtversion->glue_table[idx];