aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-19 15:14:13 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-29 00:09:04 +0100
commit45513e6040195f5494d40a2750de4dac7037593f (patch)
tree4064efa34c02047181a78fab4086a228aa832bb1
parent7211fe157e1107d4a9c04a0ecf494a7b9633c400 (diff)
stats/vty: Add stats_vty.c
This file will contain the VTY code related to statistics. This commit adds a minimal file with just as single VTY command: - show stats This command shows all statistical values To enable this and future commands, the main program needs to call stats_vty_add_cmds(). Sponsored-by: On-Waves ehf
-rw-r--r--include/Makefile.am1
-rw-r--r--include/osmocom/vty/stats.h3
-rw-r--r--src/vty/Makefile.am2
-rw-r--r--src/vty/stats_vty.c52
4 files changed, 57 insertions, 1 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 7f8dd77..af189c3 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -113,6 +113,7 @@ nobase_include_HEADERS += \
osmocom/vty/buffer.h \
osmocom/vty/command.h \
osmocom/vty/logging.h \
+ osmocom/vty/stats.h \
osmocom/vty/misc.h \
osmocom/vty/telnet_interface.h \
osmocom/vty/vector.h \
diff --git a/include/osmocom/vty/stats.h b/include/osmocom/vty/stats.h
new file mode 100644
index 0000000..eaf854e
--- /dev/null
+++ b/include/osmocom/vty/stats.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void stats_vty_add_cmds();
diff --git a/src/vty/Makefile.am b/src/vty/Makefile.am
index 4225d27..7c549d9 100644
--- a/src/vty/Makefile.am
+++ b/src/vty/Makefile.am
@@ -9,7 +9,7 @@ if ENABLE_VTY
lib_LTLIBRARIES = libosmovty.la
libosmovty_la_SOURCES = buffer.c command.c vty.c vector.c utils.c \
- telnet_interface.c logging_vty.c
+ telnet_interface.c logging_vty.c stats_vty.c
libosmovty_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined
libosmovty_la_LIBADD = $(top_builddir)/src/libosmocore.la
endif
diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c
new file mode 100644
index 0000000..c19b225
--- /dev/null
+++ b/src/vty/stats_vty.c
@@ -0,0 +1,52 @@
+/* OpenBSC stats helper for the VTY */
+/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2009-2014 by Holger Hans Peter Freyther
+ * (C) 2015 by Sysmocom s.f.m.c. GmbH
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include "../../config.h"
+
+#include <osmocom/vty/command.h>
+#include <osmocom/vty/buffer.h>
+#include <osmocom/vty/vty.h>
+#include <osmocom/vty/telnet_interface.h>
+#include <osmocom/vty/misc.h>
+
+#define CFG_STATS_STR "Configure stats sub-system\n"
+#define CFG_REPORTER_STR "Configure a stats reporter\n"
+
+#define SHOW_STATS_STR "Show statistical values\n"
+
+DEFUN(show_stats,
+ show_stats_cmd,
+ "show stats",
+ SHOW_STR SHOW_STATS_STR)
+{
+ vty_out_statistics_full(vty, "");
+
+ return CMD_SUCCESS;
+}
+
+void stats_vty_add_cmds(const struct log_info *cat)
+{
+ install_element_ve(&show_stats_cmd);
+}