libosmocore 1.11.0.30-c17053.202507072026
Osmocom core library
|
This module implements periodic reporting of statistics / counters. More...
Files | |
file | stats.h |
file | stats.c |
file | stats_statsd.c |
file | stats_tcp.c |
Data Structures | |
struct | osmo_stats_reporter |
One statistics reporter instance. More... | |
struct | osmo_stats_config |
struct | stats_tcp_entry |
Macros | |
#define | TRACE(probe) |
#define | TRACE_ENABLED(probe) (0) |
#define | STATS_DEFAULT_INTERVAL 5 /* secs */ |
#define | STATS_DEFAULT_BUFLEN 256 |
Enumerations | |
enum | osmo_stats_class { OSMO_STATS_CLASS_UNKNOWN , OSMO_STATS_CLASS_GLOBAL , OSMO_STATS_CLASS_PEER , OSMO_STATS_CLASS_SUBSCRIBER } |
Statistics Class definitions. More... | |
enum | osmo_stats_reporter_type { OSMO_STATS_REPORTER_LOG , OSMO_STATS_REPORTER_STATSD } |
Statistics Reporter Type. More... | |
enum | { STATS_TCP_UNACKED , STATS_TCP_LOST , STATS_TCP_RETRANS , STATS_TCP_RTT , STATS_TCP_RCV_RTT , STATS_TCP_NOTSENT_BYTES , STATS_TCP_RWND_LIMITED , STATS_TCP_SNDBUF_LIMITED , STATS_TCP_REORD_SEEN } |
This module implements periodic reporting of statistics / counters.
It supports the notion of multiple osmo_stats_reporter objects which independently of each other can report statistics at different configurable intervals to different destinations.
In order to use this facility, you have to call osmo_stats_init() once at application start-up and then create one or more osmo_stats_reporter, either using the direct API functions or by using the optional VTY bindings:
You can either use the above API functions directly to create osmo_stats_reporter instances, or you can use the VTY support contained in libosmovty. See the "stats" configuration node installed by osmo_stats_vty_Add_cmds().
An osmo_stats_reporter reports statistics on all of the following libosmocore internal counter/statistics objects:
You do not need to do anything in particular to expose a given counter or stat_item, they are all exported automatically via any osmo_stats_reporter. If you have multiple osmo_stats_reporter, they will each report all counters/stat_items.
#define STATS_DEFAULT_BUFLEN 256 |
|
static |
|
static |
References osmo_fd::fd, stats_tcp_entry::fd, stats_tcp_entry::name, OSMO_ASSERT, osmo_sock_get_ip_and_port(), osmo_sock_get_name2(), osmo_stat_item_group_alloc(), osmo_stat_item_group_get_item(), osmo_stat_item_group_set_name(), osmo_stat_item_set(), stats_tcp_entry::stats_tcp, stats_tcp_desc, STATS_TCP_LOST, STATS_TCP_NOTSENT_BYTES, STATS_TCP_RCV_RTT, STATS_TCP_REORD_SEEN, STATS_TCP_RETRANS, STATS_TCP_RTT, STATS_TCP_RWND_LIMITED, STATS_TCP_UNACKED, and subsys.
Referenced by stats_tcp_poll_timer_cb().
References osmo_stats_reporter::list, llist_for_each_entry, osmo_stats_reporter_list, osmo_stats_reporter_send_buffer(), and subsys.
Referenced by osmo_stats_report().
|
static |
References llist_for_each_entry, osmo_counter_difference(), osmo_stats_reporter_list, osmo_stats_reporter_send_counter(), and subsys.
Referenced by osmo_stats_report().
References osmo_fd::fd, and subsys.
Referenced by osmo_stats_tcp_osmo_fd_register().
LLIST_HEAD | ( | osmo_stats_reporter_list | ) |
|
static |
References stats_tcp_entry::entry, llist_empty(), llist_entry, llist_first_entry, llist_last_entry, llist_head::next, stats_tcp_entry::stats_tcp, and stats_tcp_entry_cur.
Referenced by osmo_stats_tcp_osmo_fd_unregister(), and stats_tcp_poll_timer_cb().
Initialize the stats reporting module; call this once in your program.
[in] | ctx | Talloc context from which stats related memory is allocated |
References osmo_tcp_stats_config::interval, is_initialised, osmo_stats_ctx, osmo_stats_tcp_set_interval(), and start_timer().
struct osmo_stats_reporter * osmo_stats_reporter_alloc | ( | enum osmo_stats_reporter_type | type, |
const char * | name | ||
) |
References llist_add_tail(), name, osmo_stats_ctx, osmo_stats_reporter_list, subsys, and osmo_stats_reporter::type.
Referenced by osmo_stats_reporter_create_log(), and osmo_stats_reporter_create_statsd().
|
static |
References OSMO_STATS_CLASS_GLOBAL, OSMO_STATS_CLASS_SUBSCRIBER, OSMO_STATS_CLASS_UNKNOWN, and subsys.
Referenced by osmo_stat_item_handler(), and rate_ctr_handler().
struct osmo_stats_reporter * osmo_stats_reporter_create_log | ( | const char * | name | ) |
Create a stats_reporter that logs via libosmocore logging.
A stats_reporter created via this function will simply print the statistics via the libosmocore logging framework, using DLSTATS subsystem and LOGL_INFO priority. The configuration of the libosmocore log targets define where this information will end up (ignored, text file, stderr, syslog, ...).
[in] | name | Name of the to-be-created stats_reporter |
References name, osmo_stats_reporter_alloc(), OSMO_STATS_REPORTER_LOG, osmo_stats_reporter_log_send_counter(), osmo_stats_reporter_log_send_item(), and subsys.
struct osmo_stats_reporter * osmo_stats_reporter_create_statsd | ( | const char * | name | ) |
Create a stats_reporter reporting to statsd.
This creates a stats_reporter instance which reports the related statistics data to statsd.
[in] | name | Name of the to-be-created stats_reporter |
References name, osmo_stats_reporter_alloc(), OSMO_STATS_REPORTER_STATSD, osmo_stats_reporter_statsd_send_counter(), osmo_stats_reporter_statsd_send_item(), osmo_stats_reporter_udp_close(), osmo_stats_reporter_udp_open(), and subsys.
int osmo_stats_reporter_disable | ( | struct osmo_stats_reporter * | srep | ) |
Disable the given stats_reporter.
[in] | srep | stats_reporter who is to be disabled |
References subsys, and update_srep_config().
Referenced by osmo_stats_reporter_free().
int osmo_stats_reporter_enable | ( | struct osmo_stats_reporter * | srep | ) |
Enable the given stats_reporter.
[in] | srep | stats_reporter who is to be enabled |
References subsys, and update_srep_config().
struct osmo_stats_reporter * osmo_stats_reporter_find | ( | enum osmo_stats_reporter_type | type, |
const char * | name | ||
) |
Find a stats_reporter of given type and name.
[in] | type | Type of stats_reporter to find |
[in] | name | Name of stats_reporter to find |
References osmo_stats_reporter::list, llist_for_each_entry, name, osmo_stats_reporter_list, subsys, and osmo_stats_reporter::type.
void osmo_stats_reporter_free | ( | struct osmo_stats_reporter * | srep | ) |
Destroy a given stats_reporter.
Takes care of first disabling it.
[in] | srep | stats_reporter that shall be disabled + destroyed |
References llist_del(), osmo_stats_reporter_disable(), and subsys.
|
static |
References DLSTATS, LOGL_INFO, LOGP, subsys, and osmo_stats_reporter::type.
Referenced by osmo_stats_reporter_log_send_counter(), and osmo_stats_reporter_log_send_item().
|
static |
References rate_ctr_group::desc, rate_ctr_group_desc::group_name_prefix, rate_ctr_group::idx, osmo_stats_reporter_log_send(), and subsys.
Referenced by osmo_stats_reporter_create_log().
|
static |
Replace all illegal ':' in the stats name, but not when used as value seperator.
':' is used as seperator between the name and the value in the statsd protocol.
[in,out] | buf | is a null terminated string containing name, value, unit. |
References subsys.
Referenced by osmo_stats_reporter_statsd_send().
int osmo_stats_reporter_send_buffer | ( | struct osmo_stats_reporter * | srep | ) |
Referenced by flush_all_reporters(), and osmo_stats_reporter_statsd_send().
|
static |
References subsys.
Referenced by handle_counter(), and rate_ctr_handler().
|
static |
References subsys.
Referenced by osmo_stat_item_handler().
int osmo_stats_reporter_set_flush_period | ( | struct osmo_stats_reporter * | srep, |
unsigned int | period | ||
) |
Set the regular flush period for a given stats_reporter.
Send all stats even if they have not changed (i.e. force the flush) every N-th reporting interval. Set to 0 to disable regular flush, set to 1 to flush every time, set to 2 to flush every 2nd time, etc.
[in] | srep | stats_reporter to set flush period for |
[in] | period | Reporting interval in seconds |
References subsys.
int osmo_stats_reporter_set_local_addr | ( | struct osmo_stats_reporter * | srep, |
const char * | addr | ||
) |
int osmo_stats_reporter_set_max_class | ( | struct osmo_stats_reporter * | srep, |
enum osmo_stats_class | class_id | ||
) |
References OSMO_STATS_CLASS_UNKNOWN, and subsys.
int osmo_stats_reporter_set_mtu | ( | struct osmo_stats_reporter * | srep, |
int | mtu | ||
) |
int osmo_stats_reporter_set_name_prefix | ( | struct osmo_stats_reporter * | srep, |
const char * | prefix | ||
) |
Set the name prefix of a given stats_reporter.
[in] | srep | stats_reporter whose name prefix is to be set |
[in] | prefix | Name prefix to pre-pend for any reported value |
References subsys, and update_srep_config().
int osmo_stats_reporter_set_remote_addr | ( | struct osmo_stats_reporter * | srep, |
const char * | addr | ||
) |
int osmo_stats_reporter_set_remote_port | ( | struct osmo_stats_reporter * | srep, |
int | port | ||
) |
|
static |
|
static |
int osmo_stats_reporter_udp_close | ( | struct osmo_stats_reporter * | srep | ) |
Referenced by osmo_stats_reporter_create_statsd().
int osmo_stats_reporter_udp_open | ( | struct osmo_stats_reporter * | srep | ) |
Referenced by osmo_stats_reporter_create_statsd().
Set the reporting interval (common for all reporters)
[in] | interval | Reporting interval in seconds |
References osmo_stats_config::interval, is_initialised, start_timer(), and subsys.
Register an osmo_fd for TCP stats monitoring.
[in] | fd | osmocom file descriptor to be registered. |
[in] | human | readbla name that is used as prefix for the related stats item. |
References stats_tcp_entry::entry, stats_tcp_entry::fd, is_tcp(), llist_add_tail(), name, stats_tcp_entry::name, OSMO_ASSERT, osmo_stats_tcp_osmo_fd_unregister(), OTC_GLOBAL, stats_tcp_entry::stats_tcp, stats_tcp_lock, and subsys.
Register an osmo_fd for TCP stats monitoring.
[in] | fd | osmocom file descriptor to be unregistered. |
References stats_tcp_entry::entry, osmo_fd::fd, stats_tcp_entry::fd, llist_count(), llist_del(), llist_for_each_entry, next_stats_tcp_entry(), osmo_stat_item_group_free(), stats_tcp_entry::stats_tcp, stats_tcp_entry_cur, stats_tcp_lock, and subsys.
Referenced by osmo_stats_tcp_osmo_fd_register().
Set the polling interval (common for all sockets)
[in] | interval | Poll interval in seconds |
References osmo_tcp_stats_config::interval, osmo_timer_schedule(), and stats_tcp_poll_timer.
Referenced by osmo_stats_init().
References DLSTATS, osmo_fd::fd, llist_empty(), LOGL_NOTICE, LOGP, OSMO_ASSERT, OSMO_FD_READ, osmo_stats_report(), osmo_stats_reporter_list, and subsys.
Referenced by start_timer().
|
static |
References rate_ctr_for_each_counter(), rate_ctr_handler(), and subsys.
Referenced by osmo_stats_report().
|
static |
References rate_ctr_group_desc::class_id, rate_ctr::current, rate_ctr_group::desc, rate_ctr_group::idx, osmo_stats_reporter::list, llist_for_each_entry, osmo_stats_reporter_check_config(), osmo_stats_reporter_list, osmo_stats_reporter_send_counter(), rate_ctr_difference(), and subsys.
Referenced by rate_ctr_group_handler().
References DLSTATS, osmo_fd::fd, osmo_stats_config::interval, is_initialised, LOGL_ERROR, LOGL_INFO, LOGP, osmo_stats_timer, osmo_stats_timer_cb(), osmo_timerfd_disable(), osmo_timerfd_schedule(), osmo_timerfd_setup(), and subsys.
Referenced by osmo_stats_init(), and osmo_stats_set_interval().
|
static |
References subsys.
Referenced by osmo_stats_reporter_disable(), osmo_stats_reporter_enable(), and osmo_stats_reporter_set_name_prefix().
struct llist_head stats_tcp_entry::entry |
Referenced by next_stats_tcp_entry(), osmo_stats_tcp_osmo_fd_register(), and osmo_stats_tcp_osmo_fd_unregister().
Referenced by fill_stats(), osmo_stats_tcp_osmo_fd_register(), and osmo_stats_tcp_osmo_fd_unregister().
|
static |
Referenced by osmo_stats_init(), osmo_stats_set_interval(), and start_timer().
Referenced by fill_stats(), and osmo_stats_tcp_osmo_fd_register().
|
extern |
|
static |
Referenced by osmo_stats_init(), and osmo_stats_reporter_alloc().
|
extern |
Referenced by start_timer().
|
static |
|
static |
struct osmo_stat_item_group* stats_tcp_entry::stats_tcp |
|
static |
Referenced by fill_stats().
|
static |
Referenced by __attribute__(), next_stats_tcp_entry(), osmo_stats_tcp_osmo_fd_unregister(), and stats_tcp_poll_timer_cb().
|
static |
pthread_mutex_t stats_tcp_lock |
|
static |
Referenced by __attribute__(), osmo_stats_tcp_set_interval(), and stats_tcp_poll_timer_cb().