aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/gsm_data.h5
-rw-r--r--openbsc/include/openbsc/gsm_data_shared.h2
-rw-r--r--openbsc/src/libbsc/chan_alloc.c3
-rw-r--r--openbsc/src/libcommon/gsm_data_shared.c19
4 files changed, 28 insertions, 1 deletions
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index b12c4edc3..b823acc65 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -10,6 +10,7 @@
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/select.h>
#include <osmocom/core/stats.h>
+#include <osmocom/core/stat_item.h>
#include <osmocom/crypt/auth.h>
@@ -175,6 +176,10 @@ struct gsm_subscriber_connection {
#define ROLE_BSC
#include "gsm_data_shared.h"
+enum {
+ BTS_STAT_CHAN_LOAD_AVERAGE,
+ BTS_STAT_T3122,
+};
enum {
BSC_CTR_CHREQ_TOTAL,
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index a78e2eb7a..47c5faef4 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -907,6 +907,8 @@ struct gsm_bts {
char *pcu_sock_path;
struct pcu_sock_state *pcu_state;
+ struct osmo_stat_item_group *bts_statg;
+
/* BTS-specific overrides for timer values from struct gsm_network. */
uint8_t T3122; /* ASSIGMENT REJECT wait indication */
diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c
index 2fd197f60..b27ac8fd2 100644
--- a/openbsc/src/libbsc/chan_alloc.c
+++ b/openbsc/src/libbsc/chan_alloc.c
@@ -609,6 +609,8 @@ bts_update_t3122_chan_load(struct gsm_bts *bts)
load = ((used / total) * 100);
LOGP(DRLL, LOGL_DEBUG, "(bts=%d) channel load average is %lu.%.2lu%%\n",
bts->nr, (load & 0xffffff00) >> 8, (load & 0xff) / 10);
+ osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_LOAD_AVERAGE],
+ (load & 0xffffff00) >> 8);
/* Calculate new T3122 wait indicator. */
wait_ind = ((used / total) * max_wait_ind);
@@ -620,4 +622,5 @@ bts_update_t3122_chan_load(struct gsm_bts *bts)
LOGP(DRLL, LOGL_DEBUG, "(bts=%d) T3122 wait indicator set to %lu seconds\n", bts->nr, wait_ind);
bts->T3122 = (uint8_t)wait_ind;
+ osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_T3122], wait_ind);
}
diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index a1d7a50b4..37baec341 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -30,10 +30,24 @@
#include <osmocom/core/talloc.h>
#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/gsm/abis_nm.h>
-#include <osmocom/core/statistics.h>
+#include <osmocom/core/counter.h>
+#include <osmocom/core/stats.h>
#include <openbsc/gsm_data.h>
+static const struct osmo_stat_item_desc bts_stat_desc[] = {
+ { "chanloadavg", "Channel load average.", "%", 16, 0 },
+ { "T3122", "T3122 IMMEDIATE ASSIGNMENT REJECT wait indicator.", "s", 16, GSM_T3122_DEFAULT },
+};
+
+static const struct osmo_stat_item_group_desc bts_statg_desc = {
+ .group_name_prefix = "bts",
+ .group_description = "base transceiver station",
+ .class_id = OSMO_STATS_CLASS_GLOBAL,
+ .num_items = ARRAY_SIZE(bts_stat_desc),
+ .item_desc = bts_stat_desc,
+};
+
void gsm_abis_mo_reset(struct gsm_abis_mo *mo)
{
mo->nm_state.operational = NM_OPSTATE_NULL;
@@ -347,9 +361,12 @@ struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num)
memcpy(&bts->gprs.cell.rlc_cfg, &rlc_cfg_default,
sizeof(bts->gprs.cell.rlc_cfg));
+ bts->bts_statg = osmo_stat_item_group_alloc(bts, &bts_statg_desc, 0);
+
/* create our primary TRX */
bts->c0 = gsm_bts_trx_alloc(bts);
if (!bts->c0) {
+ osmo_stat_item_group_free(bts->bts_statg);
talloc_free(bts);
return NULL;
}