aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-06-17 18:16:00 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-06-17 18:18:12 +0800
commitb2c38ebb1f2e9f670b3a59caca9e6195277b62be (patch)
tree03fb94bdb12e550b46ec92343212a7fc823282d0 /openbsc
parentf6d0e06940d6430ef58ecd095702e8d1d323d605 (diff)
nat: Switch per BSC counters to the rate ctr.
This is switching the simple statistics to the rate counter and is updating all users...
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/bsc_nat.h14
-rw-r--r--openbsc/src/nat/bsc_nat.c8
-rw-r--r--openbsc/src/nat/bsc_nat_utils.c24
-rw-r--r--openbsc/src/nat/bsc_nat_vty.c7
-rw-r--r--openbsc/src/nat/bsc_sccp.c2
5 files changed, 36 insertions, 19 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index cb0f76188..bb2d5df95 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -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,
};
/**
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 431e6406c..0f50a2b83 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -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) {
diff --git a/openbsc/src/nat/bsc_nat_utils.c b/openbsc/src/nat/bsc_nat_utils.c
index eed7f3a55..d21185361 100644
--- a/openbsc/src/nat/bsc_nat_utils.c
+++ b/openbsc/src/nat/bsc_nat_utils.c
@@ -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;
-} \ No newline at end of file
+}
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c
index eea5dd894..c09eca4de 100644
--- a/openbsc/src/nat/bsc_nat_vty.c
+++ b/openbsc/src/nat/bsc_nat_vty.c
@@ -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;
diff --git a/openbsc/src/nat/bsc_sccp.c b/openbsc/src/nat/bsc_sccp.c
index 94b332a8e..97a4f1289 100644
--- a/openbsc/src/nat/bsc_sccp.c
+++ b/openbsc/src/nat/bsc_sccp.c
@@ -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",