mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-sgsn.git
synced 2025-11-03 13:43:16 +00:00
stats: Introduce stats sgsn.iu_peers.{total,active}
Change-Id: I51b5227d92027f1251dc4debbbf59737e7c1a9ba
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <osmocom/core/msgb.h>
|
||||
#include <osmocom/core/select.h>
|
||||
#include <osmocom/core/stat_item.h>
|
||||
#include <osmocom/crypt/gprs_cipher.h>
|
||||
#include <osmocom/gprs/gprs_ns2.h>
|
||||
#include <osmocom/gprs/gprs_bssgp.h>
|
||||
@@ -159,6 +160,7 @@ struct sgsn_instance {
|
||||
struct sgsn_ra_global *routing_area;
|
||||
|
||||
struct rate_ctr_group *rate_ctrs;
|
||||
struct osmo_stat_item_group *statg;
|
||||
|
||||
struct llist_head apn_list; /* list of struct sgsn_apn_ctx */
|
||||
struct llist_head ggsn_list; /* list of struct sgsn_ggsn_ctx */
|
||||
@@ -184,6 +186,21 @@ extern struct osmo_tdef sgsn_T_defs[];
|
||||
extern struct sgsn_instance *sgsn;
|
||||
extern void *tall_sgsn_ctx;
|
||||
|
||||
enum {
|
||||
SGSN_STAT_IU_PEERS_TOTAL,
|
||||
SGSN_STAT_IU_PEERS_ACTIVE,
|
||||
};
|
||||
static inline void sgsn_stat_inc(unsigned int idx, int32_t value)
|
||||
{
|
||||
osmo_stat_item_inc(osmo_stat_item_group_get_item(sgsn->statg, idx), value);
|
||||
}
|
||||
|
||||
static inline void sgsn_stat_dec(unsigned int idx, int32_t value)
|
||||
{
|
||||
osmo_stat_item_dec(osmo_stat_item_group_get_item(sgsn->statg, idx), value);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ctrl interface related work (sgsn_ctrl.c)
|
||||
*/
|
||||
|
||||
@@ -76,6 +76,7 @@ static struct ranap_iu_rnc *iu_rnc_alloc(const struct osmo_rnc_id *rnc_id,
|
||||
osmo_rnc_id_name(rnc_id), addr_str);
|
||||
|
||||
llist_add(&rnc->entry, &sgsn->rnc_list);
|
||||
sgsn_stat_inc(SGSN_STAT_IU_PEERS_TOTAL, 1);
|
||||
|
||||
LOGP(DRANAP, LOGL_NOTICE, "New RNC %s at %s\n",
|
||||
osmo_rnc_id_name(&rnc->rnc_id), osmo_sccp_addr_dump(rnc_sccp_addr));
|
||||
|
||||
@@ -216,6 +216,12 @@ static void iu_rnc_st_wait_rx_reset_ack(struct osmo_fsm_inst *fi, uint32_t event
|
||||
}
|
||||
}
|
||||
|
||||
static void iu_rnc_st_ready_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
|
||||
{
|
||||
if (prev_state != IU_RNC_ST_READY)
|
||||
sgsn_stat_inc(SGSN_STAT_IU_PEERS_ACTIVE, 1);
|
||||
}
|
||||
|
||||
static void iu_rnc_st_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
||||
{
|
||||
struct ranap_iu_rnc *rnc = fi->priv;
|
||||
@@ -261,6 +267,12 @@ static void iu_rnc_st_ready(struct osmo_fsm_inst *fi, uint32_t event, void *data
|
||||
}
|
||||
}
|
||||
|
||||
static void iu_rnc_st_ready_onleave(struct osmo_fsm_inst *fi, uint32_t next_state)
|
||||
{
|
||||
if (next_state != IU_RNC_ST_READY)
|
||||
sgsn_stat_dec(SGSN_STAT_IU_PEERS_ACTIVE, 1);
|
||||
}
|
||||
|
||||
static int iu_rnc_fsm_timer_cb(struct osmo_fsm_inst *fi)
|
||||
{
|
||||
struct ranap_iu_rnc *rnc = fi->priv;
|
||||
@@ -273,6 +285,10 @@ static void iu_rnc_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_caus
|
||||
struct ranap_iu_rnc *rnc = fi->priv;
|
||||
|
||||
iu_rnc_discard_all_ue_ctx(rnc);
|
||||
|
||||
if (rnc->fi->state == IU_RNC_ST_READY)
|
||||
sgsn_stat_dec(SGSN_STAT_IU_PEERS_ACTIVE, 1);
|
||||
sgsn_stat_dec(SGSN_STAT_IU_PEERS_TOTAL, 1);
|
||||
}
|
||||
|
||||
static const struct osmo_fsm_state iu_rnc_fsm_states[] = {
|
||||
@@ -314,6 +330,8 @@ static const struct osmo_fsm_state iu_rnc_fsm_states[] = {
|
||||
[IU_RNC_ST_READY] = {
|
||||
.name = "READY",
|
||||
.action = iu_rnc_st_ready,
|
||||
.onenter = iu_rnc_st_ready_onenter,
|
||||
.onleave = iu_rnc_st_ready_onleave,
|
||||
.in_event_mask = 0
|
||||
| S(IU_RNC_EV_RX_RESET)
|
||||
| S(IU_RNC_EV_MSG_UP_CO_INITIAL)
|
||||
|
||||
@@ -103,6 +103,20 @@ static const struct rate_ctr_group_desc sgsn_ctrg_desc = {
|
||||
sgsn_ctr_description,
|
||||
};
|
||||
|
||||
|
||||
static const struct osmo_stat_item_desc sgsn_stat_item_description[] = {
|
||||
[SGSN_STAT_IU_PEERS_TOTAL] = { "iu_peers:total", "Total Iu peers (RNC, HNBGW) seen since startup", OSMO_STAT_ITEM_NO_UNIT, 4, 0},
|
||||
[SGSN_STAT_IU_PEERS_ACTIVE] = { "iu_peers:active", "Currently active Iu peers (RANAP ready)", OSMO_STAT_ITEM_NO_UNIT, 4, 0},
|
||||
};
|
||||
|
||||
static const struct osmo_stat_item_group_desc sgsn_statg_desc = {
|
||||
"sgsn",
|
||||
"serving GPRS support node statistics",
|
||||
OSMO_STATS_CLASS_GLOBAL,
|
||||
ARRAY_SIZE(sgsn_stat_item_description),
|
||||
sgsn_stat_item_description,
|
||||
};
|
||||
|
||||
static void sgsn_llme_cleanup_free(struct gprs_llc_llme *llme)
|
||||
{
|
||||
struct sgsn_mm_ctx *mmctx = NULL;
|
||||
@@ -161,6 +175,7 @@ static int sgsn_instance_talloc_destructor(struct sgsn_instance *sgi)
|
||||
#endif /* #if BUILD_IU */
|
||||
osmo_timer_del(&sgi->llme_timer);
|
||||
rate_ctr_group_free(sgi->rate_ctrs);
|
||||
osmo_stat_item_group_free(sgi->statg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -185,6 +200,8 @@ struct sgsn_instance *sgsn_instance_alloc(void *talloc_ctx)
|
||||
|
||||
inst->rate_ctrs = rate_ctr_group_alloc(inst, &sgsn_ctrg_desc, 0);
|
||||
OSMO_ASSERT(inst->rate_ctrs);
|
||||
inst->statg = osmo_stat_item_group_alloc(inst, &sgsn_statg_desc, 0);
|
||||
OSMO_ASSERT(inst->statg);
|
||||
|
||||
INIT_LLIST_HEAD(&inst->apn_list);
|
||||
INIT_LLIST_HEAD(&inst->ggsn_list);
|
||||
|
||||
Reference in New Issue
Block a user