libosmocore
1.5.1
Osmocom core library
|
Counters about events and their event rates. More...
Files | |
file | rate_ctr.h |
file | rate_ctr.c |
Data Structures | |
struct | rate_ctr_per_intv |
data we keep for each of the intervals More... | |
struct | rate_ctr |
data we keep for each actual value More... | |
struct | rate_ctr_desc |
rate counter description More... | |
struct | rate_ctr_group_desc |
description of a rate counter group More... | |
struct | rate_ctr_group |
One instance of a counter group class. More... | |
Macros | |
#define | RATE_CTR_INTV_NUM 4 |
Number of rate counter intervals. More... | |
Typedefs | |
typedef int(* | rate_ctr_handler_t )(struct rate_ctr_group *, struct rate_ctr *, const struct rate_ctr_desc *, void *) |
typedef int(* | rate_ctr_group_handler_t )(struct rate_ctr_group *, void *) |
typedef int(* | rate_ctr_handler_t )(struct rate_ctr_group *, struct rate_ctr *, const struct rate_ctr_desc *, void *) |
typedef int(* | rate_ctr_group_handler_t )(struct rate_ctr_group *, void *) |
Enumerations | |
enum | rate_ctr_intv { RATE_CTR_INTV_SEC, RATE_CTR_INTV_MIN, RATE_CTR_INTV_HOUR, RATE_CTR_INTV_DAY } |
enum | rate_ctr_intv { RATE_CTR_INTV_SEC, RATE_CTR_INTV_MIN, RATE_CTR_INTV_HOUR, RATE_CTR_INTV_DAY } |
Rate counter interval. More... | |
Functions | |
struct rate_ctr_group * | rate_ctr_group_alloc (void *ctx, const struct rate_ctr_group_desc *desc, unsigned int idx) |
Allocate a new group of counters according to description. More... | |
static void | rate_ctr_group_upd_idx (struct rate_ctr_group *grp, unsigned int idx) |
void | rate_ctr_group_free (struct rate_ctr_group *grp) |
Free the memory for the specified group of counters. More... | |
void | rate_ctr_add (struct rate_ctr *ctr, int inc) |
Increment the counter by inc. More... | |
static void | rate_ctr_inc (struct rate_ctr *ctr) |
static void | rate_ctr_inc2 (struct rate_ctr_group *ctrg, unsigned int idx) |
int64_t | rate_ctr_difference (struct rate_ctr *ctr) |
Return the counter difference since the last call to this function. More... | |
int | rate_ctr_init (void *tall_ctx) |
Initialize the counter module. More... | |
struct rate_ctr_group * | rate_ctr_get_group_by_name_idx (const char *name, const unsigned int idx) |
Search for counter group based on group name and index. More... | |
const struct rate_ctr * | rate_ctr_get_by_name (const struct rate_ctr_group *ctrg, const char *name) |
Search for counter based on group + name. More... | |
int | rate_ctr_for_each_counter (struct rate_ctr_group *ctrg, rate_ctr_handler_t handle_counter, void *data) |
Iterate over each counter in group and call function. More... | |
int | rate_ctr_for_each_group (rate_ctr_group_handler_t handle_group, void *data) |
Iterate over all counter groups. More... | |
void | rate_ctr_reset (struct rate_ctr *ctr) |
Reset a rate counter back to zero. More... | |
void | rate_ctr_group_reset (struct rate_ctr_group *ctrg) |
Reset all counters in a group. More... | |
static | LLIST_HEAD (rate_ctr_groups) |
static bool | rate_ctrl_group_desc_validate (const struct rate_ctr_group_desc *desc) |
static char * | mangle_identifier_ifneeded (const void *ctx, const char *in) |
static struct rate_ctr_group_desc * | rate_ctr_group_desc_mangle (void *ctx, const struct rate_ctr_group_desc *desc) |
static unsigned int | rate_ctr_get_unused_name_idx (const char *name) |
static void | interval_expired (struct rate_ctr *ctr, enum rate_ctr_intv intv) |
static void | rate_ctr_group_intv (struct rate_ctr_group *grp) |
static void | rate_ctr_timer_cb (void *data) |
static int | rate_ctr_handler (struct rate_ctr_group *ctrg, struct rate_ctr *ctr, const struct rate_ctr_desc *desc, void *vctx_) |
void | vty_out_rate_ctr_group (struct vty *vty, const char *prefix, struct rate_ctr_group *ctrg) |
static char * | pad_append_str (char *s, const char *a, int minwidth) |
static char * | pad_append_ctr (char *s, uint64_t ctr, int minwidth) |
static int | rate_ctr_handler_fmt (struct rate_ctr_group *ctrg, struct rate_ctr *ctr, const struct rate_ctr_desc *desc, void *vctx_) |
void | vty_out_rate_ctr_group_fmt (struct vty *vty, const char *fmt, struct rate_ctr_group *ctrg) |
static int | rate_ctr_group_handler (struct rate_ctr_group *ctrg, void *vctx_) |
Variables | |
static void * | tall_rate_ctr_ctx |
static struct osmo_timer_list | rate_ctr_timer |
static uint64_t | timer_ticks |
static void * | tall_rate_ctr_ctx |
static struct osmo_timer_list | rate_ctr_timer |
static uint64_t | timer_ticks |
Counters about events and their event rates.
As osmo_counter and Statistics value item are concerned only with a single given value that may be increased/decreased, or the difference to one given previous value, this module adds some support for keeping long term information about a given event rate.
A Rate counters keeps information on the amount of events per second, per minute, per hour and per day.
Rate counters come in groups: An application describes a group of counters with their names and identities once in a (typically const) rate_ctr_group_desc.
As objects (such as e.g. a subscriber or a PDP context) are allocated dynamically at runtime, the application calls rate_ctr_group_alloc with a refernce to the rate_ctr_group_desc, which causes the library to allocate one set of rate_ctr: One for each in the group.
The application then uses functions like rate_ctr_add or rate_ctr_inc to increment the value as certain events (e.g. location update) happens.
The library internally keeps a timer once per second which iterates over all registered counters and which updates the per-second, per-minute, per-hour and per-day averages based on the current value.
The counters can be reported using Statistics reporting or by VTY introspection, as well as by any application-specific code accessing the rate_ctr::intv array directly.
#define RATE_CTR_INTV_NUM 4 |
Number of rate counter intervals.
typedef int(* rate_ctr_group_handler_t)(struct rate_ctr_group *, void *) |
typedef int(* rate_ctr_handler_t)(struct rate_ctr_group *, struct rate_ctr *, const struct rate_ctr_desc *, void *) |
enum rate_ctr_intv |
|
static |
Referenced by rate_ctr_init(), and rate_ctr_timer_cb().
|
static |
Referenced by rate_ctr_group_alloc(), and rate_ctr_init().
|
static |
Referenced by rate_ctr_group_intv(), and rate_ctr_timer_cb().