libosmocore  0.9.6.315-40e62
Osmocom core library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
stat_item.h
Go to the documentation of this file.
1 #pragma once
2 
7 #include <stdint.h>
8 
10 
11 struct osmo_stat_item_desc;
12 
13 #define OSMO_STAT_ITEM_NOVALUE_ID 0
14 #define OSMO_STAT_ITEM_NO_UNIT NULL
15 
17  int32_t id;
18  int32_t value;
19 };
20 
23  const struct osmo_stat_item_desc *desc;
27  int16_t last_offs;
30 };
31 
34  const char *name;
35  const char *description;
36  const char *unit;
37  unsigned int num_values;
38  int32_t default_value;
39 };
40 
44  const char *group_name_prefix;
46  const char *group_description;
48  int class_id;
50  const unsigned int num_items;
53 };
54 
58  struct llist_head list;
62  unsigned int idx;
64  struct osmo_stat_item *items[0];
65 };
66 
68  void *ctx,
69  const struct osmo_stat_item_group_desc *desc,
70  unsigned int idx);
71 
72 static inline void osmo_stat_item_group_udp_idx(
73  struct osmo_stat_item_group *grp, unsigned int idx)
74 {
75  grp->idx = idx;
76 }
77 
79 
80 void osmo_stat_item_set(struct osmo_stat_item *item, int32_t value);
81 
82 int osmo_stat_item_init(void *tall_ctx);
83 
85  const char *name, const unsigned int idx);
86 
88  const struct osmo_stat_item_group *statg, const char *name);
89 
106 int osmo_stat_item_get_next(const struct osmo_stat_item *item, int32_t *idx, int32_t *value);
107 
109 static int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item);
110 
112 int osmo_stat_item_discard(const struct osmo_stat_item *item, int32_t *idx);
113 
115 int osmo_stat_item_discard_all(int32_t *idx);
116 
118  struct osmo_stat_item_group *, struct osmo_stat_item *, void *);
119 
120 typedef int (*osmo_stat_item_group_handler_t)(struct osmo_stat_item_group *, void *);
121 
127  osmo_stat_item_handler_t handle_item, void *data);
128 
130 
131 static inline int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item)
132 {
133  return item->values[item->last_offs].value;
134 }
description of a statistics value group
Definition: stat_item.h:42
void osmo_stat_item_set(struct osmo_stat_item *item, int32_t value)
Definition: stat_item.c:122
const struct osmo_stat_item_group_desc * desc
Pointer to the counter group class.
Definition: stat_item.h:60
int osmo_stat_item_discard(const struct osmo_stat_item *item, int32_t *idx)
Skip all values of the item and update idx accordingly.
Definition: stat_item.c:174
int class_id
The class to which this group belongs.
Definition: stat_item.h:48
const char * group_description
The human-readable description of the group.
Definition: stat_item.h:46
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.
Definition: stat_item.c:48
unsigned int num_values
number of values to store
Definition: stat_item.h:37
int32_t default_value
Definition: stat_item.h:38
int32_t value
Definition: stat_item.h:18
struct osmo_stat_item_value values[0]
value fifo
Definition: stat_item.h:29
const char * description
description of the item
Definition: stat_item.h:35
char name[32]
source file name
Definition: gsmtap.h:122
int osmo_stat_item_init(void *tall_ctx)
Initialize the stat item module.
Definition: stat_item.c:192
const char * unit
unit of a value
Definition: stat_item.h:36
const unsigned int num_items
The number of values in this group.
Definition: stat_item.h:50
unsigned int idx
The index of this value group within its class.
Definition: stat_item.h:62
int32_t id
Definition: stat_item.h:17
int32_t last_value_index
the index of the freshest value
Definition: stat_item.h:25
const struct osmo_stat_item_desc * desc
Definition: stat_item.h:23
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.
Definition: stat_item.c:136
struct osmo_stat_item_group * osmo_stat_item_get_group_by_name_idx(const char *name, const unsigned int idx)
Search for item group based on group name and index.
Definition: stat_item.c:200
struct llist_head list
Linked list of all value groups in the system.
Definition: stat_item.h:58
const char * group_name_prefix
The prefix to the name of all values in this group.
Definition: stat_item.h:44
struct osmo_stat_item * items[0]
Actual counter structures below.
Definition: stat_item.h:64
Simple doubly linked list implementation.
int osmo_stat_item_for_each_group(osmo_stat_item_group_handler_t handle_group, void *data)
Definition: stat_item.c:252
(double) linked list header structure
Definition: linuxlist.h:46
int16_t last_offs
offset to the freshest value in the value fifo
Definition: stat_item.h:27
int(* osmo_stat_item_group_handler_t)(struct osmo_stat_item_group *, void *)
Definition: stat_item.h:120
One instance of a counter group class.
Definition: stat_item.h:56
const struct osmo_stat_item * osmo_stat_item_get_by_name(const struct osmo_stat_item_group *statg, const char *name)
Search for item group based on group name.
Definition: stat_item.c:217
const char * name
name of the item
Definition: stat_item.h:34
data we keep for each actual value
Definition: stat_item.h:22
const struct osmo_stat_item_desc * item_desc
Pointer to array of value names.
Definition: stat_item.h:52
int(* osmo_stat_item_handler_t)(struct osmo_stat_item_group *, struct osmo_stat_item *, void *)
Definition: stat_item.h:117
static int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item)
Get the last (freshest) value.
Definition: stat_item.h:131
Definition: stat_item.h:16
static void osmo_stat_item_group_udp_idx(struct osmo_stat_item_group *grp, unsigned int idx)
Definition: stat_item.h:72
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.
Definition: stat_item.c:236
void osmo_stat_item_group_free(struct osmo_stat_item_group *statg)
Free the memory for the specified group of counters.
Definition: stat_item.c:116
statistics value description
Definition: stat_item.h:33
int osmo_stat_item_discard_all(int32_t *idx)
Skip all values of all items and update idx accordingly.
Definition: stat_item.c:183