libosmocore
1.5.1
Osmocom core library
|
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/logging.h>
Functions | |
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) |
Find an unused index for this rate counter group. More... | |
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... | |
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... | |
int64_t | rate_ctr_difference (struct rate_ctr *ctr) |
Return the counter difference since the last call to this function. More... | |
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) |
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... | |
Variables | |
static void * | tall_rate_ctr_ctx |
static struct osmo_timer_list | rate_ctr_timer |
static uint64_t | timer_ticks |
|
static |
References ARRAY_SIZE, rate_ctr::current, rate_ctr::intv, rate_ctr_per_intv::last, and rate_ctr_per_intv::rate.
Referenced by rate_ctr_group_intv().
|
static |
|
static |
References DLGLOBAL, LOGL_NOTICE, LOGP, and OSMO_ASSERT.
Referenced by rate_ctr_group_desc_mangle().
|
static |
Find an unused index for this rate counter group.
[in] | name | Name of the counter group |
References rate_ctr_group::desc, rate_ctr_group_desc::group_name_prefix, rate_ctr_group::idx, rate_ctr_group::list, and llist_for_each_entry.
Referenced by rate_ctr_group_alloc().
|
static |
References rate_ctr_group_desc::class_id, rate_ctr_group_desc::ctr_desc, rate_ctr_desc::description, DLGLOBAL, rate_ctr_group_desc::group_description, rate_ctr_group_desc::group_name_prefix, if(), LOGL_ERROR, LOGL_INFO, LOGP, mangle_identifier_ifneeded(), rate_ctr_desc::name, name, rate_ctr_group_desc::num_ctr, OSMO_ASSERT, and rate_ctrl_group_desc_validate().
Referenced by rate_ctr_group_alloc().
|
static |
References rate_ctr_group::ctr, rate_ctr_group::desc, interval_expired(), rate_ctr_group_desc::num_ctr, RATE_CTR_INTV_DAY, RATE_CTR_INTV_HOUR, RATE_CTR_INTV_MIN, RATE_CTR_INTV_SEC, and timer_ticks.
Referenced by rate_ctr_timer_cb().
|
static |
References rate_ctr_group::list, llist_for_each_entry, osmo_timer_schedule(), rate_ctr_group_intv(), rate_ctr_timer, and timer_ticks.
Referenced by rate_ctr_init().
|
static |
References rate_ctr_group_desc::ctr_desc, DEBUGP, DLGLOBAL, rate_ctr_group_desc::group_name_prefix, LOGL_ERROR, LOGP, name, rate_ctr_group_desc::num_ctr, and osmo_identifier_valid().
Referenced by rate_ctr_group_alloc(), and rate_ctr_group_desc_mangle().