2 * Copyright (C) 2009, 2012 Internet Systems Consortium, Inc. ("ISC")
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
22 /*! \file isc/stats.h */
24 #include <isc/types.h>
29 * Flag(s) for isc_stats_dump().
31 #define ISC_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */
36 typedef void (*isc_stats_dumper_t)(isc_statscounter_t, isc_uint64_t, void *);
39 isc_stats_create(isc_mem_t *mctx, isc_stats_t **statsp, int ncounters);
41 * Create a statistics counter structure of general type. It counts a general
42 * set of counters indexed by an ID between 0 and ncounters -1.
45 *\li 'mctx' must be a valid memory context.
47 *\li 'statsp' != NULL && '*statsp' == NULL.
50 *\li ISC_R_SUCCESS -- all ok
52 *\li anything else -- failure
56 isc_stats_attach(isc_stats_t *stats, isc_stats_t **statsp);
58 * Attach to a statistics set.
61 *\li 'stats' is a valid isc_stats_t.
63 *\li 'statsp' != NULL && '*statsp' == NULL
67 isc_stats_detach(isc_stats_t **statsp);
69 * Detaches from the statistics set.
72 *\li 'statsp' != NULL and '*statsp' is a valid isc_stats_t.
76 isc_stats_ncounters(isc_stats_t *stats);
78 * Returns the number of counters contained in stats.
81 *\li 'stats' is a valid isc_stats_t.
86 isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter);
88 * Increment the counter-th counter of stats.
91 *\li 'stats' is a valid isc_stats_t.
93 *\li counter is less than the maximum available ID for the stats specified
98 isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter);
100 * Decrement the counter-th counter of stats.
103 *\li 'stats' is a valid isc_stats_t.
107 isc_stats_dump(isc_stats_t *stats, isc_stats_dumper_t dump_fn, void *arg,
108 unsigned int options);
110 * Dump the current statistics counters in a specified way. For each counter
111 * in stats, dump_fn is called with its current value and the given argument
112 * arg. By default counters that have a value of 0 is skipped; if options has
113 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
116 *\li 'stats' is a valid isc_stats_t.
121 #endif /* ISC_STATS_H */