stats.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2009, 2012, 2014  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 2000, 2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id$ */
00019 
00020 #ifndef DNS_STATS_H
00021 #define DNS_STATS_H 1
00022 
00023 /*! \file dns/stats.h */
00024 
00025 #include <dns/types.h>
00026 
00027 /*%
00028  * Statistics counters.  Used as isc_statscounter_t values.
00029  */
00030 enum {
00031         /*%
00032          * Resolver statistics counters.
00033          */
00034         dns_resstatscounter_queryv4 = 0,
00035         dns_resstatscounter_queryv6 = 1,
00036         dns_resstatscounter_responsev4 = 2,
00037         dns_resstatscounter_responsev6 = 3,
00038         dns_resstatscounter_nxdomain = 4,
00039         dns_resstatscounter_servfail = 5,
00040         dns_resstatscounter_formerr = 6,
00041         dns_resstatscounter_othererror = 7,
00042         dns_resstatscounter_edns0fail = 8,
00043         dns_resstatscounter_mismatch = 9,
00044         dns_resstatscounter_truncated = 10,
00045         dns_resstatscounter_lame = 11,
00046         dns_resstatscounter_retry = 12,
00047         dns_resstatscounter_gluefetchv4 = 13,
00048         dns_resstatscounter_gluefetchv6 = 14,
00049         dns_resstatscounter_gluefetchv4fail = 15,
00050         dns_resstatscounter_gluefetchv6fail = 16,
00051         dns_resstatscounter_val = 17,
00052         dns_resstatscounter_valsuccess = 18,
00053         dns_resstatscounter_valnegsuccess = 19,
00054         dns_resstatscounter_valfail = 20,
00055         dns_resstatscounter_dispabort = 21,
00056         dns_resstatscounter_dispsockfail = 22,
00057         dns_resstatscounter_querytimeout = 23,
00058         dns_resstatscounter_queryrtt0 = 24,
00059         dns_resstatscounter_queryrtt1 = 25,
00060         dns_resstatscounter_queryrtt2 = 26,
00061         dns_resstatscounter_queryrtt3 = 27,
00062         dns_resstatscounter_queryrtt4 = 28,
00063         dns_resstatscounter_queryrtt5 = 29,
00064         dns_resstatscounter_nfetch = 30,
00065         dns_resstatscounter_disprequdp = 31,
00066         dns_resstatscounter_dispreqtcp = 32,
00067         dns_resstatscounter_buckets = 33,
00068         dns_resstatscounter_refused = 34,
00069 #ifdef ISC_PLATFORM_USESIT
00070         dns_resstatscounter_sitcc = 35,
00071         dns_resstatscounter_sitout = 36,
00072         dns_resstatscounter_sitin = 37,
00073         dns_resstatscounter_sitok = 38,
00074 
00075         dns_resstatscounter_badvers = 39,
00076         dns_resstatscounter_max = 40,
00077 #else
00078         dns_resstatscounter_badvers = 35,
00079         dns_resstatscounter_max = 36,
00080 #endif
00081 
00082         /*
00083          * DNSSEC stats.
00084          */
00085         dns_dnssecstats_asis = 0,
00086         dns_dnssecstats_downcase = 1,
00087         dns_dnssecstats_wildcard = 2,
00088         dns_dnssecstats_fail = 3,
00089 
00090         dns_dnssecstats_max = 4,
00091 
00092         /*%
00093          * Zone statistics counters.
00094          */
00095         dns_zonestatscounter_notifyoutv4 = 0,
00096         dns_zonestatscounter_notifyoutv6 = 1,
00097         dns_zonestatscounter_notifyinv4 = 2,
00098         dns_zonestatscounter_notifyinv6 = 3,
00099         dns_zonestatscounter_notifyrej = 4,
00100         dns_zonestatscounter_soaoutv4 = 5,
00101         dns_zonestatscounter_soaoutv6 = 6,
00102         dns_zonestatscounter_axfrreqv4 = 7,
00103         dns_zonestatscounter_axfrreqv6 = 8,
00104         dns_zonestatscounter_ixfrreqv4 = 9,
00105         dns_zonestatscounter_ixfrreqv6 = 10,
00106         dns_zonestatscounter_xfrsuccess = 11,
00107         dns_zonestatscounter_xfrfail = 12,
00108 
00109         dns_zonestatscounter_max = 13,
00110 
00111         /*
00112          * Adb statistics values.
00113          */
00114         dns_adbstats_nentries = 0,
00115         dns_adbstats_entriescnt = 1,
00116         dns_adbstats_nnames = 2,
00117         dns_adbstats_namescnt = 3,
00118 
00119         dns_adbstats_max = 4,
00120 
00121         /*
00122          * Cache statistics values.
00123          */
00124         dns_cachestatscounter_hits = 1,
00125         dns_cachestatscounter_misses = 2,
00126         dns_cachestatscounter_queryhits = 3,
00127         dns_cachestatscounter_querymisses = 4,
00128         dns_cachestatscounter_deletelru = 5,
00129         dns_cachestatscounter_deletettl = 6,
00130 
00131         dns_cachestatscounter_max = 7,
00132 
00133         /*%
00134          * Query statistics counters (obsolete).
00135          */
00136         dns_statscounter_success = 0,    /*%< Successful lookup */
00137         dns_statscounter_referral = 1,   /*%< Referral result */
00138         dns_statscounter_nxrrset = 2,    /*%< NXRRSET result */
00139         dns_statscounter_nxdomain = 3,   /*%< NXDOMAIN result */
00140         dns_statscounter_recursion = 4,  /*%< Recursion was used */
00141         dns_statscounter_failure = 5,    /*%< Some other failure */
00142         dns_statscounter_duplicate = 6,  /*%< Duplicate query */
00143         dns_statscounter_dropped = 7     /*%< Duplicate query (dropped) */
00144 };
00145 
00146 #define DNS_STATS_NCOUNTERS 8
00147 
00148 #if 0
00149 /*%<
00150  * Flag(s) for dns_xxxstats_dump().  DNS_STATSDUMP_VERBOSE is obsolete.
00151  * ISC_STATSDUMP_VERBOSE should be used instead.  These two values are
00152  * intentionally defined to be the same value to ensure binary compatibility.
00153  */
00154 #define DNS_STATSDUMP_VERBOSE   0x00000001 /*%< dump 0-value counters */
00155 #endif
00156 
00157 /*%<
00158  * (Obsoleted)
00159  */
00160 LIBDNS_EXTERNAL_DATA extern const char *dns_statscounter_names[];
00161 
00162 /*%
00163  * Attributes for statistics counters of RRset and Rdatatype types.
00164  *
00165  * _OTHERTYPE
00166  *      The rdata type is not explicitly supported and the corresponding counter
00167  *      is counted for other such types, too.  When this attribute is set,
00168  *      the base type is of no use.
00169  *
00170  * _NXRRSET
00171  *      RRset type counters only.  Indicates the RRset is non existent.
00172  *
00173  * _NXDOMAIN
00174  *      RRset type counters only.  Indicates a non existent name.  When this
00175  *      attribute is set, the base type is of no use.
00176  *
00177  * _STALE
00178  *      RRset type counters only.  This indicates a record that marked for
00179  *      removal.
00180  *
00181  *      Note: incrementing _STALE will decrement the corresponding non-stale
00182  *      counter.
00183  */
00184 #define DNS_RDATASTATSTYPE_ATTR_OTHERTYPE       0x0001
00185 #define DNS_RDATASTATSTYPE_ATTR_NXRRSET         0x0002
00186 #define DNS_RDATASTATSTYPE_ATTR_NXDOMAIN        0x0004
00187 #define DNS_RDATASTATSTYPE_ATTR_STALE           0x0008
00188 
00189 /*%<
00190  * Conversion macros among dns_rdatatype_t, attributes and isc_statscounter_t.
00191  */
00192 #define DNS_RDATASTATSTYPE_BASE(type)   ((dns_rdatatype_t)((type) & 0xFFFF))
00193 #define DNS_RDATASTATSTYPE_ATTR(type)   ((type) >> 16)
00194 #define DNS_RDATASTATSTYPE_VALUE(b, a)  (((a) << 16) | (b))
00195 
00196 /*%<
00197  * Types of dump callbacks.
00198  */
00199 typedef void (*dns_generalstats_dumper_t)(isc_statscounter_t, isc_uint64_t,
00200                                           void *);
00201 typedef void (*dns_rdatatypestats_dumper_t)(dns_rdatastatstype_t, isc_uint64_t,
00202                                             void *);
00203 typedef void (*dns_opcodestats_dumper_t)(dns_opcode_t, isc_uint64_t, void *);
00204 
00205 ISC_LANG_BEGINDECLS
00206 
00207 isc_result_t
00208 dns_generalstats_create(isc_mem_t *mctx, dns_stats_t **statsp, int ncounters);
00209 /*%<
00210  * Create a statistics counter structure of general type.  It counts a general
00211  * set of counters indexed by an ID between 0 and ncounters -1.
00212  * This function is obsolete.  A more general function, isc_stats_create(),
00213  * should be used.
00214  *
00215  * Requires:
00216  *\li   'mctx' must be a valid memory context.
00217  *
00218  *\li   'statsp' != NULL && '*statsp' == NULL.
00219  *
00220  * Returns:
00221  *\li   ISC_R_SUCCESS   -- all ok
00222  *
00223  *\li   anything else   -- failure
00224  */
00225 
00226 isc_result_t
00227 dns_rdatatypestats_create(isc_mem_t *mctx, dns_stats_t **statsp);
00228 /*%<
00229  * Create a statistics counter structure per rdatatype.
00230  *
00231  * Requires:
00232  *\li   'mctx' must be a valid memory context.
00233  *
00234  *\li   'statsp' != NULL && '*statsp' == NULL.
00235  *
00236  * Returns:
00237  *\li   ISC_R_SUCCESS   -- all ok
00238  *
00239  *\li   anything else   -- failure
00240  */
00241 
00242 isc_result_t
00243 dns_rdatasetstats_create(isc_mem_t *mctx, dns_stats_t **statsp);
00244 /*%<
00245  * Create a statistics counter structure per RRset.
00246  *
00247  * Requires:
00248  *\li   'mctx' must be a valid memory context.
00249  *
00250  *\li   'statsp' != NULL && '*statsp' == NULL.
00251  *
00252  * Returns:
00253  *\li   ISC_R_SUCCESS   -- all ok
00254  *
00255  *\li   anything else   -- failure
00256  */
00257 
00258 isc_result_t
00259 dns_opcodestats_create(isc_mem_t *mctx, dns_stats_t **statsp);
00260 /*%<
00261  * Create a statistics counter structure per opcode.
00262  *
00263  * Requires:
00264  *\li   'mctx' must be a valid memory context.
00265  *
00266  *\li   'statsp' != NULL && '*statsp' == NULL.
00267  *
00268  * Returns:
00269  *\li   ISC_R_SUCCESS   -- all ok
00270  *
00271  *\li   anything else   -- failure
00272  */
00273 
00274 void
00275 dns_stats_attach(dns_stats_t *stats, dns_stats_t **statsp);
00276 /*%<
00277  * Attach to a statistics set.
00278  *
00279  * Requires:
00280  *\li   'stats' is a valid dns_stats_t.
00281  *
00282  *\li   'statsp' != NULL && '*statsp' == NULL
00283  */
00284 
00285 void
00286 dns_stats_detach(dns_stats_t **statsp);
00287 /*%<
00288  * Detaches from the statistics set.
00289  *
00290  * Requires:
00291  *\li   'statsp' != NULL and '*statsp' is a valid dns_stats_t.
00292  */
00293 
00294 void
00295 dns_generalstats_increment(dns_stats_t *stats, isc_statscounter_t counter);
00296 /*%<
00297  * Increment the counter-th counter of stats.  This function is obsolete.
00298  * A more general function, isc_stats_increment(), should be used.
00299  *
00300  * Requires:
00301  *\li   'stats' is a valid dns_stats_t created by dns_generalstats_create().
00302  *
00303  *\li   counter is less than the maximum available ID for the stats specified
00304  *      on creation.
00305  */
00306 
00307 void
00308 dns_rdatatypestats_increment(dns_stats_t *stats, dns_rdatatype_t type);
00309 /*%<
00310  * Increment the statistics counter for 'type'.
00311  *
00312  * Requires:
00313  *\li   'stats' is a valid dns_stats_t created by dns_rdatatypestats_create().
00314  */
00315 
00316 void
00317 dns_rdatasetstats_increment(dns_stats_t *stats, dns_rdatastatstype_t rrsettype);
00318 /*%<
00319  * Increment the statistics counter for 'rrsettype'.
00320  *
00321  * Note: if 'rrsettype' has the _STALE attribute set the corresponding
00322  * non-stale counter will be decremented.
00323  *
00324  * Requires:
00325  *\li   'stats' is a valid dns_stats_t created by dns_rdatasetstats_create().
00326  */
00327 
00328 void
00329 dns_rdatasetstats_decrement(dns_stats_t *stats, dns_rdatastatstype_t rrsettype);
00330 /*%<
00331  * Decrement the statistics counter for 'rrsettype'.
00332  *
00333  * Requires:
00334  *\li   'stats' is a valid dns_stats_t created by dns_rdatasetstats_create().
00335  */
00336 
00337 void
00338 dns_opcodestats_increment(dns_stats_t *stats, dns_opcode_t code);
00339 /*%<
00340  * Increment the statistics counter for 'code'.
00341  *
00342  * Requires:
00343  *\li   'stats' is a valid dns_stats_t created by dns_opcodestats_create().
00344  */
00345 
00346 void
00347 dns_generalstats_dump(dns_stats_t *stats, dns_generalstats_dumper_t dump_fn,
00348                       void *arg, unsigned int options);
00349 /*%<
00350  * Dump the current statistics counters in a specified way.  For each counter
00351  * in stats, dump_fn is called with its current value and the given argument
00352  * arg.  By default counters that have a value of 0 is skipped; if options has
00353  * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
00354  *
00355  * This function is obsolete.  A more general function, isc_stats_dump(),
00356  * should be used.
00357  *
00358  * Requires:
00359  *\li   'stats' is a valid dns_stats_t created by dns_generalstats_create().
00360  */
00361 
00362 void
00363 dns_rdatatypestats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn,
00364                         void *arg, unsigned int options);
00365 /*%<
00366  * Dump the current statistics counters in a specified way.  For each counter
00367  * in stats, dump_fn is called with the corresponding type in the form of
00368  * dns_rdatastatstype_t, the current counter value and the given argument
00369  * arg.  By default counters that have a value of 0 is skipped; if options has
00370  * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
00371  *
00372  * Requires:
00373  *\li   'stats' is a valid dns_stats_t created by dns_generalstats_create().
00374  */
00375 
00376 void
00377 dns_rdatasetstats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn,
00378                        void *arg, unsigned int options);
00379 /*%<
00380  * Dump the current statistics counters in a specified way.  For each counter
00381  * in stats, dump_fn is called with the corresponding type in the form of
00382  * dns_rdatastatstype_t, the current counter value and the given argument
00383  * arg.  By default counters that have a value of 0 is skipped; if options has
00384  * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
00385  *
00386  * Requires:
00387  *\li   'stats' is a valid dns_stats_t created by dns_generalstats_create().
00388  */
00389 
00390 void
00391 dns_opcodestats_dump(dns_stats_t *stats, dns_opcodestats_dumper_t dump_fn,
00392                      void *arg, unsigned int options);
00393 /*%<
00394  * Dump the current statistics counters in a specified way.  For each counter
00395  * in stats, dump_fn is called with the corresponding opcode, the current
00396  * counter value and the given argument arg.  By default counters that have a
00397  * value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even
00398  * such counters are dumped.
00399  *
00400  * Requires:
00401  *\li   'stats' is a valid dns_stats_t created by dns_generalstats_create().
00402  */
00403 
00404 isc_result_t
00405 dns_stats_alloccounters(isc_mem_t *mctx, isc_uint64_t **ctrp);
00406 /*%<
00407  * Allocate an array of query statistics counters from the memory
00408  * context 'mctx'.
00409  *
00410  * This function is obsoleted.  Use dns_xxxstats_create() instead.
00411  */
00412 
00413 void
00414 dns_stats_freecounters(isc_mem_t *mctx, isc_uint64_t **ctrp);
00415 /*%<
00416  * Free an array of query statistics counters allocated from the memory
00417  * context 'mctx'.
00418  *
00419  * This function is obsoleted.  Use dns_stats_destroy() instead.
00420  */
00421 
00422 ISC_LANG_ENDDECLS
00423 
00424 #endif /* DNS_STATS_H */

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