show sessions uptime format

Here you can post your feature requests and suggestions
Post Reply
andlui9
Posts: 25
Joined: 20 Jan 2017, 11:46

show sessions uptime format

Post by andlui9 » 06 Jan 2018, 02:11

Is it possible to include an uptime display parameter in seconds?

andlui9
Posts: 25
Joined: 20 Jan 2017, 11:46

Re: show sessions uptime format

Post by andlui9 » 10 Jan 2018, 15:07

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 ...

dimka88
Posts: 360
Joined: 13 Oct 2014, 05:51
Contact:

Re: show sessions uptime format

Post by dimka88 » 12 Jan 2018, 18:02

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

Dmitry
Администратор
Posts: 921
Joined: 09 Oct 2014, 10:06

Re: show sessions uptime format

Post by Dmitry » 13 Jan 2018, 12:06

commit f3df13b15616f57a5d8bf8efab932d67005e3b87

piterSl
Posts: 3
Joined: 06 Apr 2018, 21:07

show sessions uptime format

Post by piterSl » 09 Apr 2018, 22:38

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests