/*% * Dump methods */ void dns_generalstats_dump(dns_stats_t *stats, dns_generalstats_dumper_t dump_fn, void *arg, unsigned int options) { REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_general); isc_stats_dump(stats->counters, (isc_stats_dumper_t)dump_fn, arg, options); }
void dns_opcodestats_dump (dns_stats_t * stats, dns_opcodestats_dumper_t dump_fn, void *arg0, unsigned int options) { opcodedumparg_t arg; REQUIRE (DNS_STATS_VALID (stats) && stats->type == dns_statstype_opcode); arg.fn = dump_fn; arg.arg = arg0; isc_stats_dump (stats->counters, opcode_dumpcb, &arg, options); }
static isc_result_t dump_counters(isc_stats_t *stats, statsformat_t type, void *arg, const char *category, const char **desc, int ncounters, int *indices, isc_uint64_t *values, int options) { int i, index; isc_uint64_t value; stats_dumparg_t dumparg; FILE *fp; #ifdef HAVE_LIBXML2 xmlTextWriterPtr writer; int xmlrc; #endif #ifndef HAVE_LIBXML2 UNUSED(category); #endif dumparg.type = type; dumparg.ncounters = ncounters; dumparg.counterindices = indices; dumparg.countervalues = values; memset(values, 0, sizeof(values[0]) * ncounters); isc_stats_dump(stats, generalstat_dump, &dumparg, options); for (i = 0; i < ncounters; i++) { index = indices[i]; value = values[index]; switch (dumparg.type) { case statsformat_file: fp = arg; fprintf(fp, "%20" ISC_PRINT_QUADFORMAT "u %s\n", value, desc[index]); break; case statsformat_xml: #ifdef HAVE_LIBXML2 writer = arg; if (category != NULL) { TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR category)); TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "name")); TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR desc[index])); TRY0(xmlTextWriterEndElement(writer)); /* name */ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counter")); } else { TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR desc[index])); } TRY0(xmlTextWriterWriteFormatString(writer, "%" ISC_PRINT_QUADFORMAT "u", value)); TRY0(xmlTextWriterEndElement(writer)); /* counter */ if (category != NULL) TRY0(xmlTextWriterEndElement(writer)); /* category */ #endif break; } } return (ISC_R_SUCCESS); #ifdef HAVE_LIBXML2 error: return (ISC_R_FAILURE); #endif }