libosmocore 0.9.6-23.20170220git32ee5af8.fc42
Osmocom core library
Loading...
Searching...
No Matches
Statistics value item

Files

file  stat_item.h
 
file  stat_item.c
 

Data Structures

struct  osmo_stat_item_value
 
struct  osmo_stat_item
 data we keep for each actual value More...
 
struct  osmo_stat_item_desc
 statistics value description More...
 
struct  osmo_stat_item_group_desc
 description of a statistics value group More...
 
struct  osmo_stat_item_group
 One instance of a counter group class. More...
 

Macros

#define OSMO_STAT_ITEM_NOVALUE_ID   0
 
#define OSMO_STAT_ITEM_NO_UNIT   NULL
 

Typedefs

typedef int(* osmo_stat_item_handler_t) (struct osmo_stat_item_group *, struct osmo_stat_item *, void *)
 
typedef int(* osmo_stat_item_group_handler_t) (struct osmo_stat_item_group *, void *)
 

Functions

struct osmo_stat_item_grouposmo_stat_item_group_alloc (void *ctx, const struct osmo_stat_item_group_desc *desc, unsigned int idx)
 Allocate a new group of counters according to description.
 
static void osmo_stat_item_group_udp_idx (struct osmo_stat_item_group *grp, unsigned int idx)
 
void osmo_stat_item_group_free (struct osmo_stat_item_group *grp)
 Free the memory for the specified group of counters.
 
void osmo_stat_item_set (struct osmo_stat_item *item, int32_t value)
 
int osmo_stat_item_init (void *tall_ctx)
 Initialize the stat item module.
 
struct osmo_stat_item_grouposmo_stat_item_get_group_by_name_idx (const char *name, const unsigned int idx)
 Search for item group based on group name and index.
 
const struct osmo_stat_itemosmo_stat_item_get_by_name (const struct osmo_stat_item_group *statg, const char *name)
 Search for item group based on group name.
 
int osmo_stat_item_get_next (const struct osmo_stat_item *item, int32_t *idx, int32_t *value)
 Retrieve the next value from the osmo_stat_item object. If a new value has been set, it is returned. The idx is used to decide which value to return. On success, *idx is updated to refer to the next unread value. If values have been missed due to FIFO overflow, *idx is incremented by (1 + num_lost). This way, the osmo_stat_item object can be kept stateless from the reader's perspective and therefore be used by several backends simultaneously.
 
static int32_t osmo_stat_item_get_last (const struct osmo_stat_item *item)
 Get the last (freshest) value.
 
int osmo_stat_item_discard (const struct osmo_stat_item *item, int32_t *idx)
 Skip all values of the item and update idx accordingly.
 
int osmo_stat_item_discard_all (int32_t *idx)
 Skip all values of all items and update idx accordingly.
 
int osmo_stat_item_for_each_item (struct osmo_stat_item_group *statg, osmo_stat_item_handler_t handle_item, void *data)
 Iteate over all items.
 
int osmo_stat_item_for_each_group (osmo_stat_item_group_handler_t handle_group, void *data)
 
static LLIST_HEAD (osmo_stat_item_groups)
 

Variables

static int32_t global_value_id = 0
 
static void * tall_stat_item_ctx
 

Detailed Description

Function Documentation

◆ osmo_stat_item_discard()

int osmo_stat_item_discard ( const struct osmo_stat_item * item,
int32_t * idx )

Skip all values of the item and update idx accordingly.

Skip all values of this item and update idx accordingly.

References last_offs, and values.

◆ osmo_stat_item_for_each_item()

int osmo_stat_item_for_each_item ( struct osmo_stat_item_group * statg,
osmo_stat_item_handler_t handle_item,
void * data )

Iteate over all items.

Parameters
[in]handle_itemCall-back function, aborts if rc < 0
[in]dataPrivate data handed through to handle_item

References osmo_stat_item_group::desc, osmo_stat_item_group::items, and osmo_stat_item_group_desc::num_items.

◆ osmo_stat_item_get_next()

int osmo_stat_item_get_next ( const struct osmo_stat_item * item,
int32_t * idx,
int32_t * value )

Retrieve the next value from the osmo_stat_item object. If a new value has been set, it is returned. The idx is used to decide which value to return. On success, *idx is updated to refer to the next unread value. If values have been missed due to FIFO overflow, *idx is incremented by (1 + num_lost). This way, the osmo_stat_item object can be kept stateless from the reader's perspective and therefore be used by several backends simultaneously.

Parameters
valthe osmo_stat_item object
idxidentifies the next value to be read
valuea pointer to store the value
Returns
the increment of the index (0: no value has been read, 1: one value has been taken, (1+n): n values have been skipped, one has been taken)

References last_offs, osmo_stat_item_desc::num_values, and values.

◆ osmo_stat_item_group_alloc()

struct osmo_stat_item_group * osmo_stat_item_group_alloc ( void * ctx,
const struct osmo_stat_item_group_desc * desc,
unsigned int idx )

Allocate a new group of counters according to description.

Parameters
[in]ctxtalloc context
[in]descStatistics item group description
[in]idxIndex of new stat item group

References osmo_stat_item_group::desc, osmo_stat_item_group::idx, osmo_stat_item_group_desc::item_desc, osmo_stat_item_group::items, last_offs, last_value_index, osmo_stat_item_group::list, llist_add(), osmo_stat_item_group_desc::num_items, osmo_stat_item_desc::num_values, and values.