stats: Enable stats for sgsn, gbproxy, nitb, bsc, nat

This commit initialises and enables the stats subsystem for the given
binaries.

Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c
index 45b45a4..f82fb5b 100644
--- a/openbsc/src/gprs/gb_proxy_main.c
+++ b/openbsc/src/gprs/gb_proxy_main.c
@@ -36,6 +36,7 @@
 #include <osmocom/core/talloc.h>
 #include <osmocom/core/select.h>
 #include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/stats.h>
 
 #include <osmocom/gprs/gprs_ns.h>
 #include <osmocom/gprs/gprs_bssgp.h>
@@ -48,6 +49,7 @@
 #include <osmocom/vty/command.h>
 #include <osmocom/vty/telnet_interface.h>
 #include <osmocom/vty/logging.h>
+#include <osmocom/vty/stats.h>
 #include <osmocom/vty/ports.h>
 
 #include "../../bscconfig.h"
@@ -242,11 +244,13 @@
 	vty_info.copyright = openbsc_copyright;
 	vty_init(&vty_info);
 	logging_vty_add_cmds(&gprs_log_info);
+	osmo_stats_vty_add_cmds(&gprs_log_info);
 	gbproxy_vty_init();
 
 	handle_options(argc, argv);
 
 	rate_ctr_init(tall_bsc_ctx);
+	osmo_stats_init(tall_bsc_ctx);
 
 	rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_GBPROXY);
 	if (rc < 0)
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index e6a361d..2d3a0e4 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -37,12 +37,14 @@
 #include <osmocom/core/select.h>
 #include <osmocom/core/rate_ctr.h>
 #include <osmocom/core/logging.h>
+#include <osmocom/core/stats.h>
 
 #include <osmocom/gprs/gprs_ns.h>
 #include <osmocom/gprs/gprs_bssgp.h>
 
 #include <osmocom/vty/telnet_interface.h>
 #include <osmocom/vty/logging.h>
+#include <osmocom/vty/stats.h>
 #include <osmocom/vty/ports.h>
 
 #include <openbsc/signal.h>
@@ -302,11 +304,13 @@
 
 	osmo_init_ignore_signals();
 	osmo_init_logging(&gprs_log_info);
+	osmo_stats_init(tall_bsc_ctx);
 
 	vty_info.copyright = openbsc_copyright;
 	vty_init(&vty_info);
 	logging_vty_add_cmds(&gprs_log_info);
-        sgsn_vty_init();
+	osmo_stats_vty_add_cmds(&gprs_log_info);
+	sgsn_vty_init();
 
 	handle_options(argc, argv);
 
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index f8ef833..24bae97 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -24,6 +24,7 @@
 #include <osmocom/vty/buffer.h>
 #include <osmocom/vty/vty.h>
 #include <osmocom/vty/logging.h>
+#include <osmocom/vty/stats.h>
 #include <osmocom/vty/telnet_interface.h>
 #include <osmocom/vty/misc.h>
 
@@ -3737,6 +3738,7 @@
 	install_element_ve(&show_paging_group_cmd);
 
 	logging_vty_add_cmds(cat);
+	osmo_stats_vty_add_cmds();
 
 	install_element(CONFIG_NODE, &cfg_net_cmd);
 	install_node(&net_node, config_write_net);
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c
index 3ab1267..4bb2da1 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_main.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c
@@ -36,6 +36,7 @@
 #include <osmocom/core/application.h>
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/core/stats.h>
 #include <osmocom/gsm/protocol/gsm_12_21.h>
 
 #include <osmocom/abis/abis.h>
@@ -192,6 +193,7 @@
 	tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
 
 	osmo_init_logging(&log_info);
+	osmo_stats_init(tall_bsc_ctx);
 
 	bts_init();
 	libosmo_abis_init(tall_bsc_ctx);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 18343dd..816ae58 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -56,6 +56,7 @@
 
 #include <osmocom/core/application.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/core/stats.h>
 
 #include <osmocom/gsm/tlv.h>
 #include <osmocom/gsm/gsm0808.h>
@@ -64,6 +65,7 @@
 #include <osmocom/vty/telnet_interface.h>
 #include <osmocom/vty/vty.h>
 #include <osmocom/vty/logging.h>
+#include <osmocom/vty/stats.h>
 #include <osmocom/vty/ports.h>
 
 #include <osmocom/sccp/sccp.h>
@@ -1613,6 +1615,7 @@
 	vty_info.copyright = openbsc_copyright;
 	vty_init(&vty_info);
 	logging_vty_add_cmds(&log_info);
+	osmo_stats_vty_add_cmds(&log_info);
 	bsc_nat_vty_init(nat);
 
 
@@ -1621,6 +1624,7 @@
 	handle_options(argc, argv);
 
 	rate_ctr_init(tall_bsc_ctx);
+	osmo_stats_init(tall_bsc_ctx);
 
 	/* init vty and parse */
 	telnet_init(tall_bsc_ctx, NULL, OSMO_VTY_PORT_BSC_NAT);
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-nitb/bsc_hack.c
index 7229a9b..8b074f1 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-nitb/bsc_hack.c
@@ -32,6 +32,7 @@
 #include <openbsc/db.h>
 #include <osmocom/core/application.h>
 #include <osmocom/core/select.h>
+#include <osmocom/core/stats.h>
 #include <openbsc/debug.h>
 #include <osmocom/abis/abis.h>
 #include <osmocom/abis/e1_input.h>
@@ -258,6 +259,7 @@
 
 	libosmo_abis_init(tall_bsc_ctx);
 	osmo_init_logging(&log_info);
+	osmo_stats_init(tall_bsc_ctx);
 	bts_init();
 
 	/* This needs to precede handle_options() */