nat: Switch per BSC counters to the rate ctr.

This is switching the simple statistics to the rate counter
and is updating all users...
This commit is contained in:
Holger Hans Peter Freyther 2010-06-17 18:16:00 +08:00
parent f6d0e06940
commit b2c38ebb1f
5 changed files with 36 additions and 19 deletions

View File

@ -31,6 +31,7 @@
#include <osmocore/msgb.h>
#include <osmocore/timer.h>
#include <osmocore/write_queue.h>
#include <osmocore/rate_ctr.h>
#include <osmocore/statistics.h>
#include <regex.h>
@ -142,14 +143,13 @@ struct sccp_connections {
* Stats per BSC
*/
struct bsc_config_stats {
struct {
struct counter *conn;
struct counter *calls;
} sccp;
struct rate_ctr_group *ctrg;
};
struct {
struct counter *reconn;
} net;
enum bsc_cfg_ctr {
BCFG_CTR_SCCP_CONN,
BCFG_CTR_SCCP_CALLS,
BCFG_CTR_NET_RECONN,
};
/**

View File

@ -411,7 +411,9 @@ static int forward_sccp_to_bts(struct msgb *msg)
counter_inc(nat->stats.sccp.calls);
if (con) {
counter_inc(con->bsc->cfg->stats.sccp.calls);
struct rate_ctr_group *ctrg;
ctrg = con->bsc->cfg->stats.ctrg;
rate_ctr_inc(&ctrg->ctr[BCFG_CTR_SCCP_CALLS]);
if (bsc_mgcp_assign(con, msg) != 0)
LOGP(DNAT, LOGL_ERROR, "Failed to assign...\n");
} else
@ -639,7 +641,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);
rate_ctr_inc(&conf->stats.ctrg->ctr[BCFG_CTR_NET_RECONN]);
bsc->authenticated = 1;
bsc->cfg = conf;
bsc_del_timer(&bsc->id_timeout);
@ -1111,6 +1113,8 @@ int main(int argc, char** argv)
local_addr.s_addr = INADDR_ANY;
handle_options(argc, argv);
rate_ctr_init(tall_bsc_ctx);
/* init vty and parse */
telnet_init(tall_bsc_ctx, NULL, 4244);
if (mgcp_parse_config(config_file, nat->mgcp_cfg) < 0) {

View File

@ -38,6 +38,20 @@
#include <netinet/in.h>
#include <arpa/inet.h>
static const struct rate_ctr_desc bsc_cfg_ctr_description[] = {
[BCFG_CTR_SCCP_CONN] = { "sccp.conn", "SCCP Connections" },
[BCFG_CTR_SCCP_CALLS] = { "sccp.calls", "SCCP Assignment Commands"},
[BCFG_CTR_NET_RECONN] = { "net.reconnects", "Network reconnects"},
};
static const struct rate_ctr_group_desc bsc_cfg_ctrg_desc = {
.group_name_prefix = "nat.bsc",
.group_description = "NAT BSC Statistics",
.num_ctr = ARRAY_SIZE(bsc_cfg_ctr_description),
.ctr_desc = bsc_cfg_ctr_description,
};
struct bsc_nat *bsc_nat_alloc(void)
{
struct bsc_nat *nat = talloc_zero(tall_bsc_ctx, struct bsc_nat);
@ -94,9 +108,11 @@ struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, unsi
llist_add_tail(&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");
conf->stats.ctrg = rate_ctr_group_alloc(conf, &bsc_cfg_ctrg_desc, conf->lac);
if (!conf->stats.ctrg) {
talloc_free(conf);
return NULL;
}
return conf;
}
@ -489,4 +505,4 @@ struct bsc_nat_acc_lst_entry *bsc_nat_acc_lst_entry_create(struct bsc_nat_acc_ls
llist_add_tail(&entry->list, &lst->fltr_list);
return entry;
}
}

View File

@ -27,6 +27,7 @@
#include <openbsc/vty.h>
#include <osmocore/talloc.h>
#include <osmocore/rate_ctr.h>
#include <sccp/sccp.h>
@ -196,11 +197,7 @@ DEFUN(show_stats,
vty_out(vty, " BSC lac: %d nr: %d%s",
conf->lac, conf->nr, VTY_NEWLINE);
vty_out(vty, " SCCP Connnections %lu total, %lu calls%s",
counter_get(conf->stats.sccp.conn),
counter_get(conf->stats.sccp.calls), VTY_NEWLINE);
vty_out(vty, " BSC Connections %lu total%s",
counter_get(conf->stats.net.reconn), VTY_NEWLINE);
vty_out_rate_ctr_group(vty, " ", conf->stats.ctrg);
}
return CMD_SUCCESS;

View File

@ -128,7 +128,7 @@ struct sccp_connections *create_sccp_src_ref(struct bsc_connection *bsc,
bsc_mgcp_init(conn);
llist_add_tail(&conn->list_entry, &bsc->nat->sccp_connections);
counter_inc(bsc->cfg->stats.sccp.conn);
rate_ctr_inc(&bsc->cfg->stats.ctrg->ctr[BCFG_CTR_SCCP_CONN]);
counter_inc(bsc->cfg->nat->stats.sccp.conn);
LOGP(DNAT, LOGL_DEBUG, "Created 0x%x <-> 0x%x mapping for con %p\n",