From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 16/19] OpenVPN Log: Add connection duration Date: Mon, 13 Apr 2020 09:45:47 +0200 Message-ID: <20200413074550.2735-16-stefan.schantl@ipfire.org> In-Reply-To: <20200413074550.2735-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6672800718547469760==" List-Id: --===============6672800718547469760== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Michael Tremer Signed-off-by: Michael Tremer --- html/cgi-bin/logs.cgi/ovpnclients.dat | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/html/cgi-bin/logs.cgi/ovpnclients.dat b/html/cgi-bin/logs.cgi/ov= pnclients.dat index 002a393ad..2009990ec 100755 --- a/html/cgi-bin/logs.cgi/ovpnclients.dat +++ b/html/cgi-bin/logs.cgi/ovpnclients.dat @@ -128,7 +128,8 @@ my $database_query =3D qq( =20 if ($cgiparams{'CONNECTION_NAME'}) { $database_query =3D qq( - SELECT common_name, DATETIME(connected_at, 'localtime'), DATETIME(disconne= cted_at, 'localtime'), bytes_received, bytes_sent FROM sessions + SELECT common_name, DATETIME(connected_at, 'localtime'), DATETIME(disconne= cted_at, 'localtime'), bytes_received, bytes_sent, + STRFTIME('%s', DATETIME(disconnected_at)) - STRFTIME('%s', DATETIME(conne= cted_at)) AS duration FROM sessions WHERE common_name =3D '$cgiparams{"CONNECTION_NAME"}' AND ( @@ -260,8 +261,9 @@ my $col =3D "bgcolor=3D'$color{'color20'}'"; print "$Lang::tr{'ovpn connection name'}\n"; =20 if ($cgiparams{'CONNECTION_NAME'}) { - print "$Lang::tr{'connected'}\n"; - print "$Lang::tr{'disconnected'}\n"; + print "$Lang::tr{'connected'}\n"; + print "$Lang::tr{'disconnected'}\n"; + print "$Lang::tr{'duration'}= \n"; print "$Lang::tr{'received'}= \n"; print "$Lang::tr{'sent'}\n"; } else { @@ -279,6 +281,7 @@ unless ($errormessage) { my $connection_close_time =3D $row[2]; my $connection_bytes_recieved =3D &General::formatBytes($row[3]); my $connection_bytes_sent =3D &General::formatBytes($row[4]); + my $duration =3D &General::format_time($row[5]); =20 # Colorize columns. if ($lines % 2) { @@ -291,8 +294,9 @@ unless ($errormessage) { print "$connection_name\n"; =20 if ($cgiparams{'CONNECTION_NAME'}) { - print "$connection_open_time\n"; - print "$connection_close_time\n"; + print "$connection_open_time\n"; + print "$connection_close_time\n"; + print "$duration\n"; print "$connection_bytes_recieved<= /td>\n"; print "$connection_bytes_sent= \n"; } else { @@ -312,7 +316,7 @@ unless ($errormessage) { # If nothing has been fetched, the amount of lines is still zero. # In this case display a hint about no data.=09 unless ($lines) { - print "$Lang::tr{'no entries'}\n"; + print "$Lang::tr{'no entries'}\n"; } =20 print "
\n"; --=20 2.26.0 --===============6672800718547469760==--