From 9732cb4a92a883c7e9f7dcd928b6e22976a797ca Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 1 Oct 2015 20:43:53 +0200 Subject: stats: Add stat_item for value monitoring This commit adds instrumentation function to gather measurement and statistical values similar to counter groups. Multiple values can be stored per item, which can be retrieved in FIFO order. Getting values from the item does not modify its state to allow for multiple independant backends (e.g. VTY and statd). When a new value is set, the oldest value gets silently overwritten. Lost values are skipped when getting values from the item. Sponsored-by: On-Waves ehf --- include/Makefile.am | 1 + include/osmocom/core/stat_item.h | 104 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 include/osmocom/core/stat_item.h (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index 52c6a38f..7f8dd777 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -28,6 +28,7 @@ nobase_include_HEADERS = \ osmocom/core/prim.h \ osmocom/core/process.h \ osmocom/core/rate_ctr.h \ + osmocom/core/stat_item.h \ osmocom/core/select.h \ osmocom/core/signal.h \ osmocom/core/socket.h \ diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h new file mode 100644 index 00000000..e166579f --- /dev/null +++ b/include/osmocom/core/stat_item.h @@ -0,0 +1,104 @@ +#pragma once + +/*! \defgroup stat_item Statistics value item + * @{ + */ + +/*! \file stat_item.h */ + +#include + +#include + +struct stat_item_desc; + +/*! \brief data we keep for each actual value */ +struct stat_item { + const struct stat_item_desc *desc; + /*! \brief the index of the freshest value */ + int32_t last_value_index; + /*! \brief offset to the freshest value in the value fifo */ + int16_t last_offs; + /*! \brief value fifo */ + int32_t values[0]; +}; + +/*! \brief statistics value description */ +struct stat_item_desc { + const char *name; /*!< \brief name of the item */ + const char *description;/*!< \brief description of the item */ + const char *unit; /*!< \brief unit of a value */ + unsigned int num_values;/*!< \brief number of values to store */ + int32_t default_value; +}; + +/*! \brief description of a statistics value group */ +struct stat_item_group_desc { + /*! \brief The prefix to the name of all values in this group */ + const char *group_name_prefix; + /*! \brief The human-readable description of the group */ + const char *group_description; + /*! \brief The number of values in this group */ + const unsigned int num_items; + /*! \brief Pointer to array of value names */ + const struct stat_item_desc *item_desc; +}; + +/*! \brief One instance of a counter group class */ +struct stat_item_group { + /*! \brief Linked list of all value groups in the system */ + struct llist_head list; + /*! \brief Pointer to the counter group class */ + const struct stat_item_group_desc *desc; + /*! \brief The index of this value group within its class */ + unsigned int idx; + /*! \brief Actual counter structures below */ + struct stat_item *items[0]; +}; + +struct stat_item_group *stat_item_group_alloc( + void *ctx, + const struct stat_item_group_desc *desc, + unsigned int idx); + +void stat_item_group_free(struct stat_item_group *grp); + +void stat_item_set(struct stat_item *val, int32_t value); + +int stat_item_init(void *tall_ctx); + +struct stat_item_group *stat_item_get_group_by_name_idx( + const char *name, const unsigned int idx); + +const struct stat_item *stat_item_get_by_name( + const struct stat_item_group *valg, const char *name); + +/*! \brief Retrieve the next value from the 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 stat_item object can be kept stateless from the reader's + * perspective and therefore be used by several backends simultaneously. + * + * \param val the stat_item object + * \param idx identifies the next value to be read + * \param value a 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) + */ +int stat_item_get_next(const struct stat_item *val, int32_t *idx, int32_t *value); + +/*! \brief Get the last (freshest) value */ +static int32_t stat_item_get_last(const struct stat_item *val); + +/*! \brief Skip all values of the item and update idx accordingly */ +int stat_item_discard(const struct stat_item *val, int32_t *idx); + +static inline int32_t stat_item_get_last(const struct stat_item *val) +{ + return val->values[val->last_offs]; +} +/*! @} */ -- cgit v1.2.3 From 738d9e22108a8e472458fad42509fd8d96994d6c Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 6 Oct 2015 15:21:56 +0200 Subject: stats: Add vty_out_stat_item_group This functions dumps a whole stat item group to the VTY. Sponsored-by: On-Waves ehf --- include/osmocom/vty/misc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h index db552e77..ad878db2 100644 --- a/include/osmocom/vty/misc.h +++ b/include/osmocom/vty/misc.h @@ -2,6 +2,7 @@ #include #include +#include #include #define VTY_DO_LOWER 1 @@ -10,7 +11,10 @@ char *vty_cmd_string_from_valstr(void *ctx, const struct value_string *vals, const char *end, int do_lower); void vty_out_rate_ctr_group(struct vty *vty, const char *prefix, - struct rate_ctr_group *ctrg); + struct rate_ctr_group *ctrg); + +void vty_out_stat_item_group(struct vty *vty, const char *prefix, + struct stat_item_group *statg); int osmo_vty_write_config_file(const char *filename); int osmo_vty_save_config_file(void); -- cgit v1.2.3 From 0a1400fc8311268d0a66bb20e0620e546e8d11c8 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 6 Oct 2015 15:23:25 +0200 Subject: ns: Add statistics for some events The following counters are added to the ns.nsvc counter group: lost.alive The number of missing ALIVE ACK messages lost.reset The number of missing RESET ACK messages The following items are added to the ns.nsvc stat item group: alive.delay The time in ms between sending ALIVE and receiving the next ALIVE ACK Sponsored-by: On-Waves ehf --- include/osmocom/gprs/gprs_ns.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h index d5a605df..42e0d884 100644 --- a/include/osmocom/gprs/gprs_ns.h +++ b/include/osmocom/gprs/gprs_ns.h @@ -118,6 +118,7 @@ struct gprs_nsvc { struct osmo_timer_list timer; enum nsvc_timer_mode timer_mode; + struct timeval timer_started; int alive_retries; unsigned int remote_end_is_sgsn:1; @@ -125,6 +126,7 @@ struct gprs_nsvc { unsigned int nsvci_is_valid:1; struct rate_ctr_group *ctrg; + struct stat_item_group *statg; /*! \brief which link-layer are we based on? */ enum gprs_ns_ll ll; -- cgit v1.2.3 From b27b352e937dd0760da1e7fb05f9207be05702b8 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 12 Oct 2015 18:47:09 +0200 Subject: stats: Use a global index for stat item values Currently each stat item has a separate index value which basically counts each single value added to the item and which can be used by a reporter to get all new values that have not been reported yet. The drawback is, that such an index must be stored for each stat item. This commit introduces a global index which is incremented for each new stat item value. This index is then stored together with the item value. So a single stored index per reporter is sufficient to make sure that only new values are reported. Sponsored-by: On-Waves ehf --- include/osmocom/core/stat_item.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h index e166579f..003c9e07 100644 --- a/include/osmocom/core/stat_item.h +++ b/include/osmocom/core/stat_item.h @@ -12,6 +12,13 @@ struct stat_item_desc; +#define STAT_ITEM_NOVALUE_ID 0 + +struct stat_item_value { + int32_t id; + int32_t value; +}; + /*! \brief data we keep for each actual value */ struct stat_item { const struct stat_item_desc *desc; @@ -20,7 +27,7 @@ struct stat_item { /*! \brief offset to the freshest value in the value fifo */ int16_t last_offs; /*! \brief value fifo */ - int32_t values[0]; + struct stat_item_value values[0]; }; /*! \brief statistics value description */ @@ -61,9 +68,9 @@ struct stat_item_group *stat_item_group_alloc( const struct stat_item_group_desc *desc, unsigned int idx); -void stat_item_group_free(struct stat_item_group *grp); +void stat_item_group_free(struct stat_item_group *statg); -void stat_item_set(struct stat_item *val, int32_t value); +void stat_item_set(struct stat_item *item, int32_t value); int stat_item_init(void *tall_ctx); @@ -71,7 +78,7 @@ struct stat_item_group *stat_item_get_group_by_name_idx( const char *name, const unsigned int idx); const struct stat_item *stat_item_get_by_name( - const struct stat_item_group *valg, const char *name); + const struct stat_item_group *statg, const char *name); /*! \brief Retrieve the next value from the stat_item object. * If a new value has been set, it is returned. The idx is used to decide @@ -89,16 +96,19 @@ const struct stat_item *stat_item_get_by_name( * 1: one value has been taken, * (1+n): n values have been skipped, one has been taken) */ -int stat_item_get_next(const struct stat_item *val, int32_t *idx, int32_t *value); +int stat_item_get_next(const struct stat_item *item, int32_t *idx, int32_t *value); /*! \brief Get the last (freshest) value */ -static int32_t stat_item_get_last(const struct stat_item *val); +static int32_t stat_item_get_last(const struct stat_item *item); /*! \brief Skip all values of the item and update idx accordingly */ -int stat_item_discard(const struct stat_item *val, int32_t *idx); +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); -static inline int32_t stat_item_get_last(const struct stat_item *val) +static inline int32_t stat_item_get_last(const struct stat_item *item) { - return val->values[val->last_offs]; + return item->values[item->last_offs].value; } /*! @} */ -- cgit v1.2.3 From 423c1e5a4fc7ad2cd5e95e852b778c7e2c892bc1 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 19 Oct 2015 13:45:42 +0200 Subject: core: Extend rate_ctr by helper functions For global value reporting, some additional helper functions are needed. The statsd protocol expects differential counter values, which are currently not provided by rate_ctr (except for s/m/h/d intervals). This commit adds several helper functions to rate_ctr: - rate_ctr_difference returns the counter delta since the last call to this function for a given counter - rate_ctr_for_each_counter iterates through each counter of a group - rate_ctr_for_each_group iterates through all globally registered counter groups Note that the rate_ctr_difference function can only be used by a single backend, since it modifies the 'previous' field in the rate_ctr obj. Sponsored-by: On-Waves ehf --- include/osmocom/core/rate_ctr.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h index 821c7cfd..f3c03de3 100644 --- a/include/osmocom/core/rate_ctr.h +++ b/include/osmocom/core/rate_ctr.h @@ -30,6 +30,7 @@ struct rate_ctr_per_intv { /*! \brief data we keep for each actual value */ struct rate_ctr { uint64_t current; /*!< \brief current value */ + uint64_t previous; /*!< \brief previous value, used for delta */ /*! \brief per-interval data */ struct rate_ctr_per_intv intv[RATE_CTR_INTV_NUM]; }; @@ -78,9 +79,27 @@ static inline void rate_ctr_inc(struct rate_ctr *ctr) rate_ctr_add(ctr, 1); } +/*! \brief Return the counter difference since the last call to this function */ +int64_t rate_ctr_difference(struct rate_ctr *ctr); + int rate_ctr_init(void *tall_ctx); struct rate_ctr_group *rate_ctr_get_group_by_name_idx(const char *name, const unsigned int idx); const struct rate_ctr *rate_ctr_get_by_name(const struct rate_ctr_group *ctrg, const char *name); +typedef int (*rate_ctr_handler_t)( + struct rate_ctr_group *, struct rate_ctr *, + const struct rate_ctr_desc *, void *); +typedef int (*rate_ctr_group_handler_t)(struct rate_ctr_group *, void *); + + +/*! \brief Iterate over all counters + * \param[in] handle_item Call-back function, aborts if rc < 0 + * \param[in] data Private data handed through to \a handle_counter + */ +int rate_ctr_for_each_counter(struct rate_ctr_group *ctrg, + rate_ctr_handler_t handle_counter, void *data); + +int rate_ctr_for_each_group(rate_ctr_group_handler_t handle_group, void *data); + /*! @} */ -- cgit v1.2.3 From c6a7108828bf98ebcaf31d24bd8d789afdd4da94 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 19 Oct 2015 14:04:38 +0200 Subject: stats: Add stat_item_for_each functions This commit adds the following functions: stat_item_for_each_group Call a handler for each group stat_item_for_each_item Call a handler for each item of a group Sponsored-by: On-Waves ehf --- include/osmocom/core/stat_item.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h index 003c9e07..0786a3ba 100644 --- a/include/osmocom/core/stat_item.h +++ b/include/osmocom/core/stat_item.h @@ -107,6 +107,20 @@ 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); +typedef int (*stat_item_handler_t)( + struct stat_item_group *, struct stat_item *, void *); + +typedef int (*stat_item_group_handler_t)(struct stat_item_group *, void *); + +/*! \brief Iteate over all items + * \param[in] handle_item Call-back function, aborts if rc < 0 + * \param[in] data Private data handed through to \a handle_item + */ +int stat_item_for_each_item(struct stat_item_group *statg, + stat_item_handler_t handle_item, void *data); + +int stat_item_for_each_group(stat_item_group_handler_t handle_group, void *data); + static inline int32_t stat_item_get_last(const struct stat_item *item) { return item->values[item->last_offs].value; -- cgit v1.2.3 From e5b0fe2e3c84dd0de7021d65d416356612db4260 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 19 Oct 2015 15:00:59 +0200 Subject: core: Update osmo_counters_for_each doc Fix type and add a note about the semantics of the handler's return code. Sponsored-by: On-Waves ehf --- include/osmocom/core/statistics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/osmocom/core/statistics.h b/include/osmocom/core/statistics.h index de250bec..a9a623d3 100644 --- a/include/osmocom/core/statistics.h +++ b/include/osmocom/core/statistics.h @@ -37,8 +37,8 @@ struct osmo_counter *osmo_counter_alloc(const char *name); */ void osmo_counter_free(struct osmo_counter *ctr); -/*! \brief Iteate over all counters - * \param[in] handle_counter Call-back function +/*! \brief Iterate over all counters + * \param[in] handle_counter Call-back function, aborts if rc < 0 * \param[in] data Private dtata handed through to \a handle_counter */ int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data); -- cgit v1.2.3 From 7211fe157e1107d4a9c04a0ecf494a7b9633c400 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 19 Oct 2015 15:11:50 +0200 Subject: stat/vty: Add vty_out_statistics_full to show all statistics This functions shows the state of all osmo_counters, stat_item groups, and counter groups. Sponsored-by: On-Waves ehf --- include/osmocom/vty/misc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h index ad878db2..99c2ee68 100644 --- a/include/osmocom/vty/misc.h +++ b/include/osmocom/vty/misc.h @@ -16,5 +16,7 @@ void vty_out_rate_ctr_group(struct vty *vty, const char *prefix, void vty_out_stat_item_group(struct vty *vty, const char *prefix, struct stat_item_group *statg); +void vty_out_statistics_full(struct vty *vty, const char *prefix); + int osmo_vty_write_config_file(const char *filename); int osmo_vty_save_config_file(void); -- cgit v1.2.3 From 45513e6040195f5494d40a2750de4dac7037593f Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 19 Oct 2015 15:14:13 +0200 Subject: stats/vty: Add stats_vty.c This file will contain the VTY code related to statistics. This commit adds a minimal file with just as single VTY command: - show stats This command shows all statistical values To enable this and future commands, the main program needs to call stats_vty_add_cmds(). Sponsored-by: On-Waves ehf --- include/Makefile.am | 1 + include/osmocom/vty/stats.h | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 include/osmocom/vty/stats.h (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index 7f8dd777..af189c36 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -113,6 +113,7 @@ nobase_include_HEADERS += \ osmocom/vty/buffer.h \ osmocom/vty/command.h \ osmocom/vty/logging.h \ + osmocom/vty/stats.h \ osmocom/vty/misc.h \ osmocom/vty/telnet_interface.h \ osmocom/vty/vector.h \ diff --git a/include/osmocom/vty/stats.h b/include/osmocom/vty/stats.h new file mode 100644 index 00000000..eaf854e5 --- /dev/null +++ b/include/osmocom/vty/stats.h @@ -0,0 +1,3 @@ +#pragma once + +void stats_vty_add_cmds(); -- cgit v1.2.3 From 95bf828003b065f00a78144296072a9730cbf7bc Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 20 Oct 2015 19:05:52 +0200 Subject: stats: Add the reporting framework This commit provides the stats reporting framework that can manage several types of measurement reporters. Initially support for rate_ctr and the statsd protocol is included. Sponsored-by: On-Waves ehf --- include/Makefile.am | 1 + include/osmocom/core/stats.h | 70 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 include/osmocom/core/stats.h (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index af189c36..20735800 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -22,6 +22,7 @@ nobase_include_HEADERS = \ osmocom/core/linuxrbtree.h \ osmocom/core/logging.h \ osmocom/core/loggingrb.h \ + osmocom/core/stats.h \ osmocom/core/macaddr.h \ osmocom/core/msgb.h \ osmocom/core/panic.h \ diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h new file mode 100644 index 00000000..b4fb727c --- /dev/null +++ b/include/osmocom/core/stats.h @@ -0,0 +1,70 @@ +/* (C) 2015 by Sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * 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. + * + */ +#pragma once + +#include +#include + +enum stats_reporter_type { + STATS_REPORTER_STATSD, +}; + +struct stats_reporter { + enum stats_reporter_type type; + char *name; + + /* config */ + int enabled; + int interval; + char *name_prefix; + char *dest_addr_str; + char *bind_addr_str; + int dest_port; + int mtu; + + /* state */ + int running; + struct sockaddr dest_addr; + int dest_addr_len; + struct sockaddr bind_addr; + int bind_addr_len; + int fd; + + struct llist_head list; +}; + +void stats_init(void *ctx); +int stats_report(); + +struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type, + const char *name); +void stats_reporter_free(struct stats_reporter *srep); +struct stats_reporter *stats_reporter_create_statsd(const char *name); + +struct stats_reporter *stats_reporter_find(enum stats_reporter_type type, + const char *name); + +int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr); +int stats_reporter_set_remote_port(struct stats_reporter *srep, int port); +int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr); +int stats_reporter_set_interval(struct stats_reporter *srep, int interval); +int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix); +int stats_reporter_enable(struct stats_reporter *srep); +int stats_reporter_disable(struct stats_reporter *srep); -- cgit v1.2.3 From adc900e0e38373193c8451c0310fe742d62c2c8e Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 20 Oct 2015 19:05:52 +0200 Subject: stats/vty: Add stats configuration This commit provides stats configuration similar to the log configuration. The following vty commands are added to the config node: stats reporter statsd Create/Modify a statsd reporter no stats reporter statsd Remove a statsd reporter To actually configure a reporter, the config-stats node is entered when the "stats reporter" command has succeeded. The following new vty commands are available there: local-ip ADDR Set the IP address to which we bind locally no local-ip Do not bind to a certain IP address remote-ip ADDR Set the remote IP address to which we connect remote-port <1-65535> Set the remote port to which we connect prefix PREFIX Set the item/counter name prefix no prefix Do not use a prefix enable Enable the reporter disable Disable the reporter Sponsored-by: On-Waves ehf --- include/osmocom/vty/command.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h index 4eb519f6..890f0d6d 100644 --- a/include/osmocom/vty/command.h +++ b/include/osmocom/vty/command.h @@ -75,6 +75,7 @@ enum node_type { SERVICE_NODE, /*!< \brief Service node. */ DEBUG_NODE, /*!< \brief Debug node. */ CFG_LOG_NODE, /*!< \brief Configure the logging */ + CFG_STATS_NODE, /*!< \brief Configure the statistics */ VTY_NODE, /*!< \brief Vty node. */ -- cgit v1.2.3 From b1dbfb4c4179a62cd4b761ebdc7a3c2de5bdc0d9 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 26 Oct 2015 11:58:38 +0100 Subject: stats: Implement timer based reporting This calls stats_flush in regular intervals which polls the statistical values and calls the active reporters when values have changed. Sponsored-by: On-Waves ehf --- include/osmocom/core/stats.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h index b4fb727c..489e0e41 100644 --- a/include/osmocom/core/stats.h +++ b/include/osmocom/core/stats.h @@ -32,7 +32,6 @@ struct stats_reporter { /* config */ int enabled; - int interval; char *name_prefix; char *dest_addr_str; char *bind_addr_str; @@ -50,9 +49,17 @@ struct stats_reporter { struct llist_head list; }; +struct stats_config { + int interval; +}; + +extern struct stats_config *stats_config; + void stats_init(void *ctx); int stats_report(); +int stats_set_interval(int interval); + struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type, const char *name); void stats_reporter_free(struct stats_reporter *srep); @@ -64,7 +71,6 @@ struct stats_reporter *stats_reporter_find(enum stats_reporter_type type, int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr); int stats_reporter_set_remote_port(struct stats_reporter *srep, int port); int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr); -int stats_reporter_set_interval(struct stats_reporter *srep, int interval); int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix); int stats_reporter_enable(struct stats_reporter *srep); int stats_reporter_disable(struct stats_reporter *srep); -- cgit v1.2.3 From 80db4ec3875b0de7f06de769881d6c5d4b713f2d Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 26 Oct 2015 14:39:08 +0100 Subject: core: Add difference function to osmo_counter The osmo_counter_difference returns the counter value difference since the last call of this function with the given counter object. Sponsored-by: On-Waves ehf --- include/osmocom/core/statistics.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/statistics.h b/include/osmocom/core/statistics.h index a9a623d3..1e472ffd 100644 --- a/include/osmocom/core/statistics.h +++ b/include/osmocom/core/statistics.h @@ -9,6 +9,7 @@ struct osmo_counter { const char *name; /*!< \brief human-readable name */ const char *description; /*!< \brief humn-readable description */ unsigned long value; /*!< \brief current value */ + unsigned long previous; /*!< \brief previous value */ }; /*! \brief Increment counter */ @@ -48,3 +49,6 @@ int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), * \returns pointer to counter (\ref osmo_counter) or NULL otherwise */ struct osmo_counter *osmo_counter_get_by_name(const char *name); + +/*! \brief Return the counter difference since the last call to this function */ +int osmo_counter_difference(struct osmo_counter *ctr); -- cgit v1.2.3 From d01acfcc75a6c5798a95a8ccca9be18eba65a0bf Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 26 Oct 2015 16:22:45 +0100 Subject: stats: Support statsd Multi-Metric Packets If the MTU is given, combine several messages into a single UDP packet until the limit is reached. Flush all reporters after the values have been scanned. New vty commands (node config-stats): mtu <100-65535> Enable multi-metric packets and set the maximum packet size (in byte) no mtu Disable multi-metric packets Note that single messages that are longer than the given MTU (minus 28 octets protocol overhead) will be dropped. Sponsored-by: On-Waves ehf --- include/osmocom/core/stats.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h index 489e0e41..ed461ddc 100644 --- a/include/osmocom/core/stats.h +++ b/include/osmocom/core/stats.h @@ -22,6 +22,8 @@ #include #include +struct msgb; + enum stats_reporter_type { STATS_REPORTER_STATSD, }; @@ -45,6 +47,8 @@ struct stats_reporter { struct sockaddr bind_addr; int bind_addr_len; int fd; + struct msgb *buffer; + int agg_enabled; struct llist_head list; }; @@ -71,6 +75,7 @@ struct stats_reporter *stats_reporter_find(enum stats_reporter_type type, int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr); int stats_reporter_set_remote_port(struct stats_reporter *srep, int port); int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr); +int stats_reporter_set_mtu(struct stats_reporter *srep, int mtu); int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix); int stats_reporter_enable(struct stats_reporter *srep); int stats_reporter_disable(struct stats_reporter *srep); -- cgit v1.2.3 From ed197fd4f923512fca5b93b90c2132845896fa59 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 27 Oct 2015 14:43:24 +0100 Subject: stats: Make net config optional To support reporters without network configuration, this commit introduces the have_net_config flag to provide corresponding error messages. Sponsored-by: On-Waves ehf --- include/osmocom/core/stats.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h index ed461ddc..9ee9f106 100644 --- a/include/osmocom/core/stats.h +++ b/include/osmocom/core/stats.h @@ -32,6 +32,8 @@ struct stats_reporter { enum stats_reporter_type type; char *name; + unsigned int have_net_config : 1; + /* config */ int enabled; char *name_prefix; -- cgit v1.2.3 From 490b38f57a24726f3e3493fc3500cda526c5d0aa Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 27 Oct 2015 15:10:28 +0100 Subject: stats: Use function pointers in reporter objects Currently case statements are used to select the right reporter functions. This makes it difficult to add new reporter types, especially if they are not going to reside in the same file. This commit introduces per reporter function pointer for open, close, send_count, and send_item. They are checked for non-NULL before being called or skipped. Sponsored-by: On-Waves ehf --- include/osmocom/core/stats.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h index 9ee9f106..beeee16e 100644 --- a/include/osmocom/core/stats.h +++ b/include/osmocom/core/stats.h @@ -23,6 +23,10 @@ #include struct msgb; +struct stat_item_group; +struct stat_item_desc; +struct rate_ctr_group; +struct rate_ctr_desc; enum stats_reporter_type { STATS_REPORTER_STATSD, @@ -53,6 +57,16 @@ struct stats_reporter { int agg_enabled; struct llist_head list; + int (*open)(struct stats_reporter *srep); + int (*close)(struct stats_reporter *srep); + int (*send_counter)(struct stats_reporter *srep, + const struct rate_ctr_group *ctrg, + const struct rate_ctr_desc *desc, + int64_t value, int64_t delta); + int (*send_item)(struct stats_reporter *srep, + const struct stat_item_group *statg, + const struct stat_item_desc *desc, + int32_t value); }; struct stats_config { -- cgit v1.2.3 From bc4f7ae512b32fa4b569dfc5242d0b7a5da3f81b Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Wed, 28 Oct 2015 21:47:45 +0100 Subject: stats: Add log reporter This reporter passes the measurement values to the logging subsystem as DSTATS (which is currently DLGLOBAL) level INFO messages. Sponsored-by: On-Waves ehf --- include/osmocom/core/stats.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h index beeee16e..68c2e016 100644 --- a/include/osmocom/core/stats.h +++ b/include/osmocom/core/stats.h @@ -30,6 +30,7 @@ struct rate_ctr_desc; enum stats_reporter_type { STATS_REPORTER_STATSD, + STATS_REPORTER_LOG, }; struct stats_reporter { @@ -83,7 +84,9 @@ int stats_set_interval(int interval); struct stats_reporter *stats_reporter_alloc(enum stats_reporter_type type, const char *name); void stats_reporter_free(struct stats_reporter *srep); + struct stats_reporter *stats_reporter_create_statsd(const char *name); +struct stats_reporter *stats_reporter_create_log(const char *name); struct stats_reporter *stats_reporter_find(enum stats_reporter_type type, const char *name); -- cgit v1.2.3 From fc9533d6c4bde795dc0e18f02f91f54ab92888a2 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Thu, 29 Oct 2015 00:55:58 +0100 Subject: stats: Add osmo_ name prefix to identifiers Since the the stat_item and stats functions and data types are meant to be exported, they get an osmo_ prefix. Sponsored-by: On-Waves ehf [hfreyther: Prepended the enum values too. This was requested by Jacob] --- include/osmocom/core/stat_item.h | 68 ++++++++++++++++++++-------------------- include/osmocom/core/stats.h | 60 +++++++++++++++++------------------ include/osmocom/gprs/gprs_ns.h | 2 +- include/osmocom/vty/misc.h | 2 +- include/osmocom/vty/stats.h | 2 +- 5 files changed, 67 insertions(+), 67 deletions(-) (limited to 'include') diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h index 0786a3ba..40474958 100644 --- a/include/osmocom/core/stat_item.h +++ b/include/osmocom/core/stat_item.h @@ -1,6 +1,6 @@ #pragma once -/*! \defgroup stat_item Statistics value item +/*! \defgroup osmo_stat_item Statistics value item * @{ */ @@ -10,28 +10,28 @@ #include -struct stat_item_desc; +struct osmo_stat_item_desc; #define STAT_ITEM_NOVALUE_ID 0 -struct stat_item_value { +struct osmo_stat_item_value { int32_t id; int32_t value; }; /*! \brief data we keep for each actual value */ -struct stat_item { - const struct stat_item_desc *desc; +struct osmo_stat_item { + const struct osmo_stat_item_desc *desc; /*! \brief the index of the freshest value */ int32_t last_value_index; /*! \brief offset to the freshest value in the value fifo */ int16_t last_offs; /*! \brief value fifo */ - struct stat_item_value values[0]; + struct osmo_stat_item_value values[0]; }; /*! \brief statistics value description */ -struct stat_item_desc { +struct osmo_stat_item_desc { const char *name; /*!< \brief name of the item */ const char *description;/*!< \brief description of the item */ const char *unit; /*!< \brief unit of a value */ @@ -40,7 +40,7 @@ struct stat_item_desc { }; /*! \brief description of a statistics value group */ -struct stat_item_group_desc { +struct osmo_stat_item_group_desc { /*! \brief The prefix to the name of all values in this group */ const char *group_name_prefix; /*! \brief The human-readable description of the group */ @@ -48,80 +48,80 @@ struct stat_item_group_desc { /*! \brief The number of values in this group */ const unsigned int num_items; /*! \brief Pointer to array of value names */ - const struct stat_item_desc *item_desc; + const struct osmo_stat_item_desc *item_desc; }; /*! \brief One instance of a counter group class */ -struct stat_item_group { +struct osmo_stat_item_group { /*! \brief Linked list of all value groups in the system */ struct llist_head list; /*! \brief Pointer to the counter group class */ - const struct stat_item_group_desc *desc; + const struct osmo_stat_item_group_desc *desc; /*! \brief The index of this value group within its class */ unsigned int idx; /*! \brief Actual counter structures below */ - struct stat_item *items[0]; + struct osmo_stat_item *items[0]; }; -struct stat_item_group *stat_item_group_alloc( +struct osmo_stat_item_group *osmo_stat_item_group_alloc( void *ctx, - const struct stat_item_group_desc *desc, + const struct osmo_stat_item_group_desc *desc, unsigned int idx); -void stat_item_group_free(struct stat_item_group *statg); +void osmo_stat_item_group_free(struct osmo_stat_item_group *statg); -void stat_item_set(struct stat_item *item, int32_t value); +void osmo_stat_item_set(struct osmo_stat_item *item, int32_t value); -int stat_item_init(void *tall_ctx); +int osmo_stat_item_init(void *tall_ctx); -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); -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); -/*! \brief Retrieve the next value from the stat_item object. +/*! \brief 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 stat_item object can be kept stateless from the reader's + * This way, the osmo_stat_item object can be kept stateless from the reader's * perspective and therefore be used by several backends simultaneously. * - * \param val the stat_item object + * \param val the osmo_stat_item object * \param idx identifies the next value to be read * \param value a 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) */ -int stat_item_get_next(const struct stat_item *item, int32_t *idx, int32_t *value); +int osmo_stat_item_get_next(const struct osmo_stat_item *item, int32_t *idx, int32_t *value); /*! \brief Get the last (freshest) value */ -static int32_t stat_item_get_last(const struct stat_item *item); +static int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item); /*! \brief Skip all values of the 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); /*! \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); -typedef int (*stat_item_handler_t)( - struct stat_item_group *, struct stat_item *, void *); +typedef int (*osmo_stat_item_handler_t)( + struct osmo_stat_item_group *, struct osmo_stat_item *, void *); -typedef int (*stat_item_group_handler_t)(struct stat_item_group *, void *); +typedef int (*osmo_stat_item_group_handler_t)(struct osmo_stat_item_group *, void *); /*! \brief Iteate over all items * \param[in] handle_item Call-back function, aborts if rc < 0 * \param[in] data Private data handed through to \a handle_item */ -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 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); -static inline int32_t stat_item_get_last(const struct stat_item *item) +static inline int32_t osmo_stat_item_get_last(const struct osmo_stat_item *item) { return item->values[item->last_offs].value; } diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h index 68c2e016..7b3d0211 100644 --- a/include/osmocom/core/stats.h +++ b/include/osmocom/core/stats.h @@ -23,18 +23,18 @@ #include struct msgb; -struct stat_item_group; -struct stat_item_desc; +struct osmo_stat_item_group; +struct osmo_stat_item_desc; struct rate_ctr_group; struct rate_ctr_desc; -enum stats_reporter_type { - STATS_REPORTER_STATSD, - STATS_REPORTER_LOG, +enum osmo_stats_reporter_type { + OSMO_STATS_REPORTER_STATSD, + OSMO_STATS_REPORTER_LOG, }; -struct stats_reporter { - enum stats_reporter_type type; +struct osmo_stats_reporter { + enum osmo_stats_reporter_type type; char *name; unsigned int have_net_config : 1; @@ -58,43 +58,43 @@ struct stats_reporter { int agg_enabled; struct llist_head list; - int (*open)(struct stats_reporter *srep); - int (*close)(struct stats_reporter *srep); - int (*send_counter)(struct stats_reporter *srep, + int (*open)(struct osmo_stats_reporter *srep); + int (*close)(struct osmo_stats_reporter *srep); + int (*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); - int (*send_item)(struct stats_reporter *srep, - const struct stat_item_group *statg, - const struct stat_item_desc *desc, + int (*send_item)(struct osmo_stats_reporter *srep, + const struct osmo_stat_item_group *statg, + const struct osmo_stat_item_desc *desc, int32_t value); }; -struct stats_config { +struct osmo_stats_config { int interval; }; -extern struct stats_config *stats_config; +extern struct osmo_stats_config *osmo_stats_config; -void stats_init(void *ctx); -int stats_report(); +void osmo_stats_init(void *ctx); +int osmo_stats_report(); -int stats_set_interval(int interval); +int osmo_stats_set_interval(int interval); -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); -void stats_reporter_free(struct stats_reporter *srep); +void osmo_stats_reporter_free(struct osmo_stats_reporter *srep); -struct stats_reporter *stats_reporter_create_statsd(const char *name); -struct stats_reporter *stats_reporter_create_log(const char *name); +struct osmo_stats_reporter *osmo_stats_reporter_create_statsd(const char *name); +struct osmo_stats_reporter *osmo_stats_reporter_create_log(const char *name); -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); -int stats_reporter_set_remote_addr(struct stats_reporter *srep, const char *addr); -int stats_reporter_set_remote_port(struct stats_reporter *srep, int port); -int stats_reporter_set_local_addr(struct stats_reporter *srep, const char *addr); -int stats_reporter_set_mtu(struct stats_reporter *srep, int mtu); -int stats_reporter_set_name_prefix(struct stats_reporter *srep, const char *prefix); -int stats_reporter_enable(struct stats_reporter *srep); -int stats_reporter_disable(struct stats_reporter *srep); +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); +int osmo_stats_reporter_set_local_addr(struct osmo_stats_reporter *srep, const char *addr); +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); +int osmo_stats_reporter_enable(struct osmo_stats_reporter *srep); +int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep); diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h index 42e0d884..7c3b23c1 100644 --- a/include/osmocom/gprs/gprs_ns.h +++ b/include/osmocom/gprs/gprs_ns.h @@ -126,7 +126,7 @@ struct gprs_nsvc { unsigned int nsvci_is_valid:1; struct rate_ctr_group *ctrg; - struct stat_item_group *statg; + struct osmo_stat_item_group *statg; /*! \brief which link-layer are we based on? */ enum gprs_ns_ll ll; diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h index 99c2ee68..f3b46dbd 100644 --- a/include/osmocom/vty/misc.h +++ b/include/osmocom/vty/misc.h @@ -14,7 +14,7 @@ void vty_out_rate_ctr_group(struct vty *vty, const char *prefix, struct rate_ctr_group *ctrg); void vty_out_stat_item_group(struct vty *vty, const char *prefix, - struct stat_item_group *statg); + struct osmo_stat_item_group *statg); void vty_out_statistics_full(struct vty *vty, const char *prefix); diff --git a/include/osmocom/vty/stats.h b/include/osmocom/vty/stats.h index eaf854e5..3851b4df 100644 --- a/include/osmocom/vty/stats.h +++ b/include/osmocom/vty/stats.h @@ -1,3 +1,3 @@ #pragma once -void stats_vty_add_cmds(); +void osmo_stats_vty_add_cmds(); -- cgit v1.2.3 From 34eec7da8dd91c2e812863601ca5f787d6589ecb Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 2 Nov 2015 10:50:50 +0100 Subject: vty: Add reserved nodes to enum node_type Currently every time a node is added to enum node_type, this constitutes an ABI change, since _LAST_OSMOVTY_NODE will get incremented accordingly. In this case, every project that adds new node type based on that value will have to be recompiled. This commit adds 4 spare node type values, which can be replaced one-by-one by new real types until they are exhausted to avoid this kind of ABI change. Sponsored-by: On-Waves ehf --- include/osmocom/vty/command.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h index 890f0d6d..2ef4109e 100644 --- a/include/osmocom/vty/command.h +++ b/include/osmocom/vty/command.h @@ -84,6 +84,15 @@ enum node_type { L_NS_NODE, /*!< \brief NS node in libosmo-gb. */ L_BSSGP_NODE, /*!< \brief BSSGP node in libosmo-gb. */ + /* + * When adding new nodes to the libosmocore project, these nodes can be + * used to avoid ABI changes for unrelated projects. + */ + RESERVED1_NODE, /*!< \brief Reserved for later extensions */ + RESERVED2_NODE, /*!< \brief Reserved for later extensions */ + RESERVED3_NODE, /*!< \brief Reserved for later extensions */ + RESERVED4_NODE, /*!< \brief Reserved for later extensions */ + _LAST_OSMOVTY_NODE }; -- cgit v1.2.3 From bc9d9aced8c174bbb5fc265ec746621d31344be0 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 2 Nov 2015 14:49:35 +0100 Subject: stats: Limit reporting by class id This commit adds class_id fields to the rate_ctr and stat_item group descriptions. The stats reporter code is extended to only process groups whose class_id does not exceed a per reporter max_class level. If the class_id is not set, the code assumes 'global' for groups with idx == 0 and 'subscriber' otherwise. The following vty command is added to config-stats: level (global|peer|subscriber) Set the maximum group level Sponsored-by: On-Waves ehf --- include/osmocom/core/rate_ctr.h | 2 ++ include/osmocom/core/stat_item.h | 2 ++ include/osmocom/core/stats.h | 10 ++++++++++ 3 files changed, 14 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h index f3c03de3..03b1bfbe 100644 --- a/include/osmocom/core/rate_ctr.h +++ b/include/osmocom/core/rate_ctr.h @@ -47,6 +47,8 @@ struct rate_ctr_group_desc { const char *group_name_prefix; /*! \brief The human-readable description of the group */ const char *group_description; + /*! \brief The class to which this group belongs */ + int class_id; /*! \brief The number of counters in this group */ const unsigned int num_ctr; /*! \brief Pointer to array of counter names */ diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h index 40474958..c2ad8cfd 100644 --- a/include/osmocom/core/stat_item.h +++ b/include/osmocom/core/stat_item.h @@ -45,6 +45,8 @@ struct osmo_stat_item_group_desc { const char *group_name_prefix; /*! \brief The human-readable description of the group */ const char *group_description; + /*! \brief The class to which this group belongs */ + int class_id; /*! \brief The number of values in this group */ const unsigned int num_items; /*! \brief Pointer to array of value names */ diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h index 7b3d0211..731fdb9b 100644 --- a/include/osmocom/core/stats.h +++ b/include/osmocom/core/stats.h @@ -28,6 +28,13 @@ struct osmo_stat_item_desc; struct rate_ctr_group; struct rate_ctr_desc; +enum osmo_stats_class { + OSMO_STATS_CLASS_UNKNOWN, + OSMO_STATS_CLASS_GLOBAL, + OSMO_STATS_CLASS_PEER, + OSMO_STATS_CLASS_SUBSCRIBER, +}; + enum osmo_stats_reporter_type { OSMO_STATS_REPORTER_STATSD, OSMO_STATS_REPORTER_LOG, @@ -46,6 +53,7 @@ struct osmo_stats_reporter { char *bind_addr_str; int dest_port; int mtu; + enum osmo_stats_class max_class; /* state */ int running; @@ -95,6 +103,8 @@ int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const int osmo_stats_reporter_set_remote_port(struct osmo_stats_reporter *srep, int port); int osmo_stats_reporter_set_local_addr(struct osmo_stats_reporter *srep, const char *addr); int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu); +int osmo_stats_reporter_set_max_class(struct osmo_stats_reporter *srep, + enum osmo_stats_class class_id); int osmo_stats_reporter_set_name_prefix(struct osmo_stats_reporter *srep, const char *prefix); int osmo_stats_reporter_enable(struct osmo_stats_reporter *srep); int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep); -- cgit v1.2.3 From 79125ecf7d54b04cc56818b6dd99813d0a4daf89 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Mon, 2 Nov 2015 15:17:50 +0100 Subject: log: Add new DLSTATS log level This log level is used by the stats subsystem log reporter to report statistics to level INFO. Note that the default level of DLSTATS is NOTICE. Sponsored-by: On-Waves ehf --- include/osmocom/core/logging.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index ba41762f..1c159d0b 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -69,7 +69,8 @@ void logp(int subsys, const char *file, int line, int cont, const char *format, #define DLSMS -7 #define DLCTRL -8 #define DLGTP -9 -#define OSMO_NUM_DLIB 9 +#define DLSTATS -10 +#define OSMO_NUM_DLIB 10 struct log_category { uint8_t loglevel; -- cgit v1.2.3