aboutsummaryrefslogtreecommitdiffstats
path: root/cli.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-02-05 16:49:14 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-02-05 16:49:14 +0000
commit1b7bf356675f2f299281d35933df05812125a9cb (patch)
tree401cb479fe8909223e5f17a32b9a825eb65759bc /cli.c
parent5a5cfcf795cafa4adc612660a2872dcbc432d34c (diff)
Allow uptime to be displayed in seconds (bug #3510, with mods)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4968 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cli.c')
-rwxr-xr-xcli.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/cli.c b/cli.c
index fdd87a3b0..c011730b5 100755
--- a/cli.c
+++ b/cli.c
@@ -250,7 +250,12 @@ static char modlist_help[] =
static char version_help[] =
"Usage: show version\n"
-" Shows Asterisk version information.\n ";
+" Shows Asterisk version information.\n";
+
+static char uptime_help[] =
+"Usage: show uptime [seconds]\n"
+" Shows Asterisk uptime information.\n"
+" The seconds word returns the uptime in seconds only.\n";
static char *format_uptimestr(time_t timeval)
{
@@ -333,22 +338,35 @@ static int handle_showuptime(int fd, int argc, char *argv[])
{
time_t curtime, tmptime;
char *timestr;
+ int printsec;
+
+ printsec = ((argc == 3) && (!strcasecmp(argv[2],"seconds")));
+ if ((argc != 2) && (!printsec))
+ return RESULT_SHOWUSAGE;
time(&curtime);
if (ast_startuptime) {
tmptime = curtime - ast_startuptime;
- timestr = format_uptimestr(tmptime);
- if (timestr) {
- ast_cli(fd, "System uptime: %s\n", timestr);
- free(timestr);
+ if (printsec) {
+ ast_cli(fd, "System uptime: %lu\n",tmptime);
+ } else {
+ timestr = format_uptimestr(tmptime);
+ if (timestr) {
+ ast_cli(fd, "System uptime: %s\n", timestr);
+ free(timestr);
+ }
}
}
if (ast_lastreloadtime) {
tmptime = curtime - ast_lastreloadtime;
- timestr = format_uptimestr(tmptime);
- if (timestr) {
- ast_cli(fd, "Last reload: %s\n", timestr);
- free(timestr);
+ if (printsec) {
+ ast_cli(fd, "Last reload: %lu\n", tmptime);
+ } else {
+ timestr = format_uptimestr(tmptime);
+ if ((timestr) && (!printsec)) {
+ ast_cli(fd, "Last reload: %s\n", timestr);
+ free(timestr);
+ }
}
}
return RESULT_SUCCESS;
@@ -782,7 +800,7 @@ static struct ast_cli_entry builtins[] = {
{ { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help },
{ { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
{ { "show", "modules", "like", NULL }, handle_modlist, "List modules and info", modlist_help, complete_mod_4 },
- { { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", modlist_help },
+ { { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", uptime_help },
{ { "show", "version", NULL }, handle_version, "Display version info", version_help },
{ { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch_3 },
{ { "unload", NULL }, handle_unload, "Unload a dynamic module by name", unload_help, complete_fn },