From f3df13b15616f57a5d8bf8efab932d67005e3b87 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Sat, 13 Jan 2018 14:59:47 +0300 Subject: cli: show sessions: added uptime-raw columnt to print uptime in seconds --- accel-pppd/cli/show_sessions.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'accel-pppd') diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c index 47adb3a..ceab8db 100644 --- a/accel-pppd/cli/show_sessions.c +++ b/accel-pppd/cli/show_sessions.c @@ -491,6 +491,18 @@ static void print_uptime(struct ap_session *ses, char *buf) sprintf(buf, "%s", time_str); } +static void print_uptime_raw(struct ap_session *ses, char *buf) +{ + time_t uptime; + + if (ses->stop_time) + uptime = ses->stop_time - ses->start_time; + else + uptime = _time() - ses->start_time; + + sprintf(buf, "%lu", (unsigned long)uptime); +} + static void print_calling_sid(struct ap_session *ses, char *buf) { snprintf(buf, CELL_SIZE, "%s", ses->ctrl->calling_station_id); @@ -629,6 +641,7 @@ static void init(void) cli_show_ses_register("type", "VPN type", print_type); cli_show_ses_register("state", "state of session", print_state); cli_show_ses_register("uptime", "uptime", print_uptime); + cli_show_ses_register("uptime-raw", "uptime", print_uptime_raw); cli_show_ses_register("calling-sid", "calling station id", print_calling_sid); cli_show_ses_register("called-sid", "called station id", print_called_sid); cli_show_ses_register("sid", "session id", print_sid); -- cgit v1.2.3