Page 1 of 1

show sessions uptime format

Posted: 06 Jan 2018, 02:11
by andlui9
Is it possible to include an uptime display parameter in seconds?

Re: show sessions uptime format

Posted: 10 Jan 2018, 15:07
by andlui9
Has anyone ever needed this? It's interesting, I've done a script that collects all output information from the "accel-cmd show sessions" command (I set it to display all the columns) and format as JSON, so you can collect everything and send it to a preview pane. But the format of the uptime is a little messy, so my question is how to display it in seconds ...

Re: show sessions uptime format

Posted: 12 Jan 2018, 18:02
by dimka88
Hi, andlui9, I made patch for you

Code: Select all

diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c
index 47adb3a..b1f27e0 100644
--- a/accel-pppd/cli/show_sessions.c
+++ b/accel-pppd/cli/show_sessions.c
@@ -468,27 +468,16 @@ static void print_state(struct ap_session *ses, char *buf)

 static void print_uptime(struct ap_session *ses, char *buf)
 {
-       time_t uptime;
-       int day,hour,min,sec;
-       char time_str[14];
-
-       if (ses->stop_time)
-               uptime = ses->stop_time - ses->start_time;
-       else {
-               uptime = _time();
-               uptime -= ses->start_time;
-       }
-
-       day = uptime/ (24*60*60); uptime %= (24*60*60);
-       hour = uptime / (60*60); uptime %= (60*60);
-       min = uptime / 60;
-       sec = uptime % 60;
-       if (day)
-               snprintf(time_str, 13, "%i.%02i:%02i:%02i", day, hour, min, sec);
-       else
-               snprintf(time_str, 13, "%02i:%02i:%02i", hour, min, sec);
-
-       sprintf(buf, "%s", time_str);
+time_t uptime;
+char time_str[14];
+if (ses->stop_time)
+       uptime = ses->stop_time - ses->start_time;
+else {
+       uptime = _time();
+       uptime -= ses->start_time;
+}
+snprintf(time_str, 13, "%ld", uptime);
+sprintf(buf, "%s", time_str);
 }

 static void print_calling_sid(struct ap_session *ses, char *buf)

result

Code: Select all

root@dev:/opt/accel-ppp-code# accel-cmd show sessions
 ifname | username |    calling-sid    |     ip     | type | comp | state  | uptime
--------+----------+-------------------+------------+------+------+--------+--------
 ipoe0  |          | 00:0c:29:e3:86:f5 | 100.64.0.2 | ipoe |      | active | 1071

Re: show sessions uptime format

Posted: 13 Jan 2018, 12:06
by Dmitry
commit f3df13b15616f57a5d8bf8efab932d67005e3b87

show sessions uptime format

Posted: 09 Apr 2018, 22:38
by piterSl
Even if you use the quick filter function, please add a setting that can always show the folder.
In my method of use, I want the folder to be excluded from the filter when the quick filter function is enabled.