summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gb/gprs_ns.c8
-rw-r--r--src/stat_item.c62
-rw-r--r--src/stats.c214
-rw-r--r--src/vty/stats_vty.c80
-rw-r--r--src/vty/utils.c16
5 files changed, 190 insertions, 190 deletions
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index afc62497..5025d575 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -135,11 +135,11 @@ enum ns_stat {
NS_STAT_ALIVE_DELAY,
};
-static const struct stat_item_desc nsvc_stat_description[] = {
+static const struct osmo_stat_item_desc nsvc_stat_description[] = {
{ "alive.delay", "ALIVE reponse time ", "ms", 16, 0 },
};
-static const struct stat_item_group_desc nsvc_statg_desc = {
+static const struct osmo_stat_item_group_desc nsvc_statg_desc = {
.group_name_prefix = "ns.nsvc",
.group_description = "NSVC Peer Statistics",
.num_items = ARRAY_SIZE(nsvc_stat_description),
@@ -238,7 +238,7 @@ struct gprs_nsvc *gprs_nsvc_create(struct gprs_ns_inst *nsi, uint16_t nsvci)
nsvc->timer.cb = gprs_ns_timer_cb;
nsvc->timer.data = nsvc;
nsvc->ctrg = rate_ctr_group_alloc(nsvc, &nsvc_ctrg_desc, nsvci);
- nsvc->statg = stat_item_group_alloc(nsvc, &nsvc_statg_desc, nsvci);
+ nsvc->statg = osmo_stat_item_group_alloc(nsvc, &nsvc_statg_desc, nsvci);
llist_add(&nsvc->list, &nsi->gprs_nsvcs);
@@ -1306,7 +1306,7 @@ int gprs_ns_process_msg(struct gprs_ns_inst *nsi, struct msgb *msg,
break;
case NS_PDUT_ALIVE_ACK:
if ((*nsvc)->timer_mode == NSVC_TIMER_TNS_ALIVE)
- stat_item_set((*nsvc)->statg->items[NS_STAT_ALIVE_DELAY],
+ osmo_stat_item_set((*nsvc)->statg->items[NS_STAT_ALIVE_DELAY],
nsvc_timer_elapsed_ms(*nsvc));
/* stop Tns-alive and start Tns-test */
nsvc_start_timer(*nsvc, NSVC_TIMER_TNS_TEST);
diff --git a/src/stat_item.c b/src/stat_item.c
index 525a94b9..0545ea0d 100644
--- a/src/stat_item.c
+++ b/src/stat_item.c
@@ -21,7 +21,7 @@
*
*/
-/*! \addtogroup stat_item
+/*! \addtogroup osmo_stat_item
* @{
*/
@@ -37,7 +37,7 @@
#include <osmocom/core/timer.h>
#include <osmocom/core/stat_item.h>
-static LLIST_HEAD(stat_item_groups);
+static LLIST_HEAD(osmo_stat_item_groups);
static int32_t global_value_id = 0;
static void *tall_stat_item_ctx;
@@ -47,8 +47,8 @@ static void *tall_stat_item_ctx;
* \param[in] desc Statistics item group description
* \param[in] idx Index of new stat item group
*/
-struct stat_item_group *stat_item_group_alloc(void *ctx,
- const struct stat_item_group_desc *desc,
+struct osmo_stat_item_group *osmo_stat_item_group_alloc(void *ctx,
+ const struct osmo_stat_item_group_desc *desc,
unsigned int idx)
{
unsigned int group_size;
@@ -56,10 +56,10 @@ struct stat_item_group *stat_item_group_alloc(void *ctx,
unsigned int item_idx;
void *items;
- struct stat_item_group *group;
+ struct osmo_stat_item_group *group;
- group_size = sizeof(struct stat_item_group) +
- desc->num_items * sizeof(struct stat_item *);
+ group_size = sizeof(struct osmo_stat_item_group) +
+ desc->num_items * sizeof(struct osmo_stat_item *);
if (!ctx)
ctx = tall_stat_item_ctx;
@@ -74,8 +74,8 @@ struct stat_item_group *stat_item_group_alloc(void *ctx,
/* Get combined size of all items */
for (item_idx = 0; item_idx < desc->num_items; item_idx++) {
unsigned int size;
- size = sizeof(struct stat_item) +
- sizeof(struct stat_item_value) *
+ size = sizeof(struct osmo_stat_item) +
+ sizeof(struct osmo_stat_item_value) *
desc->item_desc[item_idx].num_values;
/* Align to pointer size */
size = (size + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
@@ -94,7 +94,7 @@ struct stat_item_group *stat_item_group_alloc(void *ctx,
/* Update item pointers */
for (item_idx = 0; item_idx < desc->num_items; item_idx++) {
- struct stat_item *item = (struct stat_item *)
+ struct osmo_stat_item *item = (struct osmo_stat_item *)
((uint8_t *)items + (int)group->items[item_idx]);
unsigned int i;
@@ -109,19 +109,19 @@ struct stat_item_group *stat_item_group_alloc(void *ctx,
}
}
- llist_add(&group->list, &stat_item_groups);
+ llist_add(&group->list, &osmo_stat_item_groups);
return group;
}
/*! \brief Free the memory for the specified group of counters */
-void stat_item_group_free(struct stat_item_group *grp)
+void osmo_stat_item_group_free(struct osmo_stat_item_group *grp)
{
llist_del(&grp->list);
talloc_free(grp);
}
-void stat_item_set(struct stat_item *item, int32_t value)
+void osmo_stat_item_set(struct osmo_stat_item *item, int32_t value)
{
item->last_offs += 1;
if (item->last_offs >= item->desc->num_values)
@@ -135,11 +135,11 @@ void stat_item_set(struct stat_item *item, int32_t value)
item->values[item->last_offs].id = global_value_id;
}
-int stat_item_get_next(const struct stat_item *item, int32_t *next_idx,
+int osmo_stat_item_get_next(const struct osmo_stat_item *item, int32_t *next_idx,
int32_t *value)
{
- const struct stat_item_value *next_value;
- const struct stat_item_value *item_value = NULL;
+ const struct osmo_stat_item_value *next_value;
+ const struct osmo_stat_item_value *item_value = NULL;
int idx_delta;
int next_offs;
@@ -173,7 +173,7 @@ int stat_item_get_next(const struct stat_item *item, int32_t *next_idx,
}
/*! \brief Skip all values of this item and update idx accordingly */
-int stat_item_discard(const struct stat_item *item, int32_t *idx)
+int osmo_stat_item_discard(const struct osmo_stat_item *item, int32_t *idx)
{
int discarded = item->values[item->last_offs].id + 1 - *idx;
*idx = item->values[item->last_offs].id + 1;
@@ -182,7 +182,7 @@ int stat_item_discard(const struct stat_item *item, int32_t *idx)
}
/*! \brief Skip all values of all items and update idx accordingly */
-int stat_item_discard_all(int32_t *idx)
+int osmo_stat_item_discard_all(int32_t *idx)
{
int discarded = global_value_id + 1 - *idx;
*idx = global_value_id + 1;
@@ -191,7 +191,7 @@ int stat_item_discard_all(int32_t *idx)
}
/*! \brief Initialize the stat item module */
-int stat_item_init(void *tall_ctx)
+int osmo_stat_item_init(void *tall_ctx)
{
tall_stat_item_ctx = tall_ctx;
@@ -199,12 +199,12 @@ int stat_item_init(void *tall_ctx)
}
/*! \brief Search for item group based on group name and index */
-struct stat_item_group *stat_item_get_group_by_name_idx(
+struct osmo_stat_item_group *osmo_stat_item_get_group_by_name_idx(
const char *name, const unsigned int idx)
{
- struct stat_item_group *statg;
+ struct osmo_stat_item_group *statg;
- llist_for_each_entry(statg, &stat_item_groups, list) {
+ llist_for_each_entry(statg, &osmo_stat_item_groups, list) {
if (!statg->desc)
continue;
@@ -216,11 +216,11 @@ struct stat_item_group *stat_item_get_group_by_name_idx(
}
/*! \brief Search for item group based on group name */
-const struct stat_item *stat_item_get_by_name(
- const struct stat_item_group *statg, const char *name)
+const struct osmo_stat_item *osmo_stat_item_get_by_name(
+ const struct osmo_stat_item_group *statg, const char *name)
{
int i;
- const struct stat_item_desc *item_desc;
+ const struct osmo_stat_item_desc *item_desc;
if (!statg->desc)
return NULL;
@@ -235,14 +235,14 @@ const struct stat_item *stat_item_get_by_name(
return NULL;
}
-int stat_item_for_each_item(struct stat_item_group *statg,
- stat_item_handler_t handle_item, void *data)
+int osmo_stat_item_for_each_item(struct osmo_stat_item_group *statg,
+ osmo_stat_item_handler_t handle_item, void *data)
{
int rc = 0;
int i;
for (i = 0; i < statg->desc->num_items; i++) {
- struct stat_item *item = statg->items[i];
+ struct osmo_stat_item *item = statg->items[i];
rc = handle_item(statg, item, data);
if (rc < 0)
return rc;
@@ -251,12 +251,12 @@ int stat_item_for_each_item(struct stat_item_group *statg,
return rc;
}
-int stat_item_for_each_group(stat_item_group_handler_t handle_group, void *data)
+int osmo_stat_item_for_each_group(osmo_stat_item_group_handler_t handle_group, void *data)
{
- struct stat_item_group *statg;
+ struct osmo_stat_item_group *statg;
int rc = 0;
- llist_for_each_entry(statg, &stat_item_groups, list) {
+ llist_for_each_entry(statg, &osmo_stat_item_groups, list) {
rc = handle_group(statg, data);
if (rc < 0)
return rc;
diff --git a/src/stats.c b/src/stats.c
index 5027a621..155f8a2c 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -46,41 +46,41 @@
#define STATS_DEFAULT_INTERVAL 5 /* secs */
#define STATS_DEFAULT_STATSD_BUFLEN 256
-static LLIST_HEAD(stats_reporter_list);
-static void *stats_ctx = NULL;
+static LLIST_HEAD(osmo_stats_reporter_list);
+static void *osmo_stats_ctx = NULL;
static int is_initialised = 0;
static int32_t current_stat_item_index = 0;
-static struct stats_config s_stats_config = {
+static struct osmo_stats_config s_stats_config = {
.interval = STATS_DEFAULT_INTERVAL,
};
-struct stats_config *stats_config = &s_stats_config;
+struct osmo_stats_config *osmo_stats_config = &s_stats_config;
-static struct osmo_timer_list stats_timer;
+static struct osmo_timer_list osmo_stats_timer;
-static int stats_reporter_statsd_open(struct stats_reporter *srep);
-static int stats_reporter_statsd_close(struct stats_reporter *srep);
-static int stats_reporter_statsd_send_counter(struct stats_reporter *srep,
+static int osmo_stats_reporter_statsd_open(struct osmo_stats_reporter *srep);
+static int osmo_stats_reporter_statsd_close(struct osmo_stats_reporter *srep);
+static int osmo_stats_reporter_statsd_send_counter(struct osmo_stats_reporter *srep,
const struct rate_ctr_group *ctrg,
const struct rate_ctr_desc *desc,
int64_t value, int64_t delta);
-static int stats_reporter_statsd_send_item(struct stats_reporter *srep,
- const struct stat_item_group *statg,
- const struct stat_item_desc *desc, int value);
+static int osmo_stats_reporter_statsd_send_item(struct osmo_stats_reporter *srep,
+ const struct osmo_stat_item_group *statg,
+ const struct osmo_stat_item_desc *desc, int value);
-static int stats_reporter_log_send_counter(struct stats_reporter *srep,
+static int osmo_stats_reporter_log_send_counter(struct osmo_stats_reporter *srep,
const struct rate_ctr_group *ctrg,
const struct rate_ctr_desc *desc,
int64_t value, int64_t delta);
-static int stats_reporter_log_send_item(struct stats_reporter *srep,
- const struct stat_item_group *statg,
- const struct stat_item_desc *desc, int value);
+static int osmo_stats_reporter_log_send_item(struct osmo_stats_reporter *srep,
+ const struct osmo_stat_item_group *statg,
+ const struct osmo_stat_item_desc *desc, int value);
-static int stats_reporter_send(struct stats_reporter *srep, const char *data,
+static int osmo_stats_reporter_send(struct osmo_stats_reporter *srep, const char *data,
int data_len);
-static int stats_reporter_send_buffer(struct stats_reporter *srep);
+static int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep);
-static int update_srep_config(struct stats_reporter *srep)
+static int update_srep_config(struct osmo_stats_reporter *srep)
{
int rc = 0;
@@ -106,14 +106,14 @@ static int update_srep_config(struct stats_reporter *srep)
return rc;
}
-static void stats_timer_cb(void *data)
+static void osmo_stats_timer_cb(void *data)
{
- int interval = stats_config->interval;
+ int interval = osmo_stats_config->interval;
- if (!llist_empty(&stats_reporter_list))
- stats_report();
+ if (!llist_empty(&osmo_stats_reporter_list))
+ osmo_stats_report();
- osmo_timer_schedule(&stats_timer, interval, 0);
+ osmo_timer_schedule(&osmo_stats_timer, interval, 0);
}
static int start_timer()
@@ -121,49 +121,49 @@ static int start_timer()
if (!is_initialised)
return -ESRCH;
- stats_timer.cb = stats_timer_cb;
- osmo_timer_schedule(&stats_timer, 0, 1);
+ osmo_stats_timer.cb = osmo_stats_timer_cb;
+ osmo_timer_schedule(&osmo_stats_timer, 0, 1);
return 0;
}
-struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type,
+struct osmo_stats_reporter *osmo_stats_reporter_alloc(enum osmo_stats_reporter_type type,
const char *name)
{
- struct stats_reporter *srep;
- srep = talloc_zero(stats_ctx, struct stats_reporter);
+ struct osmo_stats_reporter *srep;
+ srep = talloc_zero(osmo_stats_ctx, struct osmo_stats_reporter);
OSMO_ASSERT(srep);
srep->type = type;
if (name)
srep->name = talloc_strdup(srep, name);
srep->fd = -1;
- llist_add(&srep->list, &stats_reporter_list);
+ llist_add(&srep->list, &osmo_stats_reporter_list);
return srep;
}
-void stats_reporter_free(struct stats_reporter *srep)
+void osmo_stats_reporter_free(struct osmo_stats_reporter *srep)
{
- stats_reporter_disable(srep);
+ osmo_stats_reporter_disable(srep);
llist_del(&srep->list);
talloc_free(srep);
}
-void stats_init(void *ctx)
+void osmo_stats_init(void *ctx)
{
- stats_ctx = ctx;
- stat_item_discard_all(&current_stat_item_index);
+ osmo_stats_ctx = ctx;
+ osmo_stat_item_discard_all(&current_stat_item_index);
is_initialised = 1;
start_timer();
}
-struct stats_reporter *stats_reporter_find(enum stats_reporter_type type,
+struct osmo_stats_reporter *osmo_stats_reporter_find(enum osmo_stats_reporter_type type,
const char *name)
{
- struct stats_reporter *srep;
- llist_for_each_entry(srep, &stats_reporter_list, list) {
+ struct osmo_stats_reporter *srep;
+ llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
if (srep->type != type)
continue;
if (srep->name != name) {
@@ -176,7 +176,7 @@ struct stats_reporter *stats_reporter_find(enum stats_reporter_type type,
return NULL;
}
-int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr)
+int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const char *addr)
{
int rc;
struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->dest_addr;
@@ -201,7 +201,7 @@ int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr
return update_srep_config(srep);
}
-int stats_reporter_set_remote_port(struct stats_reporter *srep, int port)
+int osmo_stats_reporter_set_remote_port(struct osmo_stats_reporter *srep, int port)
{
struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->dest_addr;
@@ -214,7 +214,7 @@ int stats_reporter_set_remote_port(struct stats_reporter *srep, int port)
return update_srep_config(srep);
}
-int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr)
+int osmo_stats_reporter_set_local_addr(struct osmo_stats_reporter *srep, const char *addr)
{
int rc;
struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->bind_addr;
@@ -241,7 +241,7 @@ int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr)
return update_srep_config(srep);
}
-int stats_reporter_set_mtu(struct stats_reporter *srep, int mtu)
+int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu)
{
if (!srep->have_net_config)
return -ENOTSUP;
@@ -254,19 +254,19 @@ int stats_reporter_set_mtu(struct stats_reporter *srep, int mtu)
return update_srep_config(srep);
}
-int stats_set_interval(int interval)
+int osmo_stats_set_interval(int interval)
{
if (interval <= 0)
return -EINVAL;
- stats_config->interval = interval;
+ osmo_stats_config->interval = interval;
if (is_initialised)
start_timer();
return 0;
}
-int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix)
+int osmo_stats_reporter_set_name_prefix(struct osmo_stats_reporter *srep, const char *prefix)
{
talloc_free(srep->name_prefix);
srep->name_prefix = prefix ? talloc_strdup(srep, prefix) : NULL;
@@ -274,21 +274,21 @@ int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *pref
return update_srep_config(srep);
}
-int stats_reporter_enable(struct stats_reporter *srep)
+int osmo_stats_reporter_enable(struct osmo_stats_reporter *srep)
{
srep->enabled = 1;
return update_srep_config(srep);
}
-int stats_reporter_disable(struct stats_reporter *srep)
+int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep)
{
srep->enabled = 0;
return update_srep_config(srep);
}
-static int stats_reporter_send(struct stats_reporter *srep, const char *data,
+static int osmo_stats_reporter_send(struct osmo_stats_reporter *srep, const char *data,
int data_len)
{
int rc;
@@ -302,14 +302,14 @@ static int stats_reporter_send(struct stats_reporter *srep, const char *data,
return rc;
}
-static int stats_reporter_send_buffer(struct stats_reporter *srep)
+static int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep)
{
int rc;
if (!srep->buffer || msgb_length(srep->buffer) == 0)
return 0;
- rc = stats_reporter_send(srep,
+ rc = osmo_stats_reporter_send(srep,
(const char *)msgb_data(srep->buffer), msgb_length(srep->buffer));
msgb_trim(srep->buffer, 0);
@@ -319,20 +319,20 @@ static int stats_reporter_send_buffer(struct stats_reporter *srep)
/*** log reporter ***/
-struct stats_reporter *stats_reporter_create_log(const char *name)
+struct osmo_stats_reporter *osmo_stats_reporter_create_log(const char *name)
{
- struct stats_reporter *srep;
- srep = stats_reporter_alloc(STATS_REPORTER_LOG, name);
+ struct osmo_stats_reporter *srep;
+ srep = osmo_stats_reporter_alloc(OSMO_STATS_REPORTER_LOG, name);
srep->have_net_config = 0;
- srep->send_counter = stats_reporter_log_send_counter;
- srep->send_item = stats_reporter_log_send_item;
+ srep->send_counter = osmo_stats_reporter_log_send_counter;
+ srep->send_item = osmo_stats_reporter_log_send_item;
return srep;
}
-static int stats_reporter_log_send(struct stats_reporter *srep,
+static int osmo_stats_reporter_log_send(struct osmo_stats_reporter *srep,
const char *type,
const char *name1, int index1, const char *name2, int value,
const char *unit)
@@ -347,56 +347,56 @@ static int stats_reporter_log_send(struct stats_reporter *srep,
}
-static int stats_reporter_log_send_counter(struct stats_reporter *srep,
+static int osmo_stats_reporter_log_send_counter(struct osmo_stats_reporter *srep,
const struct rate_ctr_group *ctrg,
const struct rate_ctr_desc *desc,
int64_t value, int64_t delta)
{
if (ctrg)
- return stats_reporter_log_send(srep, "c",
+ return osmo_stats_reporter_log_send(srep, "c",
ctrg->desc->group_name_prefix,
ctrg->idx,
desc->name, value, NULL);
else
- return stats_reporter_log_send(srep, "c",
+ return osmo_stats_reporter_log_send(srep, "c",
NULL, -1,
desc->name, value, NULL);
}
-static int stats_reporter_log_send_item(struct stats_reporter *srep,
- const struct stat_item_group *statg,
- const struct stat_item_desc *desc, int value)
+static int osmo_stats_reporter_log_send_item(struct osmo_stats_reporter *srep,
+ const struct osmo_stat_item_group *statg,
+ const struct osmo_stat_item_desc *desc, int value)
{
- return stats_reporter_log_send(srep, "i",
+ return osmo_stats_reporter_log_send(srep, "i",
statg->desc->group_name_prefix, statg->idx,
desc->name, value, desc->unit);
}
/*** statsd reporter ***/
-struct stats_reporter *stats_reporter_create_statsd(const char *name)
+struct osmo_stats_reporter *osmo_stats_reporter_create_statsd(const char *name)
{
- struct stats_reporter *srep;
- srep = stats_reporter_alloc(STATS_REPORTER_STATSD, name);
+ struct osmo_stats_reporter *srep;
+ srep = osmo_stats_reporter_alloc(OSMO_STATS_REPORTER_STATSD, name);
srep->have_net_config = 1;
- srep->open = stats_reporter_statsd_open;
- srep->close = stats_reporter_statsd_close;
- srep->send_counter = stats_reporter_statsd_send_counter;
- srep->send_item = stats_reporter_statsd_send_item;
+ srep->open = osmo_stats_reporter_statsd_open;
+ srep->close = osmo_stats_reporter_statsd_close;
+ srep->send_counter = osmo_stats_reporter_statsd_send_counter;
+ srep->send_item = osmo_stats_reporter_statsd_send_item;
return srep;
}
-static int stats_reporter_statsd_open(struct stats_reporter *srep)
+static int osmo_stats_reporter_statsd_open(struct osmo_stats_reporter *srep)
{
int sock;
int rc;
int buffer_size = STATS_DEFAULT_STATSD_BUFLEN;
if (srep->fd != -1)
- stats_reporter_statsd_close(srep);
+ osmo_stats_reporter_statsd_close(srep);
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == -1)
@@ -426,13 +426,13 @@ failed:
return rc;
}
-static int stats_reporter_statsd_close(struct stats_reporter *srep)
+static int osmo_stats_reporter_statsd_close(struct osmo_stats_reporter *srep)
{
int rc;
if (srep->fd == -1)
return -EBADF;
- stats_reporter_send_buffer(srep);
+ osmo_stats_reporter_send_buffer(srep);
rc = close(srep->fd);
srep->fd = -1;
@@ -441,7 +441,7 @@ static int stats_reporter_statsd_close(struct stats_reporter *srep)
return rc == -1 ? -errno : 0;
}
-static int stats_reporter_statsd_send(struct stats_reporter *srep,
+static int osmo_stats_reporter_statsd_send(struct osmo_stats_reporter *srep,
const char *name1, int index1, const char *name2, int value,
const char *unit)
{
@@ -482,7 +482,7 @@ static int stats_reporter_statsd_send(struct stats_reporter *srep,
/* Restore original buffer (without trailing LF) */
msgb_trim(srep->buffer, old_len);
/* Send it */
- rc = stats_reporter_send_buffer(srep);
+ rc = osmo_stats_reporter_send_buffer(srep);
/* Try again */
buf = (char *)msgb_put(srep->buffer, 0);
@@ -500,39 +500,39 @@ static int stats_reporter_statsd_send(struct stats_reporter *srep,
msgb_trim(srep->buffer, msgb_length(srep->buffer) + nchars);
if (!srep->agg_enabled)
- rc = stats_reporter_send_buffer(srep);
+ rc = osmo_stats_reporter_send_buffer(srep);
return rc;
}
-static int stats_reporter_statsd_send_counter(struct stats_reporter *srep,
+static int osmo_stats_reporter_statsd_send_counter(struct osmo_stats_reporter *srep,
const struct rate_ctr_group *ctrg,
const struct rate_ctr_desc *desc,
int64_t value, int64_t delta)
{
if (ctrg)
- return stats_reporter_statsd_send(srep,
+ return osmo_stats_reporter_statsd_send(srep,
ctrg->desc->group_name_prefix,
ctrg->idx,
desc->name, delta, "c");
else
- return stats_reporter_statsd_send(srep,
+ return osmo_stats_reporter_statsd_send(srep,
NULL, -1,
desc->name, delta, "c");
}
-static int stats_reporter_statsd_send_item(struct stats_reporter *srep,
- const struct stat_item_group *statg,
- const struct stat_item_desc *desc, int value)
+static int osmo_stats_reporter_statsd_send_item(struct osmo_stats_reporter *srep,
+ const struct osmo_stat_item_group *statg,
+ const struct osmo_stat_item_desc *desc, int value)
{
- return stats_reporter_statsd_send(srep,
+ return osmo_stats_reporter_statsd_send(srep,
statg->desc->group_name_prefix, statg->idx,
desc->name, value, desc->unit);
}
/*** generic rate counter support ***/
-static int stats_reporter_send_counter(struct stats_reporter *srep,
+static int osmo_stats_reporter_send_counter(struct osmo_stats_reporter *srep,
const struct rate_ctr_group *ctrg,
const struct rate_ctr_desc *desc,
int64_t value, int64_t delta)
@@ -547,18 +547,18 @@ static int rate_ctr_handler(
struct rate_ctr_group *ctrg, struct rate_ctr *ctr,
const struct rate_ctr_desc *desc, void *sctx_)
{
- struct stats_reporter *srep;
+ struct osmo_stats_reporter *srep;
int rc;
int64_t delta = rate_ctr_difference(ctr);
if (delta == 0)
return 0;
- llist_for_each_entry(srep, &stats_reporter_list, list) {
+ llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
if (!srep->running)
continue;
- rc = stats_reporter_send_counter(srep, ctrg, desc,
+ rc = osmo_stats_reporter_send_counter(srep, ctrg, desc,
ctr->current, delta);
/* TODO: handle rc (log?, inc counter(!)?) or remove it */
@@ -576,9 +576,9 @@ static int rate_ctr_group_handler(struct rate_ctr_group *ctrg, void *sctx_)
/*** stat item support ***/
-static int stats_reporter_send_item(struct stats_reporter *srep,
- const struct stat_item_group *statg,
- const struct stat_item_desc *desc,
+static int osmo_stats_reporter_send_item(struct osmo_stats_reporter *srep,
+ const struct osmo_stat_item_group *statg,
+ const struct osmo_stat_item_desc *desc,
int32_t value)
{
if (!srep->send_item)
@@ -587,20 +587,20 @@ static int stats_reporter_send_item(struct stats_reporter *srep,
return srep->send_item(srep, statg, desc, value);
}
-static int stat_item_handler(
- struct stat_item_group *statg, struct stat_item *item, void *sctx_)
+static int osmo_stat_item_handler(
+ struct osmo_stat_item_group *statg, struct osmo_stat_item *item, void *sctx_)
{
- struct stats_reporter *srep;
+ struct osmo_stats_reporter *srep;
int rc;
int32_t idx = current_stat_item_index;
int32_t value;
- while (stat_item_get_next(item, &idx, &value) > 0) {
- llist_for_each_entry(srep, &stats_reporter_list, list) {
+ while (osmo_stat_item_get_next(item, &idx, &value) > 0) {
+ llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
if (!srep->running)
continue;
- rc = stats_reporter_send_item(srep, statg,
+ rc = osmo_stats_reporter_send_item(srep, statg,
item->desc, value);
}
}
@@ -608,10 +608,10 @@ static int stat_item_handler(
return 0;
}
-static int stat_item_group_handler(struct stat_item_group *statg, void *sctx_)
+static int osmo_stat_item_group_handler(struct osmo_stat_item_group *statg, void *sctx_)
{
- stat_item_for_each_item(statg, stat_item_handler, sctx_);
- stat_item_discard_all(&current_stat_item_index);
+ osmo_stat_item_for_each_item(statg, osmo_stat_item_handler, sctx_);
+ osmo_stat_item_discard_all(&current_stat_item_index);
return 0;
}
@@ -620,7 +620,7 @@ static int stat_item_group_handler(struct stat_item_group *statg, void *sctx_)
static int handle_counter(struct osmo_counter *counter, void *sctx_)
{
- struct stats_reporter *srep;
+ struct osmo_stats_reporter *srep;
int rc;
struct rate_ctr_desc desc = {0};
/* Fake a rate counter description */
@@ -632,11 +632,11 @@ static int handle_counter(struct osmo_counter *counter, void *sctx_)
if (delta == 0)
return 0;
- llist_for_each_entry(srep, &stats_reporter_list, list) {
+ llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
if (!srep->running)
continue;
- rc = stats_reporter_send_counter(srep, NULL, &desc,
+ rc = osmo_stats_reporter_send_counter(srep, NULL, &desc,
counter->value, delta);
/* TODO: handle rc (log?, inc counter(!)?) */
@@ -650,21 +650,21 @@ static int handle_counter(struct osmo_counter *counter, void *sctx_)
static void flush_all_reporters()
{
- struct stats_reporter *srep;
+ struct osmo_stats_reporter *srep;
- llist_for_each_entry(srep, &stats_reporter_list, list) {
+ llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
if (!srep->running)
continue;
- stats_reporter_send_buffer(srep);
+ osmo_stats_reporter_send_buffer(srep);
}
}
-int stats_report()
+int osmo_stats_report()
{
osmo_counters_for_each(handle_counter, NULL);
rate_ctr_for_each_group(rate_ctr_group_handler, NULL);
- stat_item_for_each_group(stat_item_group_handler, NULL);
+ osmo_stat_item_for_each_group(osmo_stat_item_group_handler, NULL);
flush_all_reporters();
diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c
index 839dc829..f072b1ba 100644
--- a/src/vty/stats_vty.c
+++ b/src/vty/stats_vty.c
@@ -45,7 +45,7 @@ struct cmd_node cfg_stats_node = {
1
};
-static struct stats_reporter *osmo_stats_vty2srep(struct vty *vty)
+static struct osmo_stats_reporter *osmo_stats_vty2srep(struct vty *vty)
{
if (vty->node == CFG_STATS_NODE)
return vty->index;
@@ -54,11 +54,11 @@ static struct stats_reporter *osmo_stats_vty2srep(struct vty *vty)
}
static int set_srep_parameter_str(struct vty *vty,
- int (*fun)(struct stats_reporter *, const char *),
+ int (*fun)(struct osmo_stats_reporter *, const char *),
const char *val, const char *param_name)
{
int rc;
- struct stats_reporter *srep = osmo_stats_vty2srep(vty);
+ struct osmo_stats_reporter *srep = osmo_stats_vty2srep(vty);
OSMO_ASSERT(srep);
rc = fun(srep, val);
@@ -72,12 +72,12 @@ static int set_srep_parameter_str(struct vty *vty,
}
static int set_srep_parameter_int(struct vty *vty,
- int (*fun)(struct stats_reporter *, int),
+ int (*fun)(struct osmo_stats_reporter *, int),
const char *val, const char *param_name)
{
int rc;
int int_val;
- struct stats_reporter *srep = osmo_stats_vty2srep(vty);
+ struct osmo_stats_reporter *srep = osmo_stats_vty2srep(vty);
OSMO_ASSERT(srep);
int_val = atoi(val);
@@ -97,7 +97,7 @@ DEFUN(cfg_stats_reporter_local_ip, cfg_stats_reporter_local_ip_cmd,
"Set the IP address to which we bind locally\n"
"IP Address\n")
{
- return set_srep_parameter_str(vty, stats_reporter_set_local_addr,
+ return set_srep_parameter_str(vty, osmo_stats_reporter_set_local_addr,
argv[0], "local address");
}
@@ -106,7 +106,7 @@ DEFUN(cfg_no_stats_reporter_local_ip, cfg_no_stats_reporter_local_ip_cmd,
NO_STR
"Set the IP address to which we bind locally\n")
{
- return set_srep_parameter_str(vty, stats_reporter_set_local_addr,
+ return set_srep_parameter_str(vty, osmo_stats_reporter_set_local_addr,
NULL, "local address");
}
@@ -115,7 +115,7 @@ DEFUN(cfg_stats_reporter_remote_ip, cfg_stats_reporter_remote_ip_cmd,
"Set the remote IP address to which we connect\n"
"IP Address\n")
{
- return set_srep_parameter_str(vty, stats_reporter_set_remote_addr,
+ return set_srep_parameter_str(vty, osmo_stats_reporter_set_remote_addr,
argv[0], "remote address");
}
@@ -124,7 +124,7 @@ DEFUN(cfg_stats_reporter_remote_port, cfg_stats_reporter_remote_port_cmd,
"Set the remote port to which we connect\n"
"Remote port number\n")
{
- return set_srep_parameter_int(vty, stats_reporter_set_remote_port,
+ return set_srep_parameter_int(vty, osmo_stats_reporter_set_remote_port,
argv[0], "remote port");
}
@@ -133,7 +133,7 @@ DEFUN(cfg_stats_reporter_mtu, cfg_stats_reporter_mtu_cmd,
"Set the maximum packet size\n"
"Size in byte\n")
{
- return set_srep_parameter_int(vty, stats_reporter_set_mtu,
+ return set_srep_parameter_int(vty, osmo_stats_reporter_set_mtu,
argv[0], "mtu");
}
@@ -141,7 +141,7 @@ DEFUN(cfg_no_stats_reporter_mtu, cfg_no_stats_reporter_mtu_cmd,
"no mtu",
NO_STR "Set the maximum packet size\n")
{
- return set_srep_parameter_int(vty, stats_reporter_set_mtu,
+ return set_srep_parameter_int(vty, osmo_stats_reporter_set_mtu,
0, "mtu");
}
@@ -150,7 +150,7 @@ DEFUN(cfg_stats_reporter_prefix, cfg_stats_reporter_prefix_cmd,
"Set the item name prefix\n"
"The prefix string\n")
{
- return set_srep_parameter_str(vty, stats_reporter_set_name_prefix,
+ return set_srep_parameter_str(vty, osmo_stats_reporter_set_name_prefix,
argv[0], "prefix string");
}
@@ -159,7 +159,7 @@ DEFUN(cfg_no_stats_reporter_prefix, cfg_no_stats_reporter_prefix_cmd,
NO_STR
"Set the item name prefix\n")
{
- return set_srep_parameter_str(vty, stats_reporter_set_name_prefix,
+ return set_srep_parameter_str(vty, osmo_stats_reporter_set_name_prefix,
"", "prefix string");
}
@@ -168,10 +168,10 @@ DEFUN(cfg_stats_reporter_enable, cfg_stats_reporter_enable_cmd,
"Enable the reporter\n")
{
int rc;
- struct stats_reporter *srep = osmo_stats_vty2srep(vty);
+ struct osmo_stats_reporter *srep = osmo_stats_vty2srep(vty);
OSMO_ASSERT(srep);
- rc = stats_reporter_enable(srep);
+ rc = osmo_stats_reporter_enable(srep);
if (rc < 0) {
vty_out(vty, "%% Unable to enable the reporter: %s%s",
strerror(-rc), VTY_NEWLINE);
@@ -186,10 +186,10 @@ DEFUN(cfg_stats_reporter_disable, cfg_stats_reporter_disable_cmd,
"Disable the reporter\n")
{
int rc;
- struct stats_reporter *srep = osmo_stats_vty2srep(vty);
+ struct osmo_stats_reporter *srep = osmo_stats_vty2srep(vty);
OSMO_ASSERT(srep);
- rc = stats_reporter_disable(srep);
+ rc = osmo_stats_reporter_disable(srep);
if (rc < 0) {
vty_out(vty, "%% Unable to disable the reporter: %s%s",
strerror(-rc), VTY_NEWLINE);
@@ -203,17 +203,17 @@ DEFUN(cfg_stats_reporter_statsd, cfg_stats_reporter_statsd_cmd,
"stats reporter statsd",
CFG_STATS_STR CFG_REPORTER_STR "Report to a STATSD server\n")
{
- struct stats_reporter *srep;
+ struct osmo_stats_reporter *srep;
- srep = stats_reporter_find(STATS_REPORTER_STATSD, NULL);
+ srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_STATSD, NULL);
if (!srep) {
- srep = stats_reporter_create_statsd(NULL);
+ srep = osmo_stats_reporter_create_statsd(NULL);
if (!srep) {
vty_out(vty, "%% Unable to create statsd reporter%s",
VTY_NEWLINE);
return CMD_WARNING;
}
- /* TODO: if needed, add stats_add_reporter(srep); */
+ /* TODO: if needed, add osmo_stats_add_reporter(srep); */
}
vty->index = srep;
@@ -229,7 +229,7 @@ DEFUN(cfg_stats_interval, cfg_stats_interval_cmd,
{
int rc;
int interval = atoi(argv[0]);
- rc = stats_set_interval(interval);
+ rc = osmo_stats_set_interval(interval);
if (rc < 0) {
vty_out(vty, "%% Unable to set interval: %s%s",
strerror(-rc), VTY_NEWLINE);
@@ -244,16 +244,16 @@ DEFUN(cfg_no_stats_reporter_statsd, cfg_no_stats_reporter_statsd_cmd,
"no stats reporter statsd",
NO_STR CFG_STATS_STR CFG_REPORTER_STR "Report to a STATSD server\n")
{
- struct stats_reporter *srep;
+ struct osmo_stats_reporter *srep;
- srep = stats_reporter_find(STATS_REPORTER_STATSD, NULL);
+ srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_STATSD, NULL);
if (!srep) {
vty_out(vty, "%% No statsd logging active%s",
VTY_NEWLINE);
return CMD_WARNING;
}
- stats_reporter_free(srep);
+ osmo_stats_reporter_free(srep);
return CMD_SUCCESS;
}
@@ -262,17 +262,17 @@ DEFUN(cfg_stats_reporter_log, cfg_stats_reporter_log_cmd,
"stats reporter log",
CFG_STATS_STR CFG_REPORTER_STR "Report to the logger\n")
{
- struct stats_reporter *srep;
+ struct osmo_stats_reporter *srep;
- srep = stats_reporter_find(STATS_REPORTER_LOG, NULL);
+ srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_LOG, NULL);
if (!srep) {
- srep = stats_reporter_create_log(NULL);
+ srep = osmo_stats_reporter_create_log(NULL);
if (!srep) {
vty_out(vty, "%% Unable to create log reporter%s",
VTY_NEWLINE);
return CMD_WARNING;
}
- /* TODO: if needed, add stats_add_reporter(srep); */
+ /* TODO: if needed, add osmo_stats_add_reporter(srep); */
}
vty->index = srep;
@@ -285,16 +285,16 @@ DEFUN(cfg_no_stats_reporter_log, cfg_no_stats_reporter_log_cmd,
"no stats reporter log",
NO_STR CFG_STATS_STR CFG_REPORTER_STR "Report to the logger\n")
{
- struct stats_reporter *srep;
+ struct osmo_stats_reporter *srep;
- srep = stats_reporter_find(STATS_REPORTER_LOG, NULL);
+ srep = osmo_stats_reporter_find(OSMO_STATS_REPORTER_LOG, NULL);
if (!srep) {
vty_out(vty, "%% No log reporting active%s",
VTY_NEWLINE);
return CMD_WARNING;
}
- stats_reporter_free(srep);
+ osmo_stats_reporter_free(srep);
return CMD_SUCCESS;
}
@@ -309,16 +309,16 @@ DEFUN(show_stats,
return CMD_SUCCESS;
}
-static int config_write_stats_reporter(struct vty *vty, struct stats_reporter *srep)
+static int config_write_stats_reporter(struct vty *vty, struct osmo_stats_reporter *srep)
{
if (srep == NULL)
return 0;