Commit Graph

1445 Commits

Author SHA1 Message Date
Holger Hans Peter Freyther abc46af90f debian: Make a new minor release 2015-11-09 21:35:20 +01:00
Jacob Erlbeck 01e8c91df5 stats: Fix not reported stat item values
Currently the global stat item index is being advanced in
osmo_stat_item_group_handler, so that the second and further groups
in the list will skip new item values.

This commit moves the call to osmo_stat_item_discard_all into
osmo_stats_report to a place where all groups have been processed
already.

Sponsored-by: On-Waves ehf
2015-11-09 14:49:52 +01:00
Jacob Erlbeck 8a97cb9111 stats: Fix handling of multiple resporters
Currently the reporter loop is aborted, if the event would be ignored
due to an insufficient max_level. Thus the reporters that happen to
be stored afterwards would be skipped even if their level were
sufficient.

This commit replaces the conditional 'return' statement by a
considtional 'continue' statement to ensure the processing of the
list tail.

Sponsored-by: On-Waves ehf
2015-11-09 14:49:52 +01:00
Jacob Erlbeck aed7c125fd stats: Send all values on reporter update
Currently only counter changes and new item values are being
reported. This makes it cumbersome to configure reporting clients,
since there is nothing like a list of all parameters.

This commit changes this behaviour such that all currently existing
counters and items that would be reported eventually, are passed to
the reporter when it has been reconfigured or enabled. If a counter
has not been incremented, 0 is sent. If a stat item value has not
been added, the last item value (or the default value if there is
none) is resent again.

Note that this will not catch transient counters/items that will be
created later on, e.g. triggered by new peers or subscribers.

To just force this kind of dump on a running reporter, it is
sufficient to invoke the 'enable' command in its configuration node.

Sponsored-by: On-Waves ehf
2015-11-09 14:49:49 +01:00
Jacob Erlbeck 916423ef95 stats: Fix name prefix handling
Currently the having an unset prefix leads to an abort() in the
statsd reporter due to an fprintf format string error. In addition
the prefix cannot be reset to its initial state (NULL) by using 'no
prefix', which just sets the prefix to the empty string, causing a
single leading dot to appear in front of the name.

This commit changes the implemenation to consistly use NULL for
the unset name prefix ('no prefix') and to handle this case correctly
in the statsd reporter.

Sponsored-by: On-Waves ehf
2015-11-09 10:52:19 +01:00
Holger Hans Peter Freyther 834819471a stats: Document the level in show stats level options
Potentially Fixes:

<command id='show stats level (global|peer|subscriber)'>
        <param name='subscriber' doc='(null)' />
2015-11-07 21:11:14 +01:00
Alexander Huemer aab4a2497c osmo-sim-test: add missing include 2015-11-07 12:30:38 +01:00
Holger Hans Peter Freyther eed4695d06 debian: Roll a new release with the GPRS NS counter fix 2015-11-04 14:48:13 +01:00
Holger Hans Peter Freyther 495b0dbd24 gprs-ns/stats: When the NSVCI is updated, update the stats counter
The NS object is created with an unknown identity and only after
the reset procedure has progressed (completed?) we know the real
ID for this peer. Before nobody has looked at the idx values (this
could have been seen with the CTRL interface) but with statsd the
wrong NSVCI becomes obvious.

Add routines to update the idx and I don't know if the change of
idx is causing any issues but we will find that out soon.
2015-11-04 14:39:37 +01:00
Holger Hans Peter Freyther 6e149b1f1a debian: Make new minor release with the NS bugfix 2015-11-04 10:23:57 +01:00
Jacob Erlbeck 59b90bc444 stats/vty: Add selective show stats command
Currently there is only the 'show stats' command which shows all
counter and stat_item values. This can lead to many lines of output
if there are per-subscriber rate counters.

The new command added by this commit allows it to only show groups of
a certain level (class_id), similar to the 'level' configuration
command for stats reporter.

The new command is

  show stats level (global|peer|subscriber)

Sponsored-by: On-Waves ehf
2015-08-22 01:47:55 +00:00
Jacob Erlbeck fed2a488b9 ns/stats: Fix class_id of "NSVC Peer Statistics" rate_ctr group
Currently the class_id is not set which effectively puts these groups
into the 'subscriber' class.

This commit adds the missing initialisation value.

Sponsored-by: On-Waves ehf
2015-08-22 01:35:24 +00:00
Jacob Erlbeck be37fb7db4 stats/test: Add tests to check VTY configuration
This commit adds tests to verify the stats related VTY configuration
commands.

Sponsored-by: On-Waves ehf
2015-08-22 01:34:05 +00:00
Jacob Erlbeck ca6602f476 vty/test: Refactor vty creation/deletion into separate functions
Currently this is part of the only test function that uses the
vty directly.

In preperation for more such test cases, this commit moves this code
into separate functions.

Sponsored-by: On-Waves ehf
2015-08-22 01:31:31 +00:00
Jacob Erlbeck ee2657f6af test: Remove unneeded linking to libosmovty.la
The addition of libosmovty.la to several test cases as done in
commit 738d9e2210 (stats: Add vty_out_stat_item_group)
is not needed.

This commit removes them.

Sponsored-by: On-Waves ehf
2015-08-22 01:31:23 +00:00
Holger Hans Peter Freyther bb4ae64fbb debian: Install libosmoctrl0 too when installing the dev package 2015-11-03 11:36:18 +01:00
Holger Hans Peter Freyther 8649d57f50 misc: Prepare the release of libosmocore 0.9.0
Bump the ABI version of libosmovty and we need to do this
recursively to force rebuilds of our software.
2015-11-03 09:32:32 +01:00
Holger Hans Peter Freyther c337693c4c stats: Fix build on FreeBSD
include stdint.h for int64_t and use netinet/in.h and not
netinet/ip.h for getting sockaddr_in and such.
2015-08-21 19:56:54 +00:00
Holger Hans Peter Freyther 3f838b717e timer: Fix compiler warning about timeval
timer.c:27:23: warning: tentative definition of variable with internal linkage has incomplete
      non-array type 'struct timeval' [-Wtentative-definition-incomplete-type]
static struct timeval nearest;
                      ^
timer.c:27:15: note: forward declaration of 'struct timeval'
static struct timeval nearest;
2015-08-21 19:45:08 +00:00
Neels Hofmeyr 07cf861e25 gtphub: add OSMO_VTY_PORT_GTPHUB.
This is for gtphub, being developed in openbsc.git.

Sponsored-by: On-Waves ehi
2015-11-02 20:24:06 +01:00
Neels Hofmeyr 667e83d71e fix some typos
Sponsored-by: On-Waves ehi
2015-11-02 20:23:34 +01:00
Holger Hans Peter Freyther d7b0577d7d Merge branch 'jerlbeck/wip/stats'
* This adds a new counter type (to measure time or delay)
* A statsd reporting backend. This can be fed into graphite
or similar tools.
* A periodic log backend for performance values
2015-11-02 15:57:34 +01:00
Holger Hans Peter Freyther 8f0374f752 stats: Fix handling of the no mtu command
For the atoi we need to pass the val as a string. This means
we need to write "0" which then gets parsed to 0.

[src/vty/stats_vty.c:90]: (error) Possible null pointer dereference: val
2015-11-02 15:53:09 +01:00
Holger Hans Peter Freyther 7921975989 stats: Do not assign the wrong addresss
we need to put the default value into inaddr and not put a
32bit value into the addr pointer.

Spotted by cppcheck:
[src/stats.c:231]: (error) Uninitialized variable: inaddr
2015-11-02 15:50:32 +01:00
Holger Hans Peter Freyther 837e940627 stats: Remove warnings about never read variables
Nothing is being done with these return values. Remove them
for now and update the TODO entry that is present at two of
the three places.

stats.c: In function ‘rate_ctr_handler’:
stats.c:570:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
stats.c: In function ‘osmo_stat_item_handler’:
stats.c:617:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
      ^
stats.c: In function ‘handle_counter’:
stats.c:651:6: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
  int rc;
2015-11-02 15:44:26 +01:00
Jacob Erlbeck 79125ecf7d 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
2015-11-02 15:39:31 +01:00
Jacob Erlbeck bc9d9aced8 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
2015-11-02 15:39:31 +01:00
Jacob Erlbeck 16fe8dab7c stats: Report group indices as unsigned int
Currently the unsigned group index value is silently being cast to
(signed) int in the log and statsd reporter code. If the resulting
value is negative (which can happen for instance with MMCTX
counters), the index is assumed to be unset.

This commit changes the affected types to unsigned. The index value 0
is then the only value indicating an unset group.

Sponsored-by: On-Waves ehf
2015-11-02 15:39:31 +01:00
Jacob Erlbeck 34eec7da8d 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
2015-11-02 15:39:31 +01:00
Jacob Erlbeck fc9533d6c4 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]
2015-11-02 15:39:01 +01:00
Jacob Erlbeck bc4f7ae512 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
2015-10-29 01:10:07 +01:00
Jacob Erlbeck 490b38f57a 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
2015-10-29 01:10:07 +01:00
Jacob Erlbeck ed197fd4f9 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
2015-10-29 01:10:06 +01:00
Jacob Erlbeck 4aa1177062 stats: Add missing mtu command to 'write' output
Currently the config_write_stats_reporter function does not output
the mtu value, which is fixed by this commit.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck d01acfcc75 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
2015-10-29 01:10:06 +01:00
Jacob Erlbeck c8f47b600f stats: Add support for osmo_counters
This commit changes the reporting code to also show all modified
osmo_counter values. Since there is no grouping of these values, the
name string just consists of the optional prefix and the counter
name.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck 80db4ec387 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
2015-10-29 01:10:06 +01:00
Jacob Erlbeck c27671c109 stats: Report stat item values
Currently only rate counter are being supported.

This commit adds support for stat items. All groups are polled for
changed values.

Sponsored-by: On-Waves ehf
2015-10-29 01:10:06 +01:00
Jacob Erlbeck b1dbfb4c41 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
2015-10-29 01:10:06 +01:00
Jacob Erlbeck adc900e0e3 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
2015-10-29 01:10:06 +01:00
Jacob Erlbeck 95bf828003 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
2015-10-29 01:10:03 +01:00
Jacob Erlbeck 45513e6040 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
2015-10-29 00:09:04 +01:00
Jacob Erlbeck 7211fe157e 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
2015-10-28 23:53:46 +01:00
Jacob Erlbeck aec583f687 stat/vty: Use the iterator algorithms to show ctrg and statg
Currently the groups for stat_items and counter are iterated
manually.

This commit makes use of the new iterator functions to access the
single elements via handlers.

Sponsored-by: On-Waves ehf
2015-10-28 23:53:45 +01:00
Jacob Erlbeck e5b0fe2e3c 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
2015-10-28 23:53:45 +01:00
Jacob Erlbeck c6a7108828 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
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 423c1e5a4f 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
2015-10-28 23:51:24 +01:00
Jacob Erlbeck b27b352e93 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
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 0a1400fc83 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
2015-10-28 23:51:24 +01:00
Jacob Erlbeck 738d9e2210 stats: Add vty_out_stat_item_group
This functions dumps a whole stat item group to the VTY.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:12 +01:00