From 50b55ee293479071bd161e8858b757e00d5f44dc Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Wed, 6 May 2020 02:25:21 +0300 Subject: Count dynamic timeslots as TCH/F for the channel load purposes. Change-Id: Iabd70e8adbf15eb3b7a7be597281ea99b352317b --- src/osmo-bsc/chan_alloc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/osmo-bsc/chan_alloc.c b/src/osmo-bsc/chan_alloc.c index 669eb8edb..0964b6121 100644 --- a/src/osmo-bsc/chan_alloc.c +++ b/src/osmo-bsc/chan_alloc.c @@ -58,6 +58,20 @@ void bts_chan_load(struct pchan_load *cl, const struct gsm_bts *bts) if (!nm_is_running(&ts->mo.nm_state)) continue; + /* dynamic timeslots have to be counted separately + * when not in TCH/F or TCH/H mode because they don't + * have an lchan's allocated to them */ + if ( ( ts->pchan_on_init == GSM_PCHAN_TCH_F_TCH_H_PDCH + || ts->pchan_on_init == GSM_PCHAN_TCH_F_PDCH) + && ( ts->pchan_is == GSM_PCHAN_NONE + || ts->pchan_is == GSM_PCHAN_PDCH)) { + pl->total++; + } + + /* count allocated logical channels. + * Note: When GSM_PCHAN_TCH_F_TCH_H_PDCH is allocation + * in TCH/H mode, this leads to changing the total + * count vs the TCH/F allocation */ ts_for_each_lchan(lchan, ts) { /* don't even count CBCH slots in total */ if (lchan->type == GSM_LCHAN_CBCH) -- cgit v1.2.3 From ef803ac96d779b7e9fcf95a32325d528554e41e8 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Wed, 6 May 2020 23:17:49 +0300 Subject: stats: Report per channel type load to statsd counters. Change-Id: I2eac4c93061204aeb8f3d223f7e78158c61c7156 --- include/osmocom/bsc/gsm_data.h | 16 ++++++++++++++ src/osmo-bsc/chan_alloc.c | 50 ++++++++++++++++++++++++++++++++++++++++++ src/osmo-bsc/gsm_data.c | 16 ++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 6996905a4..11a4b5fc2 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -1445,6 +1445,22 @@ static const struct rate_ctr_group_desc bts_ctrg_desc = { enum { BTS_STAT_CHAN_LOAD_AVERAGE, + BTS_STAT_CHAN_CCCH_SDCCH4_USED, + BTS_STAT_CHAN_CCCH_SDCCH4_TOTAL, + BTS_STAT_CHAN_TCH_F_USED, + BTS_STAT_CHAN_TCH_F_TOTAL, + BTS_STAT_CHAN_TCH_H_USED, + BTS_STAT_CHAN_TCH_H_TOTAL, + BTS_STAT_CHAN_SDCCH8_USED, + BTS_STAT_CHAN_SDCCH8_TOTAL, + BTS_STAT_CHAN_TCH_F_PDCH_USED, + BTS_STAT_CHAN_TCH_F_PDCH_TOTAL, + BTS_STAT_CHAN_CCCH_SDCCH4_CBCH_USED, + BTS_STAT_CHAN_CCCH_SDCCH4_CBCH_TOTAL, + BTS_STAT_CHAN_SDCCH8_CBCH_USED, + BTS_STAT_CHAN_SDCCH8_CBCH_TOTAL, + BTS_STAT_CHAN_TCH_F_TCH_H_PDCH_USED, + BTS_STAT_CHAN_TCH_F_TCH_H_PDCH_TOTAL, BTS_STAT_T3122, BTS_STAT_RACH_BUSY, BTS_STAT_RACH_ACCESS, diff --git a/src/osmo-bsc/chan_alloc.c b/src/osmo-bsc/chan_alloc.c index 0964b6121..bea16201c 100644 --- a/src/osmo-bsc/chan_alloc.c +++ b/src/osmo-bsc/chan_alloc.c @@ -101,6 +101,53 @@ void network_chan_load(struct pchan_load *pl, struct gsm_network *net) bts_chan_load(pl, bts); } +static void chan_load_stat_set(enum gsm_phys_chan_config pchan, + struct gsm_bts *bts, + struct load_counter *lc) +{ + switch (pchan) { + case GSM_PCHAN_NONE: + case GSM_PCHAN_CCCH: + case GSM_PCHAN_PDCH: + case GSM_PCHAN_UNKNOWN: + break; + case GSM_PCHAN_CCCH_SDCCH4: + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_CCCH_SDCCH4_USED], lc->used); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_CCCH_SDCCH4_TOTAL], lc->total); + break; + case GSM_PCHAN_TCH_F: + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_TCH_F_USED], lc->used); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_TCH_F_TOTAL], lc->total); + break; + case GSM_PCHAN_TCH_H: + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_TCH_H_USED], lc->used); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_TCH_H_TOTAL], lc->total); + break; + case GSM_PCHAN_SDCCH8_SACCH8C: + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_SDCCH8_USED], lc->used); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_SDCCH8_TOTAL], lc->total); + break; + case GSM_PCHAN_TCH_F_PDCH: + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_TCH_F_PDCH_USED], lc->used); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_TCH_F_PDCH_TOTAL], lc->total); + break; + case GSM_PCHAN_CCCH_SDCCH4_CBCH: + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_CCCH_SDCCH4_CBCH_USED], lc->used); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_CCCH_SDCCH4_CBCH_TOTAL], lc->total); + break; + case GSM_PCHAN_SDCCH8_SACCH8C_CBCH: + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_SDCCH8_CBCH_USED], lc->used); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_SDCCH8_CBCH_TOTAL], lc->total); + break; + case GSM_PCHAN_TCH_F_TCH_H_PDCH: + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_TCH_F_TCH_H_PDCH_USED], lc->used); + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_CHAN_TCH_F_TCH_H_PDCH_TOTAL], lc->total); + break; + default: + LOG_BTS(bts, DRLL, LOGL_NOTICE, "Unknown channel type %d\n", pchan); + } +} + /* Update T3122 wait indicator based on samples of BTS channel load. */ void bts_update_t3122_chan_load(struct gsm_bts *bts) @@ -125,6 +172,9 @@ bts_update_t3122_chan_load(struct gsm_bts *bts) for (i = 0; i < ARRAY_SIZE(pl.pchan); i++) { struct load_counter *lc = &pl.pchan[i]; + /* Export channel load to stats gauges */ + chan_load_stat_set(i, bts, lc); + /* Ignore samples too large for fixed-point calculations (shouldn't happen). */ if (lc->used > UINT16_MAX || lc->total > UINT16_MAX) { LOG_BTS(bts, DRLL, LOGL_NOTICE, "numbers in channel load sample " diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c index fe421a4bf..f61335fc7 100644 --- a/src/osmo-bsc/gsm_data.c +++ b/src/osmo-bsc/gsm_data.c @@ -371,6 +371,22 @@ void gsm_bts_set_radio_link_timeout(struct gsm_bts *bts, int value) static const struct osmo_stat_item_desc bts_stat_desc[] = { { "chanloadavg", "Channel load average.", "%", 16, 0 }, + { "chan_ccch_sdcch4_used", "Number of CCCH+SDCCH4 channels used.", "", 16, 0 }, + { "chan_ccch_sdcch4_total", "Number of CCCH+SDCCH4 channels total.", "", 16, 0 }, + { "chan_tch_f_used", "Number of TCH/F channels used.", "", 16, 0 }, + { "chan_tch_f_total", "Number of TCH/F channels total.", "", 16, 0 }, + { "chan_tch_h_used", "Number of TCH/H channels used.", "", 16, 0 }, + { "chan_tch_h_total", "Number of TCH/H channels total.", "", 16, 0 }, + { "chan_sdcch8_used", "Number of SDCCH8 channels used.", "", 16, 0 }, + { "chan_sdcch8_total", "Number of SDCCH8 channels total.", "", 16, 0 }, + { "chan_tch_f_pdch_used", "Number of TCH/F_PDCH channels used.", "", 16, 0 }, + { "chan_tch_f_pdch_total", "Number of TCH/F_PDCH channels total.", "", 16, 0 }, + { "chan_ccch_sdcch4_cbch_used", "Number of CCCH+SDCCH4+CBCH channels used.", "", 16, 0 }, + { "chan_ccch_sdcch4_cbch_total", "Number of CCCH+SDCCH4+CBCH channels total.", "", 16, 0 }, + { "chan_sdcch8_cbch_used", "Number of SDCCH8+CBCH channels used.", "", 16, 0 }, + { "chan_sdcch8_cbch_total", "Number of SDCCH8+CBCH channels total.", "", 16, 0 }, + { "chan_tch_f_tch_h_pdch_used", "Number of TCH/F_TCH/H_PDCH channels used.", "", 16, 0 }, + { "chan_tch_f_tch_h_pdch_total", "Number of TCH/F_TCH/H_PDCH channels total.", "", 16, 0 }, { "T3122", "T3122 IMMEDIATE ASSIGNMENT REJECT wait indicator.", "s", 16, GSM_T3122_DEFAULT }, { "rach_busy", "RACH slots with signal above threshold", "%", 16, 0 }, { "rach_access", "RACH slots with access bursts in them", "%", 16, 0 }, -- cgit v1.2.3 From d8835234c5436c0ce781ddbc02b1094fd6dfc4a3 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Thu, 7 May 2020 01:39:21 +0300 Subject: stats: Add a stats gauge for the MSC link status. Change-Id: Ibe4b29056ba704a27b925cfdba49f343ee34f428 --- include/osmocom/bsc/gsm_data.h | 5 +++++ src/osmo-bsc/a_reset.c | 4 ++++ src/osmo-bsc/bsc_init.c | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index 11a4b5fc2..e85796cdf 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -1554,6 +1554,10 @@ static const struct rate_ctr_group_desc bsc_ctrg_desc = { bsc_ctr_description, }; +enum { + BSC_STAT_MSC_LINK, +}; + struct gsm_tz { int override; /* if 0, use system's time zone instead. */ int hr; /* hour */ @@ -1581,6 +1585,7 @@ struct gsm_network { } hodec2; struct rate_ctr_group *bsc_ctrs; + struct osmo_stat_item_group *bsc_statg; unsigned int num_bts; struct llist_head bts_list; diff --git a/src/osmo-bsc/a_reset.c b/src/osmo-bsc/a_reset.c index 3f512781b..9d7be8585 100644 --- a/src/osmo-bsc/a_reset.c +++ b/src/osmo-bsc/a_reset.c @@ -71,7 +71,9 @@ static void fsm_disc_cb(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct reset_ctx *reset_ctx = (struct reset_ctx *)fi->priv; OSMO_ASSERT(reset_ctx); + struct bsc_msc_data *msc = reset_ctx->priv; LOGPFSML(fi, LOGL_NOTICE, "SIGTRAN connection succeeded.\n"); + osmo_stat_item_set(msc->network->bsc_statg->items[BSC_STAT_MSC_LINK], 1); reset_ctx->conn_loss_counter = 0; osmo_fsm_inst_state_chg(fi, ST_CONN, 0, 0); @@ -86,7 +88,9 @@ static void fsm_conn_cb(struct osmo_fsm_inst *fi, uint32_t event, void *data) switch (event) { case EV_N_DISCONNECT: if (reset_ctx->conn_loss_counter >= BAD_CONNECTION_THRESOLD) { + struct bsc_msc_data *msc = reset_ctx->priv; LOGPFSML(fi, LOGL_NOTICE, "SIGTRAN connection down, reconnecting...\n"); + osmo_stat_item_set(msc->network->bsc_statg->items[BSC_STAT_MSC_LINK], 0); osmo_fsm_inst_state_chg(fi, ST_DISC, RESET_RESEND_INTERVAL, RESET_RESEND_TIMER_NO); } else reset_ctx->conn_loss_counter++; diff --git a/src/osmo-bsc/bsc_init.c b/src/osmo-bsc/bsc_init.c index 18776f33d..9d0ee86f3 100644 --- a/src/osmo-bsc/bsc_init.c +++ b/src/osmo-bsc/bsc_init.c @@ -44,6 +44,18 @@ #include #include +static const struct osmo_stat_item_desc bsc_stat_desc[] = { + { "msc_link", "MSC link status.", "", 16, 0 }, +}; + +static const struct osmo_stat_item_group_desc bsc_statg_desc = { + .group_name_prefix = "bsc", + .group_description = "base station controller", + .class_id = OSMO_STATS_CLASS_GLOBAL, + .num_items = ARRAY_SIZE(bsc_stat_desc), + .item_desc = bsc_stat_desc, +}; + int bsc_shutdown_net(struct gsm_network *net) { struct gsm_bts *bts; @@ -268,6 +280,7 @@ static struct gsm_network *bsc_network_init(void *ctx) talloc_free(net); return NULL; } + net->bsc_statg = osmo_stat_item_group_alloc(net, &bsc_statg_desc, 0); INIT_LLIST_HEAD(&net->bts_rejected); gsm_net_update_ctype(net); -- cgit v1.2.3 From 8e198b0ebeedbc46c5b3cf726c88ac2ea84b3251 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Thu, 7 May 2020 02:18:06 +0300 Subject: stats: Export connected OML/RSL links count per BTS and BSC. Change-Id: I88c8025940a0eecb034b1c70f76ea17937fa0325 --- include/osmocom/bsc/gsm_data.h | 4 ++++ src/osmo-bsc/bsc_init.c | 2 ++ src/osmo-bsc/bts_ipaccess_nanobts.c | 8 ++++++++ src/osmo-bsc/gsm_data.c | 2 ++ 4 files changed, 16 insertions(+) diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h index e85796cdf..9a8e002ea 100644 --- a/include/osmocom/bsc/gsm_data.h +++ b/include/osmocom/bsc/gsm_data.h @@ -1464,6 +1464,8 @@ enum { BTS_STAT_T3122, BTS_STAT_RACH_BUSY, BTS_STAT_RACH_ACCESS, + BTS_STAT_NUM_OML_CONNECTED, + BTS_STAT_NUM_RSL_CONNECTED, }; enum { @@ -1556,6 +1558,8 @@ static const struct rate_ctr_group_desc bsc_ctrg_desc = { enum { BSC_STAT_MSC_LINK, + BSC_STAT_NUM_BTS_CONNECTED, + BSC_STAT_NUM_TRX_CONNECTED, }; struct gsm_tz { diff --git a/src/osmo-bsc/bsc_init.c b/src/osmo-bsc/bsc_init.c index 9d0ee86f3..0d5829622 100644 --- a/src/osmo-bsc/bsc_init.c +++ b/src/osmo-bsc/bsc_init.c @@ -46,6 +46,8 @@ static const struct osmo_stat_item_desc bsc_stat_desc[] = { { "msc_link", "MSC link status.", "", 16, 0 }, + { "num_bts_connected", "Number of currently connected BTS (OML links).", "", 16, 0 }, + { "num_trx_connected", "Number of currently connected TRX (RSL links).", "", 16, 0 }, }; static const struct osmo_stat_item_group_desc bsc_statg_desc = { diff --git a/src/osmo-bsc/bts_ipaccess_nanobts.c b/src/osmo-bsc/bts_ipaccess_nanobts.c index a5e697be1..8873ad4cb 100644 --- a/src/osmo-bsc/bts_ipaccess_nanobts.c +++ b/src/osmo-bsc/bts_ipaccess_nanobts.c @@ -397,6 +397,8 @@ void ipaccess_drop_rsl(struct gsm_bts_trx *trx, const char *reason) LOG_TRX(trx, DLINP, LOGL_NOTICE, "Dropping RSL link: %s\n", reason); e1inp_sign_link_destroy(trx->rsl_link); trx->rsl_link = NULL; + osmo_stat_item_set(trx->bts->bts_statg->items[BTS_STAT_NUM_RSL_CONNECTED], 0); + osmo_stat_item_dec(trx->bts->network->bsc_statg->items[BSC_STAT_NUM_TRX_CONNECTED], 1); if (trx->bts->c0 == trx) paging_flush_bts(trx->bts, NULL); @@ -417,6 +419,8 @@ void ipaccess_drop_oml(struct gsm_bts *bts, const char *reason) e1inp_sign_link_destroy(bts->oml_link); bts->oml_link = NULL; bts->uptime = 0; + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_NUM_OML_CONNECTED], 0); + osmo_stat_item_dec(bts->network->bsc_statg->items[BSC_STAT_NUM_BTS_CONNECTED], 1); /* we have issues reconnecting RSL, drop everything. */ llist_for_each_entry(trx, &bts->trx_list, list) @@ -558,6 +562,8 @@ ipaccess_sign_link_up(void *unit_data, struct e1inp_line *line, sign_link->tei, sign_link->sapi); sign_link->trx->bts->ip_access.flags |= OML_UP; } + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_NUM_OML_CONNECTED], 1); + osmo_stat_item_inc(bts->network->bsc_statg->items[BSC_STAT_NUM_BTS_CONNECTED], 1); break; case E1INP_SIGN_RSL: { struct e1inp_ts *ts; @@ -586,6 +592,8 @@ ipaccess_sign_link_up(void *unit_data, struct e1inp_line *line, (RSL_UP << sign_link->trx->nr); } break; + osmo_stat_item_set(bts->bts_statg->items[BTS_STAT_NUM_RSL_CONNECTED], 1); + osmo_stat_item_inc(bts->network->bsc_statg->items[BSC_STAT_NUM_TRX_CONNECTED], 1); } default: break; diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c index f61335fc7..fd90e3a75 100644 --- a/src/osmo-bsc/gsm_data.c +++ b/src/osmo-bsc/gsm_data.c @@ -390,6 +390,8 @@ static const struct osmo_stat_item_desc bts_stat_desc[] = { { "T3122", "T3122 IMMEDIATE ASSIGNMENT REJECT wait indicator.", "s", 16, GSM_T3122_DEFAULT }, { "rach_busy", "RACH slots with signal above threshold", "%", 16, 0 }, { "rach_access", "RACH slots with access bursts in them", "%", 16, 0 }, + { "num_oml_connected", "Number of OML links connected", "", 16, 0 }, + { "num_rsl_connected", "Number of RSL links connected", "", 16, 0 }, }; static const struct osmo_stat_item_group_desc bts_statg_desc = { -- cgit v1.2.3