aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-01-22 16:22:28 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-01-22 16:22:28 +0100
commitfbfe8eb81de7900a5241528ca4087be8211bd259 (patch)
treebdee1ac77cf5b6ad905f7c3ad0f5ee6ad695e818
parent7d7c711a43ce94912bb95e7a0485e81713eed06c (diff)
parent60af5dd57a164265ac2733eaa9992161ab682552 (diff)
Merge branch 'on-waves/stats'
-rw-r--r--include/Makefile.am2
-rw-r--r--include/counter.h46
-rw-r--r--include/mtp_data.h11
-rw-r--r--src/Makefile.am6
-rw-r--r--src/counter.c65
-rw-r--r--src/links.c5
-rw-r--r--src/mtp_layer3.c31
-rw-r--r--src/mtp_link.c14
-rw-r--r--src/sctp_m2ua.c11
-rw-r--r--src/vty_interface.c62
10 files changed, 237 insertions, 16 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 7693480..1dbaef7 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,6 +1,6 @@
noinst_HEADERS = mtp_level3.h mtp_data.h ipaccess.h thread.h mtp_pcap.h \
mgcp_ss7.h bss_patch.h bssap_sccp.h bsc_data.h udp_input.h \
snmp_mtp.h cellmgr_debug.h bsc_sccp.h bsc_ussd.h sctp_m2ua.h \
- isup_types.h
+ isup_types.h counter.h
SUBDIRS = mgcp
diff --git a/include/counter.h b/include/counter.h
new file mode 100644
index 0000000..631781c
--- /dev/null
+++ b/include/counter.h
@@ -0,0 +1,46 @@
+/* Counter for the Link and Link-Set */
+/*
+ * (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2011 by On-Waves
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+#ifndef counter_h
+#define counter_h
+
+#include <osmocore/rate_ctr.h>
+
+enum {
+ MTP_LSET_TOTA_IN_MSG,
+ MTP_LSET_SCCP_IN_MSG,
+ MTP_LSET_IUSP_IN_MSG,
+ MTP_LSET_TOTA_OUT_MSG,
+ MTP_LSET_SCCP_OUT_MSG,
+ MTP_LSET_ISUP_OUT_MSG,
+};
+
+enum {
+ MTP_LNK_IN,
+ MTP_LNK_OUT,
+ MTP_LNK_ERROR,
+ MTP_LNK_SLTM_TOUT,
+};
+
+const struct rate_ctr_group_desc *mtp_link_set_rate_ctr_desc();
+const struct rate_ctr_group_desc *mtp_link_rate_ctr_desc();
+
+#endif
diff --git a/include/mtp_data.h b/include/mtp_data.h
index f04c07d..e6cd872 100644
--- a/include/mtp_data.h
+++ b/include/mtp_data.h
@@ -27,6 +27,7 @@
struct bsc_data;
struct mtp_link;
struct mtp_level_3_mng *mng;
+struct rate_ctr_group;
/* MTP Level3 timers */
@@ -61,6 +62,9 @@ struct mtp_link_set {
/* special handling */
int pass_all_isup;
+ /* statistics */
+ struct rate_ctr_group *ctrg;
+
/* custom data */
struct bsc_data *bsc;
};
@@ -92,6 +96,9 @@ struct mtp_link {
struct timer_list t1_timer;
struct timer_list t2_timer;
+ /* statistics */
+ struct rate_ctr_group *ctrg;
+
/* callback's to implement */
int (*start)(struct mtp_link *);
int (*write)(struct mtp_link *, struct msgb *msg);
@@ -109,7 +116,7 @@ int mtp_link_set_submit_sccp_data(struct mtp_link_set *link, int sls, const uint
int mtp_link_set_submit_isup_data(struct mtp_link_set *link, int sls, const uint8_t *data, unsigned int length);
void mtp_link_set_init_slc(struct mtp_link_set *set);
-void mtp_link_set_add_link(struct mtp_link_set *set, struct mtp_link *link);
+int mtp_link_set_add_link(struct mtp_link_set *set, struct mtp_link *link);
/* one time init function */
@@ -125,7 +132,7 @@ void mtp_link_restart(struct mtp_link *link);
void mtp_link_down(struct mtp_link *data);
void mtp_link_up(struct mtp_link *data);
-void mtp_link_init(struct mtp_link *link);
+int mtp_link_init(struct mtp_link *link);
void mtp_link_start_link_test(struct mtp_link *link);
void mtp_link_stop_link_test(struct mtp_link *link);
int mtp_link_slta(struct mtp_link *link, uint16_t l3_len, struct mtp_level_3_mng *mng);
diff --git a/src/Makefile.am b/src/Makefile.am
index defe121..0ca73dd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,18 +12,18 @@ mgcp_mgw_LDADD = $(LAFORGE_LIBS) $(NEXUSWARE_C7_LIBS) $(NEXUSWARE_UNIPORTE_LIBS)
cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \
bss_patch.c bssap_sccp.c bsc_sccp.c bsc_ussd.c links.c \
msc_conn.c link_udp.c snmp_mtp.c debug.c vty_interface.c isup.c \
- mtp_link.c
+ mtp_link.c counter.c
cellmgr_ng_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto
udt_relay_SOURCES = main_udt.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \
msc_conn.c link_udp.c snmp_mtp.c debug.c vty_interface.c \
- bss_patch.c isup.c links.c sctp_m2ua.c mtp_link.c
+ bss_patch.c isup.c links.c sctp_m2ua.c mtp_link.c counter.c
udt_relay_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto -lm2ua -lsctp
osmo_stp_SOURCES = main_stp.c mtp_layer3.c thread.c pcap.c link_udp.c snmp_mtp.c \
debug.c vty_interface.c links.c isup.c sctp_m2ua.c \
- mtp_link.c
+ mtp_link.c counter.c
osmo_stp_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto -lm2ua -lsctp
diff --git a/src/counter.c b/src/counter.c
new file mode 100644
index 0000000..6063e7b
--- /dev/null
+++ b/src/counter.c
@@ -0,0 +1,65 @@
+/* Counter for the Link and Link-Set */
+/*
+ * (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2011 by On-Waves
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <counter.h>
+
+#include <osmocore/utils.h>
+
+static const struct rate_ctr_desc mtp_lset_cfg_description[] = {
+ [MTP_LSET_TOTA_IN_MSG] = { "total.in", "Total messages in "},
+ [MTP_LSET_SCCP_IN_MSG] = { "sccp.in", "SCCP messages in "},
+ [MTP_LSET_IUSP_IN_MSG] = { "isup.in", "ISUP messages in "},
+ [MTP_LSET_TOTA_OUT_MSG] = { "total.out", "Total messages out "},
+ [MTP_LSET_SCCP_IN_MSG] = { "sccp.out", "SCCP messages out "},
+ [MTP_LSET_IUSP_IN_MSG] = { "isup.out", "ISUP messages out "},
+};
+
+static const struct rate_ctr_desc mtp_link_cfg_description[] = {
+ [MTP_LNK_IN] = { "total.in", "Messages in "},
+ [MTP_LNK_OUT] = { "total.out", "Messages out "},
+ [MTP_LNK_ERROR] = { "total.error", "Errors occured "},
+ [MTP_LNK_SLTM_TOUT] = { "sltm.timeouts", "SLTM timeouts "},
+};
+
+static const struct rate_ctr_group_desc mtp_lset_ctrg_desc = {
+ .group_name_prefix = "mtp_lset",
+ .group_description = "MTP LinkSet",
+ .num_ctr = ARRAY_SIZE(mtp_lset_cfg_description),
+ .ctr_desc = mtp_lset_cfg_description,
+};
+
+static const struct rate_ctr_group_desc mtp_link_ctrg_desc = {
+ .group_name_prefix = "mtp_link",
+ .group_description = "MTP Link",
+ .num_ctr = ARRAY_SIZE(mtp_link_cfg_description),
+ .ctr_desc = mtp_link_cfg_description,
+};
+
+const struct rate_ctr_group_desc *mtp_link_set_rate_ctr_desc()
+{
+ return &mtp_lset_ctrg_desc;
+}
+
+const struct rate_ctr_group_desc *mtp_link_rate_ctr_desc()
+{
+ return &mtp_link_ctrg_desc;
+}
diff --git a/src/links.c b/src/links.c
index 4342447..9bd202b 100644
--- a/src/links.c
+++ b/src/links.c
@@ -72,11 +72,6 @@ void mtp_link_up(struct mtp_link *link)
mtp_link_start_link_test(link);
}
-void mtp_link_set_submit(struct mtp_link *link, struct msgb *msg)
-{
- link->write(link, msg);
-}
-
void mtp_link_restart(struct mtp_link *link)
{
LOGP(DINP, LOGL_ERROR, "Need to restart the SS7 link.\n");
diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c
index 67ae70e..4cbf999 100644
--- a/src/mtp_layer3.c
+++ b/src/mtp_layer3.c
@@ -23,6 +23,7 @@
#include <bsc_data.h>
#include <cellmgr_debug.h>
#include <isup_types.h>
+#include <counter.h>
#include <osmocore/talloc.h>
@@ -36,6 +37,14 @@ static void *tall_mtp_ctx = NULL;
static int mtp_int_submit(struct mtp_link_set *link, int pc, int sls, int type, const uint8_t *data, unsigned int length);
+void mtp_link_set_submit(struct mtp_link *link, struct msgb *msg)
+{
+ rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_OUT]);
+ rate_ctr_inc(&link->set->ctrg->ctr[MTP_LSET_TOTA_OUT_MSG]);
+ link->write(link, msg);
+}
+
+
struct msgb *mtp_msg_alloc(struct mtp_link_set *link)
{
struct mtp_level_3_hdr *hdr;
@@ -182,12 +191,22 @@ void mtp_link_set_init(void)
struct mtp_link_set *mtp_link_set_alloc(void)
{
+ static int linkset_no = 0;
struct mtp_link_set *link;
link = talloc_zero(tall_mtp_ctx, struct mtp_link_set);
if (!link)
return NULL;
+ link->ctrg = rate_ctr_group_alloc(link,
+ mtp_link_set_rate_ctr_desc(),
+ linkset_no++);
+ if (!link->ctrg) {
+ LOGP(DINP, LOGL_ERROR, "Failed to allocate counter.\n");
+ return NULL;
+ }
+
+
link->ni = MTP_NI_NATION_NET;
INIT_LLIST_HEAD(&link->links);
@@ -429,6 +448,7 @@ static int mtp_link_sccp_data(struct mtp_link_set *link, struct mtp_level_3_hdr
return 0;
}
+ rate_ctr_inc(&link->ctrg->ctr[MTP_LSET_SCCP_IN_MSG]);
mtp_link_set_forward_sccp(link, msg, MTP_LINK_SLS(hdr->addr));
return 0;
}
@@ -450,6 +470,8 @@ int mtp_link_set_data(struct mtp_link *link, struct msgb *msg)
hdr = (struct mtp_level_3_hdr *) msg->l2h;
l3_len = msgb_l2len(msg) - sizeof(*hdr);
+ rate_ctr_inc(&link->set->ctrg->ctr[MTP_LSET_TOTA_IN_MSG]);
+
switch (hdr->ser_ind) {
case MTP_SI_MNT_SNM_MSG:
rc = mtp_link_sign_msg(link->set, hdr, l3_len);
@@ -462,6 +484,7 @@ int mtp_link_set_data(struct mtp_link *link, struct msgb *msg)
break;
case MTP_SI_MNT_ISUP:
msg->l3h = &hdr->data[0];
+ rate_ctr_inc(&link->set->ctrg->ctr[MTP_LSET_IUSP_IN_MSG]);
rc = mtp_link_set_isup(link->set, msg, MTP_LINK_SLS(hdr->addr));
break;
default:
@@ -485,12 +508,14 @@ int mtp_link_set_submit_sccp_data(struct mtp_link_set *link, int sls, const uint
link->last_sls = (link->last_sls + 1) % 16;
}
+ rate_ctr_inc(&link->ctrg->ctr[MTP_LSET_SCCP_OUT_MSG]);
return mtp_int_submit(link, link->sccp_opc, sls, MTP_SI_MNT_SCCP, data, length);
}
int mtp_link_set_submit_isup_data(struct mtp_link_set *link, int sls,
const uint8_t *data, unsigned int length)
{
+ rate_ctr_inc(&link->ctrg->ctr[MTP_LSET_ISUP_OUT_MSG]);
return mtp_int_submit(link, link->isup_opc, sls, MTP_SI_MNT_ISUP, data, length);
}
@@ -561,12 +586,14 @@ void mtp_link_set_init_slc(struct mtp_link_set *set)
}
}
-void mtp_link_set_add_link(struct mtp_link_set *set, struct mtp_link *lnk)
+int mtp_link_set_add_link(struct mtp_link_set *set, struct mtp_link *lnk)
{
lnk->set = set;
lnk->link_no = set->nr_links++;
- mtp_link_init(lnk);
+ if (mtp_link_init(lnk) != 0)
+ return -1;
llist_add_tail(&lnk->entry, &set->links);
mtp_link_set_init_slc(set);
+ return 0;
}
diff --git a/src/mtp_link.c b/src/mtp_link.c
index 5e5f418..d885738 100644
--- a/src/mtp_link.c
+++ b/src/mtp_link.c
@@ -22,6 +22,7 @@
#include <mtp_data.h>
#include <mtp_level3.h>
#include <cellmgr_debug.h>
+#include <counter.h>
#include <string.h>
@@ -71,6 +72,8 @@ static void mtp_sltm_t1_timeout(void *_link)
{
struct mtp_link *link = (struct mtp_link *) _link;
+ rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_SLTM_TOUT]);
+
if (link->slta_misses == 0) {
LOGP(DINP, LOGL_ERROR, "No SLTM response. Retrying. Link: %p\n", link);
++link->slta_misses;
@@ -103,12 +106,20 @@ static void mtp_sltm_t2_timeout(void *_link)
bsc_schedule_timer(&link->t2_timer, MTP_T2);
}
-void mtp_link_init(struct mtp_link *link)
+int mtp_link_init(struct mtp_link *link)
{
+ link->ctrg = rate_ctr_group_alloc(link,
+ mtp_link_rate_ctr_desc(), link->link_no);
+ if (!link->ctrg) {
+ LOGP(DINP, LOGL_ERROR, "Failed to allocate rate_ctr.\n");
+ return -1;
+ }
+
link->t1_timer.data = link;
link->t1_timer.cb = mtp_sltm_t1_timeout;
link->t2_timer.data = link;
link->t2_timer.cb = mtp_sltm_t2_timeout;
+ return 0;
}
void mtp_link_stop_link_test(struct mtp_link *link)
@@ -153,5 +164,6 @@ int mtp_link_slta(struct mtp_link *link, uint16_t l3_len,
void mtp_link_failure(struct mtp_link *link)
{
LOGP(DINP, LOGL_ERROR, "Link has failed. Resetting it: 0x%p\n", link);
+ rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_ERROR]);
link->reset(link);
}
diff --git a/src/sctp_m2ua.c b/src/sctp_m2ua.c
index a4743fa..d3a64c9 100644
--- a/src/sctp_m2ua.c
+++ b/src/sctp_m2ua.c
@@ -18,6 +18,7 @@
#include <sctp_m2ua.h>
#include <bsc_data.h>
#include <cellmgr_debug.h>
+#include <counter.h>
#include <mtp_data.h>
#include <mtp_pcap.h>
@@ -31,6 +32,12 @@
extern struct bsc_data bsc;
+static void link_down(struct mtp_link *link)
+{
+ rate_ctr_inc(&link->ctrg->ctr[MTP_LNK_ERROR]);
+ mtp_link_down(link);
+}
+
static void m2ua_conn_destroy(struct sctp_m2ua_conn *conn)
{
close(conn->queue.bfd.fd);
@@ -39,7 +46,7 @@ static void m2ua_conn_destroy(struct sctp_m2ua_conn *conn)
llist_del(&conn->entry);
if (conn->asp_up && conn->asp_active && conn->established)
- mtp_link_down(&conn->trans->base);
+ link_down(&conn->trans->base);
talloc_free(conn);
#warning "Notify any other AS(P) for failover scenario"
@@ -286,7 +293,7 @@ static int m2ua_handle_rel_req(struct sctp_m2ua_conn *conn,
conn->established = 0;
LOGP(DINP, LOGL_NOTICE, "M2UA/Link is released.\n");
- mtp_link_down(&conn->trans->base);
+ link_down(&conn->trans->base);
m2ua_msg_free(conf);
return 0;
}
diff --git a/src/vty_interface.c b/src/vty_interface.c
index 0cf5929..3ad2fe0 100644
--- a/src/vty_interface.c
+++ b/src/vty_interface.c
@@ -23,6 +23,7 @@
#include <osmocore/talloc.h>
#include <osmocore/gsm48.h>
+#include <osmocore/rate_ctr.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/vty.h>
@@ -275,6 +276,62 @@ DEFUN(cfg_lac, cfg_lac_cmd,
return CMD_SUCCESS;
}
+static void dump_stats(struct vty *vty, struct mtp_link_set *set)
+{
+ struct mtp_link *link;
+
+ vty_out(vty, "Linkset opc: %d%s", set->opc, VTY_NEWLINE);
+ vty_out_rate_ctr_group(vty, " ", set->ctrg);
+
+ llist_for_each_entry(link, &set->links, entry) {
+ vty_out(vty, " Link %d%s", link->link_no, VTY_NEWLINE);
+ vty_out_rate_ctr_group(vty, " ", link->ctrg);
+ }
+}
+
+DEFUN(show_stats, show_stats_cmd,
+ "show statistics",
+ SHOW_STR "Display Linkset statistics\n")
+{
+ if (bsc.link_set)
+ dump_stats(vty, bsc.link_set);
+ if (bsc.m2ua_set)
+ dump_stats(vty, bsc.m2ua_set);
+ return CMD_SUCCESS;
+}
+
+static void dump_state(struct vty *vty, const char *name, struct mtp_link_set *set)
+{
+ struct mtp_link *link;
+
+ if (!set) {
+ vty_out(vty, "LinkSet for %s is not configured.%s", name, VTY_NEWLINE);
+ return;
+ }
+
+ vty_out(vty, "LinkSet for %s is %s, remote sccp is %s.%s",
+ name,
+ set->available == 0 ? "not available" : "available",
+ set->sccp_up == 0? "not established" : "established",
+ VTY_NEWLINE);
+
+ llist_for_each_entry(link, &set->links, entry) {
+ vty_out(vty, " Link %d is %s.%s",
+ link->link_no,
+ link->available == 0 ? "not available" : "available",
+ VTY_NEWLINE);
+ }
+}
+
+DEFUN(show_linksets, show_linksets_cmd,
+ "show link-sets",
+ SHOW_STR "Display current state of linksets\n")
+{
+ dump_state(vty, "MTP ", bsc.link_set);
+ dump_state(vty, "M2UA", bsc.m2ua_set);
+ return CMD_SUCCESS;
+}
+
void cell_vty_init(void)
{
cmd_init(1);
@@ -303,6 +360,11 @@ void cell_vty_init(void)
install_element(CELLMGR_NODE, &cfg_mcc_cmd);
install_element(CELLMGR_NODE, &cfg_mnc_cmd);
install_element(CELLMGR_NODE, &cfg_lac_cmd);
+
+
+ /* show commands */
+ install_element_ve(&show_stats_cmd);
+ install_element_ve(&show_linksets_cmd);
}
const char *openbsc_copyright = "";