aboutsummaryrefslogtreecommitdiffstats
path: root/src/stat_item.c
AgeCommit message (Collapse)AuthorFilesLines
2023-01-18Move src/*.{c,h} to src/core/Pau Espin Pedrol1-463/+0
This way we have all libosmocore.so in an own subdir instead of having lots of files in the parent dir, which also contains subdirs to other libraries. This also matches the schema under include/osmocom/. Change-Id: I6c76fafebdd5e961aed88bbecd2c16bc69d580e2
2021-12-15stat_item: tolerate NULL pointer argument in osmo_stat_item_group_freePhilipp Maier1-0/+3
Just like rate_ctr_group_free, osmo_stat_item_group_free should tolerate it when the argument is NULL Change-Id: I23323833e7268356a50c4fc6a19639c4ecd2a101
2021-12-14treewide: remove FSF addressOliver Smith1-4/+0
Remove the paragraph about writing to the Free Software Foundation's mailing address. The FSF has changed addresses in the past, and may do so again. In 2021 this is not useful, let's rather have a bit less boilerplate at the start of source files. Change-Id: I5050285e75cf120407a1d883e99b3c4bcae8ffd7
2021-09-30refactor stat_item: get rid of FIFO and "skipped" errorNeels Hofmeyr1-140/+157
Intead of attempting to store all distinct values of a reporting period, just store min, max, last as well as a sum and N of each reporting period. This gets rid of error messages like DLSTATS ERROR stat_item.c:285 num_bts:oml_connected: 44 stats values skipped while at the same time more accurately reporting the max value for each reporting period. (So far stats_item only reports the max value; keep that part unchanged, as shown in stats_test.c.) With the other so far unused values (min, sum), we are ready to also report the minimum value as well as an average value per reporting period in the future, if/when our stats reporter allows for it. Store the complete record of the previous reporting period. So far we only compare the 'max' value, but like this we are ready to also see changes in min, last and average value between reporting periods. This patch breaks API by removing: - struct members osmo_stats_item.stats_next_id, .last_offs and .values[] - struct osmo_stats_item_value - osmo_stat_item_get_next() - osmo_stat_item_discard() - osmo_stat_item_discard_all() and by making struct osmo_stats_item opaque. In libosmocore, we do have a policy of never breaking API. But since the above should never be accessed by users of the osmo_stats_item API -- or if they are, would no longer yield useful results, we decided to make an exception in this case. The alternative would be to introduce a new osmo_stats_item2 API and maintaining an unused legacy osmo_stats_item forever, but we decided that the effort is not worth it. There are no known users of the removed items. Related: SYS#5542 Change-Id: I137992a5479fc39bbceb6c6c2af9c227bd33b39b
2021-09-20stat_item: cosmetic: s/desc/group_desc in osmo_stat_item_group_alloc()Neels Hofmeyr1-9/+9
There also is an osmo_stat_item_desc, so the name 'desc' makes it hard to read the code / the upcoming refactoring patches. It is an osmo_stat_item_group_desc, so call it group_desc. Related: SYS#5542 Change-Id: I07bc011450549a44ebf043e7d8a70718ddfd900e
2021-09-14add osmo_stat_item_get_group_by_name_idxname()Neels Hofmeyr1-0/+20
Add "missing" API for looking up a stat_item_group by its index-name. A subsequent patch, which adds stat_items to the CTRL interface, will use this to look up stat item groups by object name. In stat item groups, there are group names, having a number of indexes denoting different objects. An object can have, besides the index, also a name that is equivalent to the index. Apologies for the weird function name, it's still the best one I could come up with: "group_by_name" refers to the group name, and "idxname" refers to the name that the object index is associated with. We already have osmo_stat_item_get_group_by_name_idx(). Other contestants for name of this new function were: - osmo_stat_item_get_group_by_name_name() because there is a "name" instead of "idx", but I find it confusing. - osmo_stat_item_get_group_by_name_idx_name() but I find that the last "name" should be closer to the "idx". Related: SYS#5542 Change-Id: Ia1a77a1e4657ba624dd4f4bf7ad274e7751d0141
2021-06-05stat,rate_ctr: Allow setting group name and use it at report timePau Espin Pedrol1-0/+10
This patch adds a new field "name" to the rate_ctr and osmo_stat_item_group structs, together with an API to set it. This new field allows for easy identification of specific group instances when several of them exists, rather than using a sometimes random/increasing index value. If set, this name (string) is used instead of the index by the stats reporter. The name, if set, is also printed during "show stats" VTY commands. It's up to the user or application to set up unique or meaningful names to fullfill one's needs. WARNING: this commit breaks ABI and possibly creates unexpected behavior when run with non-rebuilt apps which use the modified structs directly to get the coutners, or if use the static inline API rate_ctr_inc2(). Existing users of these structs should migrate to use new APIs introduced in follow-up commits instead of accessing the field directly. Related: SYS#5456 Change-Id: I0dc510783dd9ae8436dae8005a7b3330e80d36f3
2021-06-01stat,rate_ctr: Introduce new API to get counter at given indexPau Espin Pedrol1-0/+10
Having this API and forcing apps to use it will allow easily adding new members to the group structure without having so much impact in users of this struct. Related: SYS#5456 Change-Id: Iebbf401f11e36645f8964d389460918eb9e0910e
2021-04-07stats: log error when missing stats values (v2)Oliver Smith1-0/+4
Related: SYS#4877 Change-Id: I5140d967c2f1d36dadf93b03e52b9bbd42e2a3a6
2021-04-07stat_item: make value ids item specificOliver Smith1-19/+17
Fix counting of values missed because of FIFO overflow in osmo_stat_item_get_next(), by assigning a new item value id effectively as item->value[n + 1].id = item->value[n].id + 1, instead of increasing a global_value_id that is shared between all items and groups. With global_value_id, the count of values missed was wrong for one item, as soon as a new value was added to another item. This partially reverts b27b352e ("stats: Use a global index for stat item values") from 2015, right after stats was added to libosmocore. It was supposed to make multiple readers (reporters) possible, which could read independently from stat_item (and later added comments explain it like that). But this remained unused, stats has implemented multiple reporters by reading all stat_items once and sending the same data to all enabled reporters. The patch caused last_value_index in struct osmo_stat_item to always remain at -1. Replace this unused last_value_index with stats_next_id, so stats can store the item-specific next_id in the struct again. It appears that stats is the only direct user of osmo_stat_item, but if there are others, they can bring their own item-specific next_id: functions in stat_item.c still accept a next_id argument. Related: OS#5088 Change-Id: Ie65dcdf52c8fc3d916e20d7f0455f6223be6b64f
2021-04-06stat_item: add comment with struct overviewOliver Smith1-0/+17
Related: OS#5088 Change-Id: Ic63a5884da778938197c658c5f478c23a85a4587
2021-04-06stat_item: make next_id argument name consistentOliver Smith1-20/+20
Let osmo_stat_item_get_next, osmo_stat_item_discard, osmo_stat_item_discard_all consistently refer to their next_id arg as such (and not idx or next_idx). It refers to an ID (item->values[i].id), not an index (item->values[i]), and it is always the next one, never the current one. Do the same change for _index/_idx variables in stats.c, which are used as arguments to these functions. Replace rd_ with next_id_ in stats_test.c, too. Related: OS#5088 Change-Id: I5dd566b08dff7174d1790f49abd2d6ac020e120e
2021-03-19Revert "stats: log error when missing stats values"Oliver Smith1-5/+0
This reverts commit d290439b4afe928e7e341540cb92f1abf36a82cb, which caused "stats values skipped" messages to appear even if they were not skipped. Revert for now, replace with a proper version in the future. Related: SYS#4877 Change-Id: Ib43bd53188a4d31d771feb921ea14abe1a3ec877
2021-03-17stats: log error when missing stats valuesOliver Smith1-0/+5
Let the user know when the stats were not consumed fast enough for the given FIFO length. Related: SYS#4877 Change-Id: If0e8ab55103007693101538fb6ea310075217774
2020-07-17stat_item: Add function to reset stat items and groupsDaniel Willmann1-0/+29
Change-Id: I80fc0ea8865ec4efdcd4c982e69d863275fd9919 Related: SYS#4877
2019-05-07add osmo_stat_item_inc/osmo_stat_item_dec to set it relativeAlexander Couzens1-0/+24
Change-Id: Id2462c4866bd22bc2338c9c8f69b775f88ae7511
2017-11-13Fix/Update copyright notices; Add SPDX annotationHarald Welte1-1/+3
Let's fix some erroneous/accidential references to wrong license, update copyright information where applicable and introduce a SPDX-License-Identifier to all files. Change-Id: I39af26c6aaaf5c926966391f6565fc5936be21af
2017-10-16[doc] stat_item: Complete doxygen documentation for APIHarald Welte1-9/+76
The stat_item code base had some incomplete doxygen documentation so far. Let's complete it, and at the same time fix some cosmetic as well as copy+paste issues in the existing documentation bits. Change-Id: Ib514c137b40bf7b9791bd74be99af0b65575f2b6
2017-06-23doxygen: unify use of \file across the boardNeels Hofmeyr1-7/+5
Considering the various styles and implications found in the sources, edit scores of files to follow the same API doc guidelines around the doxygen grouping and the \file tag. Many files now show a short description in the generated API doc that was so far only available as C comment. The guidelines and reasoning behind it is documented at https://osmocom.org/projects/cellular-infrastructure/wiki/Guidelines_for_API_documentation In some instances, remove file comments and add to the corresponding group instead, to be shared among several files (e.g. bitvec). Change-Id: Ifa70e77e90462b5eb2b0457c70fd25275910c72b
2017-06-23doxygen: enable AUTOBRIEF, drop \briefNeels Hofmeyr1-7/+7
Especially for short descriptions, it is annoying to have to type \brief for every single API doc. Drop all \brief and enable the AUTOBRIEF feature of doxygen, which always takes the first sentence of an API doc as the brief description. Change-Id: I11a8a821b065a128108641a2a63fb5a2b1916e87
2015-12-08stats: Add OSMO prefix to STAT_ITEM_NOVALUE_IDJacob Erlbeck1-3/+3
This symbol is globally visible and therefore should have an OSMO prefix like the other identifiers exported by stat_item.h. Sponsored-by: On-Waves ehf
2015-11-20stat_item.c: Fix compiler warningsHarald Welte1-2/+2
CC stat_item.lo stat_item.c: In function 'osmo_stat_item_group_alloc': stat_item.c:84:28: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] group->items[item_idx] = (void *)items_size; ^ stat_item.c:98:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] ((uint8_t *)items + (int)group->items[item_idx]); ^
2015-11-02stats: Add osmo_ name prefix to identifiersJacob Erlbeck1-31/+31
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-10-28stats: Add stat_item_for_each functionsJacob Erlbeck1-0/+30
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-28stats: Use a global index for stat item valuesJacob Erlbeck1-24/+47
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-28stats: Add stat_item for value monitoringJacob Erlbeck1-0/+215
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