stats.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009, 2012  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 /* $Id$ */
00018 
00019 #ifndef ISC_STATS_H
00020 #define ISC_STATS_H 1
00021 
00022 /*! \file isc/stats.h */
00023 
00024 #include <isc/types.h>
00025 
00026 ISC_LANG_BEGINDECLS
00027 
00028 /*%<
00029  * Flag(s) for isc_stats_dump().
00030  */
00031 #define ISC_STATSDUMP_VERBOSE   0x00000001 /*%< dump 0-value counters */
00032 
00033 /*%<
00034  * Dump callback type.
00035  */
00036 typedef void (*isc_stats_dumper_t)(isc_statscounter_t, isc_uint64_t, void *);
00037 
00038 isc_result_t
00039 isc_stats_create(isc_mem_t *mctx, isc_stats_t **statsp, int ncounters);
00040 /*%<
00041  * Create a statistics counter structure of general type.  It counts a general
00042  * set of counters indexed by an ID between 0 and ncounters -1.
00043  *
00044  * Requires:
00045  *\li   'mctx' must be a valid memory context.
00046  *
00047  *\li   'statsp' != NULL && '*statsp' == NULL.
00048  *
00049  * Returns:
00050  *\li   ISC_R_SUCCESS   -- all ok
00051  *
00052  *\li   anything else   -- failure
00053  */
00054 
00055 void
00056 isc_stats_attach(isc_stats_t *stats, isc_stats_t **statsp);
00057 /*%<
00058  * Attach to a statistics set.
00059  *
00060  * Requires:
00061  *\li   'stats' is a valid isc_stats_t.
00062  *
00063  *\li   'statsp' != NULL && '*statsp' == NULL
00064  */
00065 
00066 void
00067 isc_stats_detach(isc_stats_t **statsp);
00068 /*%<
00069  * Detaches from the statistics set.
00070  *
00071  * Requires:
00072  *\li   'statsp' != NULL and '*statsp' is a valid isc_stats_t.
00073  */
00074 
00075 int
00076 isc_stats_ncounters(isc_stats_t *stats);
00077 /*%<
00078  * Returns the number of counters contained in stats.
00079  *
00080  * Requires:
00081  *\li   'stats' is a valid isc_stats_t.
00082  *
00083  */
00084 
00085 void
00086 isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter);
00087 /*%<
00088  * Increment the counter-th counter of stats.
00089  *
00090  * Requires:
00091  *\li   'stats' is a valid isc_stats_t.
00092  *
00093  *\li   counter is less than the maximum available ID for the stats specified
00094  *      on creation.
00095  */
00096 
00097 void
00098 isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter);
00099 /*%<
00100  * Decrement the counter-th counter of stats.
00101  *
00102  * Requires:
00103  *\li   'stats' is a valid isc_stats_t.
00104  */
00105 
00106 void
00107 isc_stats_dump(isc_stats_t *stats, isc_stats_dumper_t dump_fn, void *arg,
00108                unsigned int options);
00109 /*%<
00110  * Dump the current statistics counters in a specified way.  For each counter
00111  * in stats, dump_fn is called with its current value and the given argument
00112  * arg.  By default counters that have a value of 0 is skipped; if options has
00113  * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
00114  *
00115  * Requires:
00116  *\li   'stats' is a valid isc_stats_t.
00117  */
00118 
00119 void
00120 isc_stats_set(isc_stats_t *stats, isc_uint64_t val,
00121               isc_statscounter_t counter);
00122 /*%<
00123  * Set the given counter to the specfied value.
00124  *
00125  * Requires:
00126  *\li   'stats' is a valid isc_stats_t.
00127  */
00128 
00129 void
00130 isc_stats_set(isc_stats_t *stats, isc_uint64_t val,
00131               isc_statscounter_t counter);
00132 /*%<
00133  * Set the given counter to the specfied value.
00134  *
00135  * Requires:
00136  *\li   'stats' is a valid isc_stats_t.
00137  */
00138 
00139 ISC_LANG_ENDDECLS
00140 
00141 #endif /* ISC_STATS_H */

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