2017-06-20 02:35:06 +00:00
|
|
|
/*! \file stats.c */
|
2015-10-20 17:05:52 +00:00
|
|
|
/*
|
2017-11-12 16:00:26 +00:00
|
|
|
* (C) 2015 by sysmocom - s.f.m.c. GmbH
|
2015-10-20 17:05:52 +00:00
|
|
|
* Author: Jacob Erlbeck <jerlbeck@sysmocom.de>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
2017-11-12 16:00:26 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*
|
2015-10-20 17:05:52 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! \addtogroup stats
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* This module implements periodic reporting of statistics / counters.
|
|
|
|
* It supports the notion of multiple \ref 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 \ref
|
|
|
|
* osmo_stats_init() once at application start-up and then create one or
|
|
|
|
* more \ref osmo_stats_reporter, either using the direct API functions
|
|
|
|
* or by using the optional VTY bindings:
|
|
|
|
*
|
|
|
|
* - reporting to any of the libosmocore log targets
|
|
|
|
* \ref osmo_stats_reporter_create_log() creates a new stats_reporter
|
|
|
|
* which reports to the libosmcoore \ref logging subsystem.
|
|
|
|
*
|
|
|
|
* - reporting to statsd (a front-end proxy for the Graphite/Carbon
|
|
|
|
* metrics server
|
|
|
|
* \ref osmo_stats_reporter_create_statsd() creates a new stats_reporter
|
|
|
|
* which reports via UDP to statsd.
|
|
|
|
*
|
|
|
|
* You can either use the above API functions directly to create \ref
|
|
|
|
* 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 \ref osmo_stats_reporter reports statistics on all of the following
|
|
|
|
* libosmocore internal counter/statistics objects:
|
|
|
|
* - \ref osmo_counter
|
|
|
|
* - \ref rate_ctr
|
|
|
|
* - \ref osmo_stat_item
|
|
|
|
*
|
|
|
|
* You do not need to do anything in particular to expose a given
|
|
|
|
* counter or stat_item, they are all exported automatically via any
|
|
|
|
* \ref osmo_stats_reporter. If you have multiple \ref
|
|
|
|
* osmo_stats_reporter, they will each report all counters/stat_items.
|
|
|
|
*
|
|
|
|
* \file stats.c */
|
|
|
|
|
2017-01-15 16:56:11 +00:00
|
|
|
#include "config.h"
|
|
|
|
#if !defined(EMBEDDED)
|
|
|
|
|
2017-05-15 10:11:36 +00:00
|
|
|
#include <osmocom/core/byteswap.h>
|
2015-10-20 17:05:52 +00:00
|
|
|
#include <osmocom/core/stats.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
2015-08-21 19:56:54 +00:00
|
|
|
#include <sys/types.h>
|
2020-05-08 22:57:51 +00:00
|
|
|
#include <inttypes.h>
|
2017-01-15 16:56:11 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
2015-10-20 17:05:52 +00:00
|
|
|
#include <sys/socket.h>
|
2015-08-21 19:56:54 +00:00
|
|
|
#include <netinet/in.h>
|
2015-10-20 17:05:52 +00:00
|
|
|
#include <arpa/inet.h>
|
2017-01-15 16:56:11 +00:00
|
|
|
#endif
|
2015-10-20 17:05:52 +00:00
|
|
|
|
|
|
|
#include <osmocom/core/utils.h>
|
|
|
|
#include <osmocom/core/logging.h>
|
|
|
|
#include <osmocom/core/rate_ctr.h>
|
|
|
|
#include <osmocom/core/stat_item.h>
|
2020-05-08 22:57:51 +00:00
|
|
|
#include <osmocom/core/select.h>
|
2017-10-15 17:46:19 +00:00
|
|
|
#include <osmocom/core/counter.h>
|
2015-10-26 15:22:45 +00:00
|
|
|
#include <osmocom/core/msgb.h>
|
2015-10-20 17:05:52 +00:00
|
|
|
|
2015-10-26 10:58:38 +00:00
|
|
|
#define STATS_DEFAULT_INTERVAL 5 /* secs */
|
2015-11-09 14:33:44 +00:00
|
|
|
#define STATS_DEFAULT_BUFLEN 256
|
2015-10-20 17:05:52 +00:00
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static LLIST_HEAD(osmo_stats_reporter_list);
|
|
|
|
static void *osmo_stats_ctx = NULL;
|
2015-10-26 10:58:38 +00:00
|
|
|
static int is_initialised = 0;
|
|
|
|
static int32_t current_stat_item_index = 0;
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static struct osmo_stats_config s_stats_config = {
|
2015-10-26 10:58:38 +00:00
|
|
|
.interval = STATS_DEFAULT_INTERVAL,
|
|
|
|
};
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_config *osmo_stats_config = &s_stats_config;
|
2015-10-26 10:58:38 +00:00
|
|
|
|
2020-05-08 22:57:51 +00:00
|
|
|
static struct osmo_fd osmo_stats_timer = { .fd = -1 };
|
2015-10-20 17:05:52 +00:00
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static int osmo_stats_reporter_log_send_counter(struct osmo_stats_reporter *srep,
|
2015-10-28 20:47:45 +00:00
|
|
|
const struct rate_ctr_group *ctrg,
|
|
|
|
const struct rate_ctr_desc *desc,
|
|
|
|
int64_t value, int64_t delta);
|
2015-10-28 23:55:58 +00:00
|
|
|
static int osmo_stats_reporter_log_send_item(struct osmo_stats_reporter *srep,
|
|
|
|
const struct osmo_stat_item_group *statg,
|
2016-11-11 14:06:06 +00:00
|
|
|
const struct osmo_stat_item_desc *desc, int64_t value);
|
2015-10-28 20:47:45 +00:00
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static int update_srep_config(struct osmo_stats_reporter *srep)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (srep->running) {
|
2015-10-27 14:10:28 +00:00
|
|
|
if (srep->close)
|
|
|
|
rc = srep->close(srep);
|
2015-10-20 17:05:52 +00:00
|
|
|
srep->running = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!srep->enabled)
|
|
|
|
return rc;
|
|
|
|
|
2015-10-27 14:10:28 +00:00
|
|
|
if (srep->open)
|
|
|
|
rc = srep->open(srep);
|
|
|
|
else
|
|
|
|
rc = 0;
|
|
|
|
|
2015-10-20 17:05:52 +00:00
|
|
|
if (rc < 0)
|
|
|
|
srep->enabled = 0;
|
|
|
|
else
|
|
|
|
srep->running = 1;
|
|
|
|
|
2015-11-09 10:25:12 +00:00
|
|
|
srep->force_single_flush = 1;
|
|
|
|
|
2015-10-20 17:05:52 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2020-05-08 22:57:51 +00:00
|
|
|
static int osmo_stats_timer_cb(struct osmo_fd *ofd, unsigned int what)
|
2015-10-26 10:58:38 +00:00
|
|
|
{
|
2020-05-08 22:57:51 +00:00
|
|
|
uint64_t expire_count;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* check that the timer has actually expired */
|
|
|
|
if (!(what & OSMO_FD_READ))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* read from timerfd: number of expirations of periodic timer */
|
|
|
|
rc = read(ofd->fd, (void *) &expire_count, sizeof(expire_count));
|
|
|
|
if (rc < 0 && errno == EAGAIN)
|
|
|
|
return 0;
|
|
|
|
OSMO_ASSERT(rc == sizeof(expire_count));
|
|
|
|
|
|
|
|
if (expire_count > 1)
|
|
|
|
LOGP(DLSTATS, LOGL_NOTICE, "Stats timer expire_count=%" PRIu64 ": We missed %" PRIu64 " timers\n",
|
|
|
|
expire_count, expire_count-1);
|
2015-10-26 10:58:38 +00:00
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
if (!llist_empty(&osmo_stats_reporter_list))
|
|
|
|
osmo_stats_report();
|
2015-10-26 10:58:38 +00:00
|
|
|
|
2020-05-08 22:57:51 +00:00
|
|
|
return 0;
|
2015-10-26 10:58:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int start_timer()
|
|
|
|
{
|
2020-05-08 22:57:51 +00:00
|
|
|
int rc;
|
|
|
|
int interval = osmo_stats_config->interval;
|
|
|
|
|
2015-10-26 10:58:38 +00:00
|
|
|
if (!is_initialised)
|
|
|
|
return -ESRCH;
|
|
|
|
|
2020-05-08 22:57:51 +00:00
|
|
|
struct timespec ts_first = {.tv_sec=0, .tv_nsec=1000};
|
|
|
|
struct timespec ts_interval = {.tv_sec=interval, .tv_nsec=0};
|
|
|
|
|
|
|
|
rc = osmo_timerfd_setup(&osmo_stats_timer, osmo_stats_timer_cb, NULL);
|
|
|
|
if (rc < 0)
|
|
|
|
LOGP(DLSTATS, LOGL_ERROR, "Failed to setup the timer with error code %d (fd=%d)\n",
|
|
|
|
rc, osmo_stats_timer.fd);
|
|
|
|
|
2020-07-14 16:11:14 +00:00
|
|
|
if (interval == 0) {
|
|
|
|
rc = osmo_timerfd_disable(&osmo_stats_timer);
|
|
|
|
if (rc < 0)
|
|
|
|
LOGP(DLSTATS, LOGL_ERROR, "Failed to disable the timer with error code %d (fd=%d)\n",
|
|
|
|
rc, osmo_stats_timer.fd);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
rc = osmo_timerfd_schedule(&osmo_stats_timer, &ts_first, &ts_interval);
|
|
|
|
if (rc < 0)
|
|
|
|
LOGP(DLSTATS, LOGL_ERROR, "Failed to schedule the timer with error code %d (fd=%d, interval %d sec)\n",
|
|
|
|
rc, osmo_stats_timer.fd, interval);
|
|
|
|
|
|
|
|
LOGP(DLSTATS, LOGL_INFO, "Stats timer started with interval %d sec\n", interval);
|
|
|
|
}
|
2015-10-26 10:58:38 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *osmo_stats_reporter_alloc(enum osmo_stats_reporter_type type,
|
2015-10-20 17:05:52 +00:00
|
|
|
const char *name)
|
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *srep;
|
|
|
|
srep = talloc_zero(osmo_stats_ctx, struct osmo_stats_reporter);
|
2015-10-20 17:05:52 +00:00
|
|
|
OSMO_ASSERT(srep);
|
|
|
|
srep->type = type;
|
|
|
|
if (name)
|
|
|
|
srep->name = talloc_strdup(srep, name);
|
|
|
|
srep->fd = -1;
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
llist_add(&srep->list, &osmo_stats_reporter_list);
|
2015-10-20 17:05:52 +00:00
|
|
|
|
|
|
|
return srep;
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Destroy a given stats_reporter. Takes care of first disabling it.
|
|
|
|
* \param[in] srep stats_reporter that shall be disabled + destroyed */
|
2015-10-28 23:55:58 +00:00
|
|
|
void osmo_stats_reporter_free(struct osmo_stats_reporter *srep)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
osmo_stats_reporter_disable(srep);
|
2015-10-20 17:05:52 +00:00
|
|
|
llist_del(&srep->list);
|
|
|
|
talloc_free(srep);
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Initilize the stats reporting module; call this once in your program
|
|
|
|
* \param[in] ctx Talloc context from which stats related memory is allocated */
|
2015-10-28 23:55:58 +00:00
|
|
|
void osmo_stats_init(void *ctx)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
osmo_stats_ctx = ctx;
|
|
|
|
osmo_stat_item_discard_all(¤t_stat_item_index);
|
2015-10-26 10:58:38 +00:00
|
|
|
|
|
|
|
is_initialised = 1;
|
|
|
|
start_timer();
|
2015-10-20 17:05:52 +00:00
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Find a stats_reporter of given \a type and \a name.
|
|
|
|
* \param[in] type Type of stats_reporter to find
|
|
|
|
* \param[in] name Name of stats_reporter to find
|
|
|
|
* \returns stats_reporter matching \a type and \a name; NULL otherwise */
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *osmo_stats_reporter_find(enum osmo_stats_reporter_type type,
|
2015-10-20 17:05:52 +00:00
|
|
|
const char *name)
|
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *srep;
|
|
|
|
llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
|
2015-10-20 17:05:52 +00:00
|
|
|
if (srep->type != type)
|
|
|
|
continue;
|
|
|
|
if (srep->name != name) {
|
|
|
|
if (name == NULL || srep->name == NULL ||
|
|
|
|
strcmp(name, srep->name) != 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
return srep;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-01-15 16:56:11 +00:00
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Set the remote (IP) address of a given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter whose remote address is to be set
|
|
|
|
* \param[in] addr String representation of remote IPv4 address
|
|
|
|
* \returns 0 on success; negative on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const char *addr)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->dest_addr;
|
|
|
|
struct in_addr inaddr;
|
|
|
|
|
2015-10-27 13:43:24 +00:00
|
|
|
if (!srep->have_net_config)
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2015-10-20 17:05:52 +00:00
|
|
|
OSMO_ASSERT(addr != NULL);
|
|
|
|
|
|
|
|
rc = inet_pton(AF_INET, addr, &inaddr);
|
|
|
|
if (rc <= 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
sock_addr->sin_addr = inaddr;
|
|
|
|
sock_addr->sin_family = AF_INET;
|
|
|
|
srep->dest_addr_len = sizeof(*sock_addr);
|
|
|
|
|
|
|
|
talloc_free(srep->dest_addr_str);
|
|
|
|
srep->dest_addr_str = talloc_strdup(srep, addr);
|
|
|
|
|
|
|
|
return update_srep_config(srep);
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Set the remote (UDP) port of a given stats_reporter
|
|
|
|
* \param[in] srep stats_reporter whose remote address is to be set
|
|
|
|
* \param[in] port UDP port of remote statsd to which we report
|
|
|
|
* \returns 0 on success; negative on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_reporter_set_remote_port(struct osmo_stats_reporter *srep, int port)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
|
|
|
struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->dest_addr;
|
|
|
|
|
2015-10-27 13:43:24 +00:00
|
|
|
if (!srep->have_net_config)
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2015-10-20 17:05:52 +00:00
|
|
|
srep->dest_port = port;
|
2017-05-15 10:11:36 +00:00
|
|
|
sock_addr->sin_port = osmo_htons(port);
|
2015-10-20 17:05:52 +00:00
|
|
|
|
|
|
|
return update_srep_config(srep);
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Set the local (IP) address of a given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter whose remote address is to be set
|
|
|
|
* \param[in] addr String representation of local IP address
|
|
|
|
* \returns 0 on success; negative on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_reporter_set_local_addr(struct osmo_stats_reporter *srep, const char *addr)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct sockaddr_in *sock_addr = (struct sockaddr_in *)&srep->bind_addr;
|
|
|
|
struct in_addr inaddr;
|
|
|
|
|
2015-10-27 13:43:24 +00:00
|
|
|
if (!srep->have_net_config)
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2015-10-20 17:05:52 +00:00
|
|
|
if (addr) {
|
|
|
|
rc = inet_pton(AF_INET, addr, &inaddr);
|
|
|
|
if (rc <= 0)
|
|
|
|
return -EINVAL;
|
|
|
|
} else {
|
2015-11-02 14:50:32 +00:00
|
|
|
inaddr.s_addr = INADDR_ANY;
|
2015-10-20 17:05:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sock_addr->sin_addr = inaddr;
|
|
|
|
sock_addr->sin_family = AF_INET;
|
|
|
|
srep->bind_addr_len = addr ? sizeof(*sock_addr) : 0;
|
|
|
|
|
|
|
|
talloc_free(srep->bind_addr_str);
|
|
|
|
srep->bind_addr_str = addr ? talloc_strdup(srep, addr) : NULL;
|
|
|
|
|
|
|
|
return update_srep_config(srep);
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Set the maximum transmission unit of a given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter whose remote address is to be set
|
|
|
|
* \param[in] mtu Maximum Transmission Unit of \a srep
|
|
|
|
* \returns 0 on success; negative on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu)
|
2015-10-26 15:22:45 +00:00
|
|
|
{
|
2015-10-27 13:43:24 +00:00
|
|
|
if (!srep->have_net_config)
|
|
|
|
return -ENOTSUP;
|
|
|
|
|
2015-10-26 15:22:45 +00:00
|
|
|
if (mtu < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
srep->mtu = mtu;
|
|
|
|
|
|
|
|
return update_srep_config(srep);
|
|
|
|
}
|
2017-01-15 16:56:11 +00:00
|
|
|
#endif /* HAVE_SYS_SOCKETS_H */
|
2015-10-26 15:22:45 +00:00
|
|
|
|
2015-11-02 13:49:35 +00:00
|
|
|
int osmo_stats_reporter_set_max_class(struct osmo_stats_reporter *srep,
|
|
|
|
enum osmo_stats_class class_id)
|
|
|
|
{
|
|
|
|
if (class_id == OSMO_STATS_CLASS_UNKNOWN)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
srep->max_class = class_id;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-05-08 16:09:22 +00:00
|
|
|
/*! Set the reporting interval (common for all reporters)
|
2017-10-15 18:03:24 +00:00
|
|
|
* \param[in] interval Reporting interval in seconds
|
|
|
|
* \returns 0 on success; negative on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_set_interval(int interval)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
2020-07-14 16:11:14 +00:00
|
|
|
if (interval < 0)
|
2015-10-26 10:58:38 +00:00
|
|
|
return -EINVAL;
|
2015-10-20 17:05:52 +00:00
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
osmo_stats_config->interval = interval;
|
2015-10-26 10:58:38 +00:00
|
|
|
if (is_initialised)
|
|
|
|
start_timer();
|
|
|
|
|
|
|
|
return 0;
|
2015-10-20 17:05:52 +00:00
|
|
|
}
|
|
|
|
|
2020-05-08 16:10:40 +00:00
|
|
|
/*! 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.
|
|
|
|
* \param[in] srep stats_reporter to set flush period for
|
|
|
|
* \param[in] period Reporting interval in seconds
|
|
|
|
* \returns 0 on success; negative on error */
|
|
|
|
int osmo_stats_reporter_set_flush_period(struct osmo_stats_reporter *srep, unsigned int period)
|
|
|
|
{
|
|
|
|
srep->flush_period = period;
|
|
|
|
srep->flush_period_counter = 0;
|
|
|
|
/* force the flush now if it's not disabled by period=0 */
|
|
|
|
if (period > 0)
|
|
|
|
srep->force_single_flush = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Set the name prefix of a given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter whose name prefix is to be set
|
|
|
|
* \param[in] prefix NAme perfix to pre-pend for any reported value
|
|
|
|
* \returns 0 on success; negative on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_reporter_set_name_prefix(struct osmo_stats_reporter *srep, const char *prefix)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
|
|
|
talloc_free(srep->name_prefix);
|
2015-11-09 09:52:19 +00:00
|
|
|
srep->name_prefix = prefix && strlen(prefix) > 0 ?
|
|
|
|
talloc_strdup(srep, prefix) : NULL;
|
2015-10-20 17:05:52 +00:00
|
|
|
|
|
|
|
return update_srep_config(srep);
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
|
|
|
|
/*! Enable the given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter who is to be enabled
|
|
|
|
* \returns 0 on success; negative on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_reporter_enable(struct osmo_stats_reporter *srep)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
|
|
|
srep->enabled = 1;
|
|
|
|
|
|
|
|
return update_srep_config(srep);
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Disable the given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter who is to be disabled
|
|
|
|
* \returns 0 on success; negative on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
|
|
|
srep->enabled = 0;
|
|
|
|
|
|
|
|
return update_srep_config(srep);
|
|
|
|
}
|
|
|
|
|
2015-11-09 14:48:25 +00:00
|
|
|
/*** i/o helper functions ***/
|
|
|
|
|
2017-01-15 16:56:11 +00:00
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Open the UDP socket for given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter whose UDP socket is to be opened
|
|
|
|
* ]returns 0 on success; negative otherwise */
|
2015-11-09 14:48:25 +00:00
|
|
|
int osmo_stats_reporter_udp_open(struct osmo_stats_reporter *srep)
|
|
|
|
{
|
|
|
|
int sock;
|
|
|
|
int rc;
|
|
|
|
int buffer_size = STATS_DEFAULT_BUFLEN;
|
|
|
|
|
|
|
|
if (srep->fd != -1 && srep->close)
|
|
|
|
srep->close(srep);
|
|
|
|
|
|
|
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
|
if (sock == -1)
|
|
|
|
return -errno;
|
|
|
|
|
2016-05-18 20:02:19 +00:00
|
|
|
#if defined(__APPLE__) && !defined(MSG_NOSIGNAL)
|
|
|
|
{
|
|
|
|
static int val = 1;
|
|
|
|
|
|
|
|
rc = setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void*)&val, sizeof(val));
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
#endif
|
2015-11-09 14:48:25 +00:00
|
|
|
if (srep->bind_addr_len > 0) {
|
|
|
|
rc = bind(sock, &srep->bind_addr, srep->bind_addr_len);
|
|
|
|
if (rc == -1)
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
srep->fd = sock;
|
|
|
|
|
|
|
|
if (srep->mtu > 0) {
|
|
|
|
buffer_size = srep->mtu - 20 /* IP */ - 8 /* UDP */;
|
|
|
|
srep->agg_enabled = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
srep->buffer = msgb_alloc(buffer_size, "stats buffer");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
rc = -errno;
|
|
|
|
close(sock);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Closee the UDP socket for given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter whose UDP socket is to be closed
|
|
|
|
* ]returns 0 on success; negative otherwise */
|
2015-11-09 14:48:25 +00:00
|
|
|
int osmo_stats_reporter_udp_close(struct osmo_stats_reporter *srep)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
if (srep->fd == -1)
|
|
|
|
return -EBADF;
|
|
|
|
|
|
|
|
osmo_stats_reporter_send_buffer(srep);
|
|
|
|
|
|
|
|
rc = close(srep->fd);
|
|
|
|
srep->fd = -1;
|
|
|
|
msgb_free(srep->buffer);
|
|
|
|
srep->buffer = NULL;
|
|
|
|
return rc == -1 ? -errno : 0;
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Send given date to given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter whose UDP socket is to be opened
|
|
|
|
* \param[in] data string data to be sent
|
|
|
|
* \param[in] data_len Length of \a data in bytes
|
|
|
|
* \returns number of bytes on success; negative otherwise */
|
2015-11-09 14:33:44 +00:00
|
|
|
int osmo_stats_reporter_send(struct osmo_stats_reporter *srep, const char *data,
|
2015-10-20 17:05:52 +00:00
|
|
|
int data_len)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
2016-05-18 20:02:19 +00:00
|
|
|
rc = sendto(srep->fd, data, data_len,
|
|
|
|
#ifdef MSG_NOSIGNAL
|
|
|
|
MSG_NOSIGNAL |
|
|
|
|
#endif
|
|
|
|
MSG_DONTWAIT,
|
2015-10-20 17:05:52 +00:00
|
|
|
&srep->dest_addr, srep->dest_addr_len);
|
|
|
|
|
|
|
|
if (rc == -1)
|
|
|
|
rc = -errno;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! Send current accumulated buffer to given stats_reporter.
|
|
|
|
* \param[in] srep stats_reporter whose UDP socket is to be opened
|
|
|
|
* \returns number of bytes on success; negative otherwise */
|
2015-11-09 14:33:44 +00:00
|
|
|
int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep)
|
2015-10-26 15:22:45 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!srep->buffer || msgb_length(srep->buffer) == 0)
|
|
|
|
return 0;
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
rc = osmo_stats_reporter_send(srep,
|
2015-10-26 15:22:45 +00:00
|
|
|
(const char *)msgb_data(srep->buffer), msgb_length(srep->buffer));
|
|
|
|
|
|
|
|
msgb_trim(srep->buffer, 0);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2017-01-15 16:56:11 +00:00
|
|
|
#endif /* HAVE_SYS_SOCKET_H */
|
2015-10-26 15:22:45 +00:00
|
|
|
|
2015-10-28 20:47:45 +00:00
|
|
|
/*** log reporter ***/
|
|
|
|
|
2017-10-15 18:03:24 +00:00
|
|
|
/*! 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, ...).
|
|
|
|
* \param[in] name Name of the to-be-created stats_reporter
|
|
|
|
* \returns stats_reporter on success; NULL on error */
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *osmo_stats_reporter_create_log(const char *name)
|
2015-10-28 20:47:45 +00:00
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *srep;
|
|
|
|
srep = osmo_stats_reporter_alloc(OSMO_STATS_REPORTER_LOG, name);
|
2015-10-28 20:47:45 +00:00
|
|
|
|
|
|
|
srep->have_net_config = 0;
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
srep->send_counter = osmo_stats_reporter_log_send_counter;
|
|
|
|
srep->send_item = osmo_stats_reporter_log_send_item;
|
2015-10-28 20:47:45 +00:00
|
|
|
|
|
|
|
return srep;
|
|
|
|
}
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static int osmo_stats_reporter_log_send(struct osmo_stats_reporter *srep,
|
2015-10-28 20:47:45 +00:00
|
|
|
const char *type,
|
2015-11-02 10:30:01 +00:00
|
|
|
const char *name1, unsigned int index1, const char *name2, int value,
|
2015-10-28 20:47:45 +00:00
|
|
|
const char *unit)
|
|
|
|
{
|
2015-11-02 14:17:50 +00:00
|
|
|
LOGP(DLSTATS, LOGL_INFO,
|
2015-11-02 10:30:01 +00:00
|
|
|
"stats t=%s p=%s g=%s i=%u n=%s v=%d u=%s\n",
|
2015-10-28 20:47:45 +00:00
|
|
|
type, srep->name_prefix ? srep->name_prefix : "",
|
|
|
|
name1 ? name1 : "", index1,
|
|
|
|
name2, value, unit ? unit : "");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static int osmo_stats_reporter_log_send_counter(struct osmo_stats_reporter *srep,
|
2015-10-28 20:47:45 +00:00
|
|
|
const struct rate_ctr_group *ctrg,
|
|
|
|
const struct rate_ctr_desc *desc,
|
|
|
|
int64_t value, int64_t delta)
|
|
|
|
{
|
|
|
|
if (ctrg)
|
2015-10-28 23:55:58 +00:00
|
|
|
return osmo_stats_reporter_log_send(srep, "c",
|
2015-10-28 20:47:45 +00:00
|
|
|
ctrg->desc->group_name_prefix,
|
|
|
|
ctrg->idx,
|
|
|
|
desc->name, value, NULL);
|
|
|
|
else
|
2015-10-28 23:55:58 +00:00
|
|
|
return osmo_stats_reporter_log_send(srep, "c",
|
2015-11-02 10:30:01 +00:00
|
|
|
NULL, 0,
|
2015-10-28 20:47:45 +00:00
|
|
|
desc->name, value, NULL);
|
|
|
|
}
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static int osmo_stats_reporter_log_send_item(struct osmo_stats_reporter *srep,
|
|
|
|
const struct osmo_stat_item_group *statg,
|
2016-11-11 14:06:06 +00:00
|
|
|
const struct osmo_stat_item_desc *desc, int64_t value)
|
2015-10-28 20:47:45 +00:00
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
return osmo_stats_reporter_log_send(srep, "i",
|
2015-10-28 20:47:45 +00:00
|
|
|
statg->desc->group_name_prefix, statg->idx,
|
|
|
|
desc->name, value, desc->unit);
|
|
|
|
}
|
|
|
|
|
2015-11-09 14:48:25 +00:00
|
|
|
/*** helper for reporting ***/
|
2015-10-20 17:05:52 +00:00
|
|
|
|
2015-11-09 14:48:25 +00:00
|
|
|
static int osmo_stats_reporter_check_config(struct osmo_stats_reporter *srep,
|
|
|
|
unsigned int index, int class_id)
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
2015-11-09 14:48:25 +00:00
|
|
|
if (class_id == OSMO_STATS_CLASS_UNKNOWN)
|
|
|
|
class_id = index != 0 ?
|
|
|
|
OSMO_STATS_CLASS_SUBSCRIBER : OSMO_STATS_CLASS_GLOBAL;
|
2015-10-26 15:22:45 +00:00
|
|
|
|
2015-11-09 14:48:25 +00:00
|
|
|
return class_id <= srep->max_class;
|
2015-10-20 17:05:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** generic rate counter support ***/
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static int osmo_stats_reporter_send_counter(struct osmo_stats_reporter *srep,
|
2015-10-20 17:05:52 +00:00
|
|
|
const struct rate_ctr_group *ctrg,
|
|
|
|
const struct rate_ctr_desc *desc,
|
|
|
|
int64_t value, int64_t delta)
|
|
|
|
{
|
2015-10-27 14:10:28 +00:00
|
|
|
if (!srep->send_counter)
|
|
|
|
return 0;
|
2015-10-20 17:05:52 +00:00
|
|
|
|
2015-10-27 14:10:28 +00:00
|
|
|
return srep->send_counter(srep, ctrg, desc, value, delta);
|
2015-10-20 17:05:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rate_ctr_handler(
|
|
|
|
struct rate_ctr_group *ctrg, struct rate_ctr *ctr,
|
|
|
|
const struct rate_ctr_desc *desc, void *sctx_)
|
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *srep;
|
2015-10-20 17:05:52 +00:00
|
|
|
int64_t delta = rate_ctr_difference(ctr);
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
|
2015-10-20 17:05:52 +00:00
|
|
|
if (!srep->running)
|
|
|
|
continue;
|
|
|
|
|
2015-11-09 10:25:12 +00:00
|
|
|
if (delta == 0 && !srep->force_single_flush)
|
|
|
|
continue;
|
|
|
|
|
2015-11-02 13:49:35 +00:00
|
|
|
if (!osmo_stats_reporter_check_config(srep,
|
|
|
|
ctrg->idx, ctrg->desc->class_id))
|
2015-11-09 10:39:42 +00:00
|
|
|
continue;
|
2015-11-02 13:49:35 +00:00
|
|
|
|
2015-11-02 14:44:26 +00:00
|
|
|
osmo_stats_reporter_send_counter(srep, ctrg, desc,
|
2015-10-20 17:05:52 +00:00
|
|
|
ctr->current, delta);
|
|
|
|
|
2015-11-02 14:44:26 +00:00
|
|
|
/* TODO: handle result (log?, inc counter(!)?) or remove it */
|
2015-10-20 17:05:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rate_ctr_group_handler(struct rate_ctr_group *ctrg, void *sctx_)
|
|
|
|
{
|
|
|
|
rate_ctr_for_each_counter(ctrg, rate_ctr_handler, sctx_);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-26 11:32:07 +00:00
|
|
|
/*** stat item support ***/
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
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,
|
2015-10-26 11:32:07 +00:00
|
|
|
int32_t value)
|
|
|
|
{
|
2015-10-27 14:10:28 +00:00
|
|
|
if (!srep->send_item)
|
|
|
|
return 0;
|
2015-10-26 11:32:07 +00:00
|
|
|
|
2015-10-27 14:10:28 +00:00
|
|
|
return srep->send_item(srep, statg, desc, value);
|
2015-10-26 11:32:07 +00:00
|
|
|
}
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static int osmo_stat_item_handler(
|
|
|
|
struct osmo_stat_item_group *statg, struct osmo_stat_item *item, void *sctx_)
|
2015-10-26 11:32:07 +00:00
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *srep;
|
2015-10-26 11:32:07 +00:00
|
|
|
int32_t idx = current_stat_item_index;
|
|
|
|
int32_t value;
|
2015-11-09 10:25:12 +00:00
|
|
|
int have_value;
|
|
|
|
|
|
|
|
have_value = osmo_stat_item_get_next(item, &idx, &value) > 0;
|
|
|
|
if (!have_value)
|
|
|
|
/* Send the last value in case a flush is requested */
|
|
|
|
value = osmo_stat_item_get_last(item);
|
2015-10-26 11:32:07 +00:00
|
|
|
|
2015-11-09 10:25:12 +00:00
|
|
|
do {
|
2015-10-28 23:55:58 +00:00
|
|
|
llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
|
2015-10-26 11:32:07 +00:00
|
|
|
if (!srep->running)
|
|
|
|
continue;
|
|
|
|
|
2015-11-09 10:25:12 +00:00
|
|
|
if (!have_value && !srep->force_single_flush)
|
|
|
|
continue;
|
|
|
|
|
2015-11-02 13:49:35 +00:00
|
|
|
if (!osmo_stats_reporter_check_config(srep,
|
|
|
|
statg->idx, statg->desc->class_id))
|
2015-11-09 10:39:42 +00:00
|
|
|
continue;
|
2015-11-02 13:49:35 +00:00
|
|
|
|
2015-11-02 14:44:26 +00:00
|
|
|
osmo_stats_reporter_send_item(srep, statg,
|
2015-10-26 11:32:07 +00:00
|
|
|
item->desc, value);
|
|
|
|
}
|
2015-11-09 10:25:12 +00:00
|
|
|
|
|
|
|
if (!have_value)
|
|
|
|
break;
|
|
|
|
|
|
|
|
have_value = osmo_stat_item_get_next(item, &idx, &value) > 0;
|
|
|
|
} while (have_value);
|
2015-10-26 11:32:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
static int osmo_stat_item_group_handler(struct osmo_stat_item_group *statg, void *sctx_)
|
2015-10-26 11:32:07 +00:00
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
osmo_stat_item_for_each_item(statg, osmo_stat_item_handler, sctx_);
|
2015-10-26 11:32:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-10-20 17:05:52 +00:00
|
|
|
|
2015-10-26 13:42:05 +00:00
|
|
|
/*** osmo counter support ***/
|
|
|
|
|
|
|
|
static int handle_counter(struct osmo_counter *counter, void *sctx_)
|
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *srep;
|
2015-10-26 13:42:05 +00:00
|
|
|
struct rate_ctr_desc desc = {0};
|
|
|
|
/* Fake a rate counter description */
|
|
|
|
desc.name = counter->name;
|
|
|
|
desc.description = counter->description;
|
|
|
|
|
|
|
|
int delta = osmo_counter_difference(counter);
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
|
2015-10-26 13:42:05 +00:00
|
|
|
if (!srep->running)
|
|
|
|
continue;
|
|
|
|
|
2015-11-09 10:25:12 +00:00
|
|
|
if (delta == 0 && !srep->force_single_flush)
|
|
|
|
continue;
|
|
|
|
|
2015-11-02 14:44:26 +00:00
|
|
|
osmo_stats_reporter_send_counter(srep, NULL, &desc,
|
2015-10-26 13:42:05 +00:00
|
|
|
counter->value, delta);
|
|
|
|
|
2015-11-02 14:44:26 +00:00
|
|
|
/* TODO: handle result (log?, inc counter(!)?) */
|
2015-10-26 13:42:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-20 17:05:52 +00:00
|
|
|
/*** main reporting function ***/
|
|
|
|
|
2015-10-26 15:22:45 +00:00
|
|
|
static void flush_all_reporters()
|
|
|
|
{
|
2015-10-28 23:55:58 +00:00
|
|
|
struct osmo_stats_reporter *srep;
|
2015-10-26 15:22:45 +00:00
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
llist_for_each_entry(srep, &osmo_stats_reporter_list, list) {
|
2015-10-26 15:22:45 +00:00
|
|
|
if (!srep->running)
|
|
|
|
continue;
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
osmo_stats_reporter_send_buffer(srep);
|
2020-05-08 16:10:40 +00:00
|
|
|
|
|
|
|
/* reset force_single_flush first */
|
2015-11-09 10:25:12 +00:00
|
|
|
srep->force_single_flush = 0;
|
2020-05-08 16:10:40 +00:00
|
|
|
/* and schedule a new flush if it's time for it */
|
|
|
|
if (srep->flush_period > 0) {
|
|
|
|
srep->flush_period_counter++;
|
|
|
|
if (srep->flush_period_counter >= srep->flush_period) {
|
|
|
|
srep->force_single_flush = 1;
|
|
|
|
srep->flush_period_counter = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-10-26 15:22:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-28 23:55:58 +00:00
|
|
|
int osmo_stats_report()
|
2015-10-20 17:05:52 +00:00
|
|
|
{
|
2015-11-09 13:13:23 +00:00
|
|
|
/* per group actions */
|
2015-10-26 13:42:05 +00:00
|
|
|
osmo_counters_for_each(handle_counter, NULL);
|
2015-10-20 17:05:52 +00:00
|
|
|
rate_ctr_for_each_group(rate_ctr_group_handler, NULL);
|
2015-10-28 23:55:58 +00:00
|
|
|
osmo_stat_item_for_each_group(osmo_stat_item_group_handler, NULL);
|
2015-10-20 17:05:52 +00:00
|
|
|
|
2015-11-09 13:13:23 +00:00
|
|
|
/* global actions */
|
|
|
|
osmo_stat_item_discard_all(¤t_stat_item_index);
|
2015-10-26 15:22:45 +00:00
|
|
|
flush_all_reporters();
|
|
|
|
|
2015-10-20 17:05:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-01-15 16:56:11 +00:00
|
|
|
|
|
|
|
#endif /* !EMBEDDED */
|
2017-10-15 18:03:24 +00:00
|
|
|
|
|
|
|
/*! @} */
|