pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmocore/+/39941?usp=email )
Change subject: vty: Add 'show runtime' command
......................................................................
vty: Add 'show runtime' command
It came up several times already that it's difficult figuring out the
osmo-io backend a process is actually using.
Add a VTY command to display the osmo-io backend in use.
Related: OS#6740
Change-Id: I7994c820894b3525bfe78b5d389ff30a1e543226
---
M include/osmocom/vty/Makefile.am
A include/osmocom/vty/vty_internal.h
M src/vty/Makefile.am
A src/vty/misc_vty.c
M src/vty/vty.c
5 files changed, 80 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/41/39941/1
diff --git a/include/osmocom/vty/Makefile.am b/include/osmocom/vty/Makefile.am
index adb05dc..2261da7 100644
--- a/include/osmocom/vty/Makefile.am
+++ b/include/osmocom/vty/Makefile.am
@@ -12,6 +12,10 @@
cpu_sched_vty.h \
tdef_vty.h \
$(NULL)
+
+noinst_HEADERS = \
+ vty_internal.h \
+ $(NULL)
endif
osmovtydir = $(includedir)/osmocom/vty
diff --git a/include/osmocom/vty/vty_internal.h b/include/osmocom/vty/vty_internal.h
new file mode 100644
index 0000000..bb800c8
--- /dev/null
+++ b/include/osmocom/vty/vty_internal.h
@@ -0,0 +1,30 @@
+/* (C) 2025 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de>
+ *
+ * Author: Pau Espin Pedrol <pespin(a)sysmocom.de>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#pragma once
+
+/*! \defgroup vty_internal Osmocom vty internals
+ * @{
+ * \file vty_internal.h */
+
+void vty_misc_init(void);
+
+/*! @} */
diff --git a/src/vty/Makefile.am b/src/vty/Makefile.am
index 14e8326..91c2413 100644
--- a/src/vty/Makefile.am
+++ b/src/vty/Makefile.am
@@ -23,6 +23,7 @@
cpu_sched_vty.c \
fsm_vty.c \
logging_vty.c \
+ misc_vty.c \
stats_vty.c \
talloc_ctx_vty.c \
tdef_vty.c \
diff --git a/src/vty/misc_vty.c b/src/vty/misc_vty.c
new file mode 100644
index 0000000..7a59c74
--- /dev/null
+++ b/src/vty/misc_vty.c
@@ -0,0 +1,42 @@
+/*
+ * (C) 2025 by sysmocom - s.f.m.c. GmbH
+ * Author: Pau Espin Pedrol <pespin(a)sysmocom.de>
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * 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.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "config.h"
+
+#include <osmocom/core/osmo_io.h>
+
+#include <osmocom/vty/command.h>
+#include <osmocom/vty/vty.h>
+
+DEFUN(show_runtime, show_runtime_cmd,
+ "show runtime",
+ SHOW_STR "Display runtime information\n")
+{
+ enum osmo_io_backend io_backend = osmo_io_get_backend();
+ vty_out(vty, "osmo-io backend: %s%s", osmo_io_backend_name(io_backend),
VTY_NEWLINE);
+ return CMD_SUCCESS;
+}
+
+void vty_misc_init(void)
+{
+ install_lib_element_ve(&show_runtime_cmd);
+}
diff --git a/src/vty/vty.c b/src/vty/vty.c
index 3a549b4..5936ee8 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -65,6 +65,7 @@
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/buffer.h>
+#include <osmocom/vty/vty_internal.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/utils.h>
@@ -1902,6 +1903,8 @@
install_lib_element(VTY_NODE, &vty_login_cmd);
install_lib_element(VTY_NODE, &no_vty_login_cmd);
install_lib_element(VTY_NODE, &vty_bind_cmd);
+
+ vty_misc_init();
}
/*! Read the configuration file using the VTY code
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/39941?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I7994c820894b3525bfe78b5d389ff30a1e543226
Gerrit-Change-Number: 39941
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>