This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
osmith gerrit-no-reply at lists.osmocom.orgosmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/24924 )
Change subject: vty: add "show uptime"
......................................................................
vty: add "show uptime"
Related: OS#4609
Change-Id: Ic7d9d5d3c8a9abd06a7e626aed7679f68406040c
---
M src/vty/command.c
1 file changed, 20 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/24/24924/1
diff --git a/src/vty/command.c b/src/vty/command.c
index de89337..854c379 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -63,6 +63,9 @@
void *tall_vty_cmd_ctx;
+/* When cmd_init() was called, for the "show uptime". */
+time_t uptime;
+
/* Command vector which includes some level of command lists. Normally
each daemon maintains each own cmdvec. */
vector cmdvec;
@@ -3037,6 +3040,20 @@
return CMD_SUCCESS;
}
+DEFUN(show_uptime,
+ show_uptime_cmd, "show uptime", SHOW_STR "Displays how long the program has been running\n")
+{
+ time_t diff = time(NULL) - uptime;
+ int d = diff / (3600 * 24);
+ int h = diff / 3600 % 24;
+ int m = diff / 60 % 60;
+ int s = diff % 60;
+
+ vty_out(vty, "%s has been running for %id %ih %im %is%s", host.app_info->name, d, h, m, s, VTY_NEWLINE);
+
+ return CMD_SUCCESS;
+}
+
/* Help display function for all node. */
gDEFUN(config_help,
config_help_cmd, "help", "Description of the interactive help system\n")
@@ -4325,6 +4342,8 @@
/* Initialize command interface. Install basic nodes and commands. */
void cmd_init(int terminal)
{
+ uptime = time(NULL);
+
/* Allocate initial top vector of commands. */
cmdvec = vector_init(VECTOR_MIN_SIZE);
@@ -4346,6 +4365,7 @@
install_node(&config_node, config_write_host);
/* Each node's basic commands. */
+ install_lib_element(VIEW_NODE, &show_uptime_cmd);
install_lib_element(VIEW_NODE, &show_version_cmd);
install_lib_element(VIEW_NODE, &show_online_help_cmd);
if (terminal) {
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24924
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ic7d9d5d3c8a9abd06a7e626aed7679f68406040c
Gerrit-Change-Number: 24924
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210712/706a9fbf/attachment.htm>