1 /* $NetBSD: stats.h,v 1.5 2014/12/10 04:38:00 christos Exp $ */ 2 3 /* 4 * Copyright (C) 2009, 2012 Internet Systems Consortium, Inc. ("ISC") 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /* Id */ 20 21 #ifndef ISC_STATS_H 22 #define ISC_STATS_H 1 23 24 /*! \file isc/stats.h */ 25 26 #include <isc/types.h> 27 28 ISC_LANG_BEGINDECLS 29 30 /*%< 31 * Flag(s) for isc_stats_dump(). 32 */ 33 #define ISC_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */ 34 35 /*%< 36 * Dump callback type. 37 */ 38 typedef void (*isc_stats_dumper_t)(isc_statscounter_t, isc_uint64_t, void *); 39 40 isc_result_t 41 isc_stats_create(isc_mem_t *mctx, isc_stats_t **statsp, int ncounters); 42 /*%< 43 * Create a statistics counter structure of general type. It counts a general 44 * set of counters indexed by an ID between 0 and ncounters -1. 45 * 46 * Requires: 47 *\li 'mctx' must be a valid memory context. 48 * 49 *\li 'statsp' != NULL && '*statsp' == NULL. 50 * 51 * Returns: 52 *\li ISC_R_SUCCESS -- all ok 53 * 54 *\li anything else -- failure 55 */ 56 57 void 58 isc_stats_attach(isc_stats_t *stats, isc_stats_t **statsp); 59 /*%< 60 * Attach to a statistics set. 61 * 62 * Requires: 63 *\li 'stats' is a valid isc_stats_t. 64 * 65 *\li 'statsp' != NULL && '*statsp' == NULL 66 */ 67 68 void 69 isc_stats_detach(isc_stats_t **statsp); 70 /*%< 71 * Detaches from the statistics set. 72 * 73 * Requires: 74 *\li 'statsp' != NULL and '*statsp' is a valid isc_stats_t. 75 */ 76 77 int 78 isc_stats_ncounters(isc_stats_t *stats); 79 /*%< 80 * Returns the number of counters contained in stats. 81 * 82 * Requires: 83 *\li 'stats' is a valid isc_stats_t. 84 * 85 */ 86 87 void 88 isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter); 89 /*%< 90 * Increment the counter-th counter of stats. 91 * 92 * Requires: 93 *\li 'stats' is a valid isc_stats_t. 94 * 95 *\li counter is less than the maximum available ID for the stats specified 96 * on creation. 97 */ 98 99 void 100 isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter); 101 /*%< 102 * Decrement the counter-th counter of stats. 103 * 104 * Requires: 105 *\li 'stats' is a valid isc_stats_t. 106 */ 107 108 void 109 isc_stats_dump(isc_stats_t *stats, isc_stats_dumper_t dump_fn, void *arg, 110 unsigned int options); 111 /*%< 112 * Dump the current statistics counters in a specified way. For each counter 113 * in stats, dump_fn is called with its current value and the given argument 114 * arg. By default counters that have a value of 0 is skipped; if options has 115 * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped. 116 * 117 * Requires: 118 *\li 'stats' is a valid isc_stats_t. 119 */ 120 121 void 122 isc_stats_set(isc_stats_t *stats, isc_uint64_t val, 123 isc_statscounter_t counter); 124 /*%< 125 * Set the given counter to the specfied value. 126 * 127 * Requires: 128 *\li 'stats' is a valid isc_stats_t. 129 */ 130 131 void 132 isc_stats_set(isc_stats_t *stats, isc_uint64_t val, 133 isc_statscounter_t counter); 134 /*%< 135 * Set the given counter to the specfied value. 136 * 137 * Requires: 138 *\li 'stats' is a valid isc_stats_t. 139 */ 140 141 ISC_LANG_ENDDECLS 142 143 #endif /* ISC_STATS_H */ 144