--- asterisk-1.0.5/cli.c.orig 2004-12-30 23:30:09.000000000 +0100 +++ asterisk-1.0.5/cli.c 2005-02-05 04:29:25.060090772 +0100 @@ -228,7 +228,12 @@ 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 [-s]\n" +" Shows Asterisk uptime information.\n" +" The -s options only returns the uptime in seconds.\n"; static char *format_uptimestr(time_t timeval) { @@ -311,22 +316,35 @@ { time_t curtime, tmptime; char *timestr; + int printsec; + + printsec = ((argc == 3) && (!strcasecmp(argv[2],"-s"))); + 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; @@ -706,7 +724,7 @@ { { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help }, { { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch_3 }, { { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help }, - { { "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 },