12#define RATE_CTR_INTV_NUM 4
static void rate_ctr_add2(struct rate_ctr_group *ctrg, unsigned int idx, int inc)
Increment the counter by inc.
Definition: rate_ctr.h:93
void rate_ctr_reset(struct rate_ctr *ctr)
Reset a rate counter back to zero.
Definition: rate_ctr.c:481
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.
Definition: rate_ctr.c:212
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.
Definition: rate_ctr.c:418
static void rate_ctr_inc2(struct rate_ctr_group *ctrg, unsigned int idx)
Increment the counter by 1.
Definition: rate_ctr.h:108
rate_ctr_intv
Rate counter interval.
Definition: rate_ctr.h:15
void rate_ctr_group_free(struct rate_ctr_group *grp)
Free the memory for the specified group of counters.
Definition: rate_ctr.c:255
struct rate_ctr * rate_ctr_group_get_ctr(struct rate_ctr_group *grp, unsigned int idx)
Get rate counter from group, identified by index idx.
Definition: rate_ctr.c:270
void rate_ctr_group_reset(struct rate_ctr_group *ctrg)
Reset all counters in a group.
Definition: rate_ctr.c:489
void rate_ctr_group_set_name(struct rate_ctr_group *grp, const char *name)
Set a name for the group of counters be used instead of index value at report time.
Definition: rate_ctr.c:280
int(* rate_ctr_group_handler_t)(struct rate_ctr_group *, void *)
Definition: rate_ctr.h:125
int rate_ctr_for_each_group(rate_ctr_group_handler_t handle_group, void *data)
Iterate over all counter groups.
Definition: rate_ctr.c:464
static void rate_ctr_group_upd_idx(struct rate_ctr_group *grp, unsigned int idx)
Definition: rate_ctr.h:74
#define RATE_CTR_INTV_NUM
Number of rate counter intervals.
Definition: rate_ctr.h:12
int(* rate_ctr_handler_t)(struct rate_ctr_group *, struct rate_ctr *, const struct rate_ctr_desc *, void *)
Definition: rate_ctr.h:122
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.
Definition: rate_ctr.c:397
static void rate_ctr_inc(struct rate_ctr *ctr)
Increment the counter by 1.
Definition: rate_ctr.h:100
int rate_ctr_init(void *tall_ctx)
Initialize the counter module.
Definition: rate_ctr.c:366
int64_t rate_ctr_difference(struct rate_ctr *ctr)
Return the counter difference since the last call to this function.
Definition: rate_ctr.c:292
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.
Definition: rate_ctr.c:442
void rate_ctr_add(struct rate_ctr *ctr, int inc)
Increment the counter by inc.
Definition: rate_ctr.c:286
@ RATE_CTR_INTV_DAY
last day
Definition: rate_ctr.h:19
@ RATE_CTR_INTV_SEC
last second
Definition: rate_ctr.h:16
@ RATE_CTR_INTV_MIN
last minute
Definition: rate_ctr.h:17
@ RATE_CTR_INTV_HOUR
last hour
Definition: rate_ctr.h:18
static int handle_counter(struct osmo_counter *counter, void *vctx_)
Simple doubly linked list implementation.
(double) linked list header structure
Definition: linuxlist.h:46
rate counter description
Definition: rate_ctr.h:37
const char * description
description of the counter
Definition: rate_ctr.h:39
const char * name
name of the counter
Definition: rate_ctr.h:38
description of a rate counter group
Definition: rate_ctr.h:43
int class_id
The class to which this group belongs.
Definition: rate_ctr.h:49
const struct rate_ctr_desc * ctr_desc
Pointer to array of counter names.
Definition: rate_ctr.h:53
unsigned int num_ctr
The number of counters in this group.
Definition: rate_ctr.h:51
const char * group_name_prefix
The prefix to the name of all counters in this group.
Definition: rate_ctr.h:45
const char * group_description
The human-readable description of the group.
Definition: rate_ctr.h:47
One instance of a counter group class.
Definition: rate_ctr.h:57
struct llist_head list
Linked list of all counter groups in the system.
Definition: rate_ctr.h:59
struct rate_ctr ctr[0]
Actual counter structures below.
Definition: rate_ctr.h:67
unsigned int idx
The index of this ctr_group within its class.
Definition: rate_ctr.h:63
char * name
Optional string-based identifier to be used instead of index at report time.
Definition: rate_ctr.h:65
const struct rate_ctr_group_desc * desc
Pointer to the counter group class.
Definition: rate_ctr.h:61
data we keep for each of the intervals
Definition: rate_ctr.h:23
uint64_t rate
counter rate
Definition: rate_ctr.h:25
uint64_t last
counter value in last interval
Definition: rate_ctr.h:24
data we keep for each actual value
Definition: rate_ctr.h:29
uint64_t current
current value
Definition: rate_ctr.h:30
struct rate_ctr_per_intv intv[RATE_CTR_INTV_NUM]
per-interval data
Definition: rate_ctr.h:33
uint64_t previous
previous value, used for delta
Definition: rate_ctr.h:31