[statistics] Provide basic statistics for the NAT
Count number of SCCP connections, number of BSC reconnects, number of calls. For most of them we have a per BSC and a global count. Right now all structs using the counters survive until the end of the application so we do not need to free them.
This commit is contained in:
parent
57f874ad8d
commit
d4702862d3
|
@ -31,6 +31,7 @@
|
|||
#include <osmocore/msgb.h>
|
||||
#include <osmocore/timer.h>
|
||||
#include <osmocore/write_queue.h>
|
||||
#include <osmocore/statistics.h>
|
||||
|
||||
#define DIR_BSC 1
|
||||
#define DIR_MSC 2
|
||||
|
@ -113,6 +114,20 @@ struct sccp_connections {
|
|||
int bsc_timeslot;
|
||||
};
|
||||
|
||||
/**
|
||||
* Stats per BSC
|
||||
*/
|
||||
struct bsc_config_stats {
|
||||
struct {
|
||||
struct counter *conn;
|
||||
struct counter *calls;
|
||||
} sccp;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
} net;
|
||||
};
|
||||
|
||||
/**
|
||||
* One BSC entry in the config
|
||||
*/
|
||||
|
@ -124,6 +139,8 @@ struct bsc_config {
|
|||
int nr;
|
||||
|
||||
struct bsc_nat *nat;
|
||||
|
||||
struct bsc_config_stats stats;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -138,6 +155,25 @@ struct bsc_endpoint {
|
|||
int pending_delete;
|
||||
};
|
||||
|
||||
/**
|
||||
* Statistic for the nat.
|
||||
*/
|
||||
struct bsc_nat_statistics {
|
||||
struct {
|
||||
struct counter *conn;
|
||||
struct counter *calls;
|
||||
} sccp;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
struct counter *auth_fail;
|
||||
} bsc;
|
||||
|
||||
struct {
|
||||
struct counter *reconn;
|
||||
} msc;
|
||||
};
|
||||
|
||||
/**
|
||||
* the structure of the "nat" network
|
||||
*/
|
||||
|
@ -162,6 +198,9 @@ struct bsc_nat {
|
|||
int first_contact;
|
||||
|
||||
struct bsc_endpoint *bsc_endpoints;
|
||||
|
||||
/* statistics */
|
||||
struct bsc_nat_statistics stats;
|
||||
};
|
||||
|
||||
/* create and init the structures */
|
||||
|
|
|
@ -258,7 +258,10 @@ static int forward_sccp_to_bts(struct msgb *msg)
|
|||
case SCCP_MSG_TYPE_IT:
|
||||
con = patch_sccp_src_ref_to_bsc(msg, parsed, nat);
|
||||
if (parsed->gsm_type == BSS_MAP_MSG_ASSIGMENT_RQST) {
|
||||
counter_inc(nat->stats.sccp.calls);
|
||||
|
||||
if (con) {
|
||||
counter_inc(con->bsc->cfg->stats.sccp.conn);
|
||||
if (bsc_mgcp_assign(con, msg) != 0)
|
||||
LOGP(DNAT, LOGL_ERROR, "Failed to assign...\n");
|
||||
} else
|
||||
|
@ -466,6 +469,7 @@ static void ipaccess_auth_bsc(struct tlv_parsed *tvp, struct bsc_connection *bsc
|
|||
|
||||
llist_for_each_entry(conf, &bsc->nat->bsc_configs, entry) {
|
||||
if (strcmp(conf->token, token) == 0) {
|
||||
counter_inc(conf->stats.net.reconn);
|
||||
bsc->authenticated = 1;
|
||||
bsc->cfg = conf;
|
||||
bsc_del_timer(&bsc->id_timeout);
|
||||
|
@ -632,6 +636,9 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* count the reconnect */
|
||||
counter_inc(nat->stats.bsc.reconn);
|
||||
|
||||
/*
|
||||
* if we are not connected to a msc... just close the socket
|
||||
*/
|
||||
|
|
|
@ -45,6 +45,11 @@ struct bsc_nat *bsc_nat_alloc(void)
|
|||
INIT_LLIST_HEAD(&nat->sccp_connections);
|
||||
INIT_LLIST_HEAD(&nat->bsc_connections);
|
||||
INIT_LLIST_HEAD(&nat->bsc_configs);
|
||||
nat->stats.sccp.conn = counter_alloc("nat.sccp.conn");
|
||||
nat->stats.sccp.calls = counter_alloc("nat.sccp.calls");
|
||||
nat->stats.bsc.reconn = counter_alloc("nat.bsc.conn");
|
||||
nat->stats.bsc.auth_fail = counter_alloc("nat.bsc.auth_fail");
|
||||
nat->stats.msc.reconn = counter_alloc("nat.msc.conn");
|
||||
return nat;
|
||||
}
|
||||
|
||||
|
@ -72,6 +77,10 @@ struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, unsi
|
|||
llist_add(&conf->entry, &nat->bsc_configs);
|
||||
++nat->num_bsc;
|
||||
|
||||
conf->stats.sccp.conn = counter_alloc("nat.bsc.sccp.conn");
|
||||
conf->stats.sccp.calls = counter_alloc("nat.bsc.sccp.calls");
|
||||
conf->stats.net.reconn = counter_alloc("nat.bsc.net.reconnects");
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ int create_sccp_src_ref(struct bsc_connection *bsc, struct msgb *msg, struct bsc
|
|||
}
|
||||
|
||||
llist_add(&conn->list_entry, &bsc->nat->sccp_connections);
|
||||
counter_inc(bsc->cfg->stats.sccp.conn);
|
||||
counter_inc(bsc->cfg->nat->stats.sccp.conn);
|
||||
|
||||
LOGP(DNAT, LOGL_DEBUG, "Created 0x%x <-> 0x%x mapping for con %p\n",
|
||||
sccp_src_ref_to_int(&conn->real_ref),
|
||||
|
|
Loading…
Reference in New Issue