show sessions uptime format
show sessions uptime format
Is it possible to include an uptime display parameter in seconds?
Re: show sessions uptime format
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
Hi, andlui9, I made patch for you
result
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)
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
commit f3df13b15616f57a5d8bf8efab932d67005e3b87
show sessions uptime format
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.
In my method of use, I want the folder to be excluded from the filter when the quick filter function is enabled.