stats.c File Reference

#include <config.h>
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/stats.h>
#include <isc/util.h>
#include <dns/opcode.h>
#include <dns/rdatatype.h>
#include <dns/stats.h>

Go to the source code of this file.

Data Structures

struct  dns_stats
struct  rdatadumparg
struct  opcodedumparg

Defines

#define DNS_STATS_MAGIC   ISC_MAGIC('D', 's', 't', 't')
#define DNS_STATS_VALID(x)   ISC_MAGIC_VALID(x, DNS_STATS_MAGIC)

Typedefs

typedef struct rdatadumparg rdatadumparg_t
typedef struct opcodedumparg opcodedumparg_t

Enumerations

enum  dns_statstype_t { dns_statstype_general = 0, dns_statstype_rdtype = 1, dns_statstype_rdataset = 2, dns_statstype_opcode = 3 }
 Statistics types. More...
enum  {
  rdtypecounter_dlv = 256, rdtypecounter_others = 257, rdtypecounter_max = 258, rdtypenxcounter_max = rdtypecounter_max * 2,
  rdtypecounter_nxdomain = rdtypenxcounter_max, rdtypecounter_stale = rdtypecounter_nxdomain + 1, rdatasettypecounter_max = rdtypecounter_stale * 2
}
 It doesn't make sense to have 2^16 counters for all possible types since most of them won't be used. We have counters for the first 256 types and those explicitly supported in the rdata implementation. XXXJT: this introduces tight coupling with the rdata implementation. Ideally, we should have rdata handle this type of details. More...

Functions

void dns_stats_attach (dns_stats_t *stats, dns_stats_t **statsp)
 Attach to a statistics set.
void dns_stats_detach (dns_stats_t **statsp)
 Detaches from the statistics set.
static isc_result_t create_stats (isc_mem_t *mctx, dns_statstype_t type, int ncounters, dns_stats_t **statsp)
 Create methods.
isc_result_t dns_generalstats_create (isc_mem_t *mctx, dns_stats_t **statsp, int ncounters)
 Create a statistics counter structure of general type. It counts a general set of counters indexed by an ID between 0 and ncounters -1. This function is obsolete. A more general function, isc_stats_create(), should be used.
isc_result_t dns_rdatatypestats_create (isc_mem_t *mctx, dns_stats_t **statsp)
 Create a statistics counter structure per rdatatype.
isc_result_t dns_rdatasetstats_create (isc_mem_t *mctx, dns_stats_t **statsp)
 Create a statistics counter structure per RRset.
isc_result_t dns_opcodestats_create (isc_mem_t *mctx, dns_stats_t **statsp)
 Create a statistics counter structure per opcode.
void dns_generalstats_increment (dns_stats_t *stats, isc_statscounter_t counter)
 Increment/Decrement methods.
void dns_rdatatypestats_increment (dns_stats_t *stats, dns_rdatatype_t type)
 Increment the statistics counter for 'type'.
static void update_rdatasetstats (dns_stats_t *stats, dns_rdatastatstype_t rrsettype, isc_boolean_t increment)
void dns_rdatasetstats_increment (dns_stats_t *stats, dns_rdatastatstype_t rrsettype)
 Increment the statistics counter for 'rrsettype'.
void dns_rdatasetstats_decrement (dns_stats_t *stats, dns_rdatastatstype_t rrsettype)
 Decrement the statistics counter for 'rrsettype'.
void dns_opcodestats_increment (dns_stats_t *stats, dns_opcode_t code)
 Increment the statistics counter for 'code'.
void dns_generalstats_dump (dns_stats_t *stats, dns_generalstats_dumper_t dump_fn, void *arg, unsigned int options)
 Dump methods.
static void dump_rdentry (int rdcounter, isc_uint64_t value, dns_rdatastatstype_t attributes, dns_rdatatypestats_dumper_t dump_fn, void *arg)
static void rdatatype_dumpcb (isc_statscounter_t counter, isc_uint64_t value, void *arg)
void dns_rdatatypestats_dump (dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn, void *arg0, unsigned int options)
 Dump the current statistics counters in a specified way. For each counter in stats, dump_fn is called with the corresponding type in the form of dns_rdatastatstype_t, the current counter value and the given argument arg. By default counters that have a value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
static void rdataset_dumpcb (isc_statscounter_t counter, isc_uint64_t value, void *arg)
void dns_rdatasetstats_dump (dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn, void *arg0, unsigned int options)
 Dump the current statistics counters in a specified way. For each counter in stats, dump_fn is called with the corresponding type in the form of dns_rdatastatstype_t, the current counter value and the given argument arg. By default counters that have a value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
static void opcode_dumpcb (isc_statscounter_t counter, isc_uint64_t value, void *arg)
void dns_opcodestats_dump (dns_stats_t *stats, dns_opcodestats_dumper_t dump_fn, void *arg0, unsigned int options)
 Dump the current statistics counters in a specified way. For each counter in stats, dump_fn is called with the corresponding opcode, the current counter value and the given argument arg. By default counters that have a value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
isc_result_t dns_stats_alloccounters (isc_mem_t *mctx, isc_uint64_t **ctrp)
 Allocate an array of query statistics counters from the memory context 'mctx'.
void dns_stats_freecounters (isc_mem_t *mctx, isc_uint64_t **ctrp)
 Free an array of query statistics counters allocated from the memory context 'mctx'.

Variables

LIBDNS_EXTERNAL_DATA const char * dns_statscounter_names [DNS_STATS_NCOUNTERS]


Detailed Description

Definition in file stats.c.


Define Documentation

#define DNS_STATS_MAGIC   ISC_MAGIC('D', 's', 't', 't')

Definition at line 33 of file stats.c.

Referenced by create_stats().

#define DNS_STATS_VALID (  )     ISC_MAGIC_VALID(x, DNS_STATS_MAGIC)

Definition at line 34 of file stats.c.

Referenced by dns_generalstats_dump(), dns_generalstats_increment(), dns_opcodestats_dump(), dns_opcodestats_increment(), dns_rdatasetstats_decrement(), dns_rdatasetstats_dump(), dns_rdatasetstats_increment(), dns_rdatatypestats_dump(), dns_rdatatypestats_increment(), dns_stats_attach(), and dns_stats_detach().


Typedef Documentation

typedef struct rdatadumparg rdatadumparg_t

typedef struct opcodedumparg opcodedumparg_t


Enumeration Type Documentation

enum dns_statstype_t

Statistics types.

Enumerator:
dns_statstype_general 
dns_statstype_rdtype 
dns_statstype_rdataset 
dns_statstype_opcode 

Definition at line 39 of file stats.c.

anonymous enum

It doesn't make sense to have 2^16 counters for all possible types since most of them won't be used. We have counters for the first 256 types and those explicitly supported in the rdata implementation. XXXJT: this introduces tight coupling with the rdata implementation. Ideally, we should have rdata handle this type of details.

Enumerator:
rdtypecounter_dlv 
rdtypecounter_others 
rdtypecounter_max 
rdtypenxcounter_max 
rdtypecounter_nxdomain 
rdtypecounter_stale 
rdatasettypecounter_max 

Definition at line 56 of file stats.c.


Function Documentation

void dns_stats_attach ( dns_stats_t stats,
dns_stats_t **  statsp 
)

Attach to a statistics set.

Requires:

Definition at line 92 of file stats.c.

References DNS_STATS_VALID, dns_stats::lock, LOCK, dns_stats::references, REQUIRE, and UNLOCK.

Referenced by dns_view_getresquerystats(), and dns_view_setresquerystats().

void dns_stats_detach ( dns_stats_t **  statsp  ) 

Detaches from the statistics set.

Requires:

Definition at line 104 of file stats.c.

References dns_stats::counters, DESTROYLOCK, DNS_STATS_VALID, isc_mem_putanddetach, isc_stats_detach(), dns_stats::lock, LOCK, dns_stats::mctx, dns_stats::references, REQUIRE, and UNLOCK.

Referenced by ATF_TC_BODY(), configure_view(), destroy(), dns_rbtdb_create(), free_rbtdb(), ns_server_destroy(), ns_zone_configure(), and zone_free().

static isc_result_t create_stats ( isc_mem_t mctx,
dns_statstype_t  type,
int  ncounters,
dns_stats_t **  statsp 
) [static]

Create methods.

Definition at line 127 of file stats.c.

References dns_stats::counters, DESTROYLOCK, DNS_STATS_MAGIC, isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_stats_create(), dns_stats::lock, dns_stats::magic, dns_stats::mctx, dns_stats::references, and dns_stats::type.

isc_result_t dns_generalstats_create ( isc_mem_t mctx,
dns_stats_t **  statsp,
int  ncounters 
)

Create a statistics counter structure of general type. It counts a general set of counters indexed by an ID between 0 and ncounters -1. This function is obsolete. A more general function, isc_stats_create(), should be used.

Requires:

Returns:

Definition at line 165 of file stats.c.

References create_stats(), dns_statstype_general, and REQUIRE.

isc_result_t dns_rdatatypestats_create ( isc_mem_t mctx,
dns_stats_t **  statsp 
)

Create a statistics counter structure per rdatatype.

Requires:

Returns:

Definition at line 172 of file stats.c.

References create_stats(), dns_statstype_rdtype, rdtypecounter_max, and REQUIRE.

Referenced by configure_view(), ns_server_create(), and ns_zone_configure().

isc_result_t dns_rdatasetstats_create ( isc_mem_t mctx,
dns_stats_t **  statsp 
)

Create a statistics counter structure per RRset.

Requires:

Returns:

Definition at line 180 of file stats.c.

References create_stats(), dns_statstype_rdataset, rdatasettypecounter_max, and REQUIRE.

Referenced by ATF_TC_BODY(), and dns_rbtdb_create().

isc_result_t dns_opcodestats_create ( isc_mem_t mctx,
dns_stats_t **  statsp 
)

Create a statistics counter structure per opcode.

Requires:

Returns:

Definition at line 188 of file stats.c.

References create_stats(), dns_statstype_opcode, and REQUIRE.

Referenced by ns_server_create().

void dns_generalstats_increment ( dns_stats_t stats,
isc_statscounter_t  counter 
)

Increment/Decrement methods.

Increment the counter-th counter of stats. This function is obsolete. A more general function, isc_stats_increment(), should be used.

Definition at line 198 of file stats.c.

References dns_stats::counters, DNS_STATS_VALID, dns_statstype_general, isc_stats_increment(), REQUIRE, and dns_stats::type.

void dns_rdatatypestats_increment ( dns_stats_t stats,
dns_rdatatype_t  type 
)

Increment the statistics counter for 'type'.

Requires:

Definition at line 205 of file stats.c.

References counter, dns_stats::counters, DNS_STATS_VALID, dns_statstype_rdtype, isc_stats_increment(), rdtypecounter_dlv, rdtypecounter_others, REQUIRE, and dns_stats::type.

Referenced by fctx_query(), inc_stats(), and ns_query_start().

static void update_rdatasetstats ( dns_stats_t stats,
dns_rdatastatstype_t  rrsettype,
isc_boolean_t  increment 
) [inline, static]

Definition at line 221 of file stats.c.

References counter, dns_stats::counters, DNS_RDATASTATSTYPE_ATTR, DNS_RDATASTATSTYPE_ATTR_NXDOMAIN, DNS_RDATASTATSTYPE_ATTR_NXRRSET, DNS_RDATASTATSTYPE_ATTR_STALE, DNS_RDATASTATSTYPE_BASE, isc_stats_decrement(), isc_stats_increment(), rdtypecounter_dlv, rdtypecounter_max, rdtypecounter_nxdomain, rdtypecounter_others, and rdtypecounter_stale.

Referenced by dns_rdatasetstats_decrement(), and dns_rdatasetstats_increment().

void dns_rdatasetstats_increment ( dns_stats_t stats,
dns_rdatastatstype_t  rrsettype 
)

Increment the statistics counter for 'rrsettype'.

Note: if 'rrsettype' has the _STALE attribute set the corresponding non-stale counter will be decremented.

Requires:

Definition at line 260 of file stats.c.

References DNS_STATS_VALID, dns_statstype_rdataset, ISC_TRUE, REQUIRE, dns_stats::type, and update_rdatasetstats().

Referenced by set_nxdomainstats(), set_typestats(), and update_rrsetstats().

void dns_rdatasetstats_decrement ( dns_stats_t stats,
dns_rdatastatstype_t  rrsettype 
)

Decrement the statistics counter for 'rrsettype'.

Requires:

Definition at line 269 of file stats.c.

References DNS_STATS_VALID, dns_statstype_rdataset, ISC_FALSE, REQUIRE, dns_stats::type, and update_rdatasetstats().

Referenced by update_rrsetstats().

void dns_opcodestats_increment ( dns_stats_t stats,
dns_opcode_t  code 
)

Increment the statistics counter for 'code'.

Requires:

Definition at line 278 of file stats.c.

References dns_stats::counters, DNS_STATS_VALID, dns_statstype_opcode, isc_stats_increment(), REQUIRE, and dns_stats::type.

Referenced by client_request().

void dns_generalstats_dump ( dns_stats_t stats,
dns_generalstats_dumper_t  dump_fn,
void *  arg,
unsigned int  options 
)

Dump methods.

Dump the current statistics counters in a specified way. For each counter in stats, dump_fn is called with its current value and the given argument arg. By default counters that have a value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.

Definition at line 288 of file stats.c.

References dns_stats::counters, DNS_STATS_VALID, dns_statstype_general, isc_stats_dump(), REQUIRE, and dns_stats::type.

static void dump_rdentry ( int  rdcounter,
isc_uint64_t  value,
dns_rdatastatstype_t  attributes,
dns_rdatatypestats_dumper_t  dump_fn,
void *  arg 
) [static]

Definition at line 298 of file stats.c.

References DNS_RDATASTATSTYPE_ATTR_OTHERTYPE, DNS_RDATASTATSTYPE_VALUE, rdtypecounter_dlv, and rdtypecounter_others.

Referenced by rdataset_dumpcb(), and rdatatype_dumpcb().

static void rdatatype_dumpcb ( isc_statscounter_t  counter,
isc_uint64_t  value,
void *  arg 
) [static]

Definition at line 318 of file stats.c.

References rdatadumparg::arg, dump_rdentry(), and rdatadumparg::fn.

Referenced by dns_rdatatypestats_dump().

void dns_rdatatypestats_dump ( dns_stats_t stats,
dns_rdatatypestats_dumper_t  dump_fn,
void *  arg,
unsigned int  options 
)

Dump the current statistics counters in a specified way. For each counter in stats, dump_fn is called with the corresponding type in the form of dns_rdatastatstype_t, the current counter value and the given argument arg. By default counters that have a value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.

Requires:

Definition at line 325 of file stats.c.

References rdatadumparg::arg, arg, dns_stats::counters, DNS_STATS_VALID, dns_statstype_rdtype, rdatadumparg::fn, isc_stats_dump(), rdatatype_dumpcb(), REQUIRE, and dns_stats::type.

Referenced by ns_stats_dump().

static void rdataset_dumpcb ( isc_statscounter_t  counter,
isc_uint64_t  value,
void *  arg 
) [static]

Definition at line 337 of file stats.c.

References rdatadumparg::arg, DNS_RDATASTATSTYPE_ATTR_NXDOMAIN, DNS_RDATASTATSTYPE_ATTR_NXRRSET, DNS_RDATASTATSTYPE_ATTR_STALE, dump_rdentry(), rdatadumparg::fn, rdtypecounter_max, rdtypecounter_nxdomain, and rdtypecounter_stale.

Referenced by dns_rdatasetstats_dump().

void dns_rdatasetstats_dump ( dns_stats_t stats,
dns_rdatatypestats_dumper_t  dump_fn,
void *  arg,
unsigned int  options 
)

Dump the current statistics counters in a specified way. For each counter in stats, dump_fn is called with the corresponding type in the form of dns_rdatastatstype_t, the current counter value and the given argument arg. By default counters that have a value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.

Requires:

Definition at line 372 of file stats.c.

References rdatadumparg::arg, arg, dns_stats::counters, DNS_STATS_VALID, dns_statstype_rdataset, rdatadumparg::fn, isc_stats_dump(), rdataset_dumpcb(), REQUIRE, and dns_stats::type.

Referenced by ATF_TC_BODY(), and ns_stats_dump().

static void opcode_dumpcb ( isc_statscounter_t  counter,
isc_uint64_t  value,
void *  arg 
) [static]

Definition at line 386 of file stats.c.

References opcodedumparg::arg, and opcodedumparg::fn.

Referenced by dns_opcodestats_dump().

void dns_opcodestats_dump ( dns_stats_t stats,
dns_opcodestats_dumper_t  dump_fn,
void *  arg,
unsigned int  options 
)

Dump the current statistics counters in a specified way. For each counter in stats, dump_fn is called with the corresponding opcode, the current counter value and the given argument arg. By default counters that have a value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.

Requires:

Definition at line 393 of file stats.c.

References opcodedumparg::arg, arg, dns_stats::counters, DNS_STATS_VALID, dns_statstype_opcode, opcodedumparg::fn, isc_stats_dump(), opcode_dumpcb(), REQUIRE, and dns_stats::type.

Referenced by ns_stats_dump().

isc_result_t dns_stats_alloccounters ( isc_mem_t mctx,
isc_uint64_t **  ctrp 
)

Allocate an array of query statistics counters from the memory context 'mctx'.

This function is obsoleted. Use dns_xxxstats_create() instead.

Definition at line 421 of file stats.c.

References DNS_STATS_NCOUNTERS, isc_mem_get, ISC_R_NOMEMORY, and ISC_R_SUCCESS.

void dns_stats_freecounters ( isc_mem_t mctx,
isc_uint64_t **  ctrp 
)

Free an array of query statistics counters allocated from the memory context 'mctx'.

This function is obsoleted. Use dns_stats_destroy() instead.

Definition at line 434 of file stats.c.

References DNS_STATS_NCOUNTERS, and isc_mem_put.


Variable Documentation

LIBDNS_EXTERNAL_DATA const char* dns_statscounter_names[DNS_STATS_NCOUNTERS]

Initial value:

        {
        "success",
        "referral",
        "nxrrset",
        "nxdomain",
        "recursion",
        "failure",
        "duplicate",
        "dropped"
        }

Definition at line 408 of file stats.c.


Generated on Tue Apr 28 17:41:18 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha