diff options
-rw-r--r-- | src/vty/command.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/vty/command.c b/src/vty/command.c index 3112fee4..bb6a6651 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -3067,13 +3067,15 @@ DEFUN(show_uptime, show_uptime_cmd, "show uptime", SHOW_STR "Displays how long the program has been running\n") { struct timespec now; + struct timespec uptime; + osmo_clock_gettime(CLOCK_MONOTONIC, &now); + timespecsub(&now, &starttime, &uptime); - time_t uptime = now.tv_sec - starttime.tv_sec; - int d = uptime / (3600 * 24); - int h = uptime / 3600 % 24; - int m = uptime / 60 % 60; - int s = uptime % 60; + int d = uptime.tv_sec / (3600 * 24); + int h = uptime.tv_sec / 3600 % 24; + int m = uptime.tv_sec / 60 % 60; + int s = uptime.tv_sec % 60; vty_out(vty, "%s has been running for %dd %dh %dm %ds%s", host.app_info->name, d, h, m, s, VTY_NEWLINE); |