From patchwork Mon Apr 13 07:45:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 2954 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4910zz43sTz3yBt for ; Mon, 13 Apr 2020 07:46:23 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4910zl4k1qz2ql; Mon, 13 Apr 2020 07:46:11 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4910zl3mpjz30FF; Mon, 13 Apr 2020 07:46:11 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4910zf51RXz30FG for ; Mon, 13 Apr 2020 07:46:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 4910zd4sR3z2jN; Mon, 13 Apr 2020 07:46:05 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1586763965; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kqp8oZgUEFfKRLRrstOtL2+sGfiC03ef7nfb6QiVz0o=; b=EMtGLobJelIF8Y6Ne8PXB1s7ZHqy+CqfkeheEzKK/aj/HTOArn/6PWzB1aPF69giFVJaKQ 3GcVUpnppfxGnWAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1586763965; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kqp8oZgUEFfKRLRrstOtL2+sGfiC03ef7nfb6QiVz0o=; b=jPbvilE1hCzF4n+zsR4+xInu9t+r9oai7Wl8408PkCt11FYHnVP7jVx6ceYVIVap7AzBvd 81tx4kt4XqrfQVwuH6i5e4aMbWexszeObZZNvol3x+UvbbtZHXQlLAJkfTmqju+D+IvIJS v6+ulvqmtkUJiS2sifwDOB9XFWj13CRUjhsEBs7ZlvNElAj3NM8ly2T2UGnxLf4ySsUMMH kQHs5sN+Mcv78T6JegAkNqX8/RgZTuMzlhr+Y3DVyhmsOxvt7LU1jEikBn4/78RGa8Lomv dtjudKrgeaBiiQDZUP0fo2y7VkeWJzQhQga+Kb8G06LbI3dDWjTmnCwbCfZpKg== 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> References: <20200413074550.2735-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=stefan.schantl@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" 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/ovpnclients.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 = qq( if ($cgiparams{'CONNECTION_NAME'}) { $database_query = qq( - SELECT common_name, DATETIME(connected_at, 'localtime'), DATETIME(disconnected_at, 'localtime'), bytes_received, bytes_sent FROM sessions + SELECT common_name, DATETIME(connected_at, 'localtime'), DATETIME(disconnected_at, 'localtime'), bytes_received, bytes_sent, + STRFTIME('%s', DATETIME(disconnected_at)) - STRFTIME('%s', DATETIME(connected_at)) AS duration FROM sessions WHERE common_name = '$cgiparams{"CONNECTION_NAME"}' AND ( @@ -260,8 +261,9 @@ my $col = "bgcolor='$color{'color20'}'"; print "$Lang::tr{'ovpn connection name'}\n"; 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 = $row[2]; my $connection_bytes_recieved = &General::formatBytes($row[3]); my $connection_bytes_sent = &General::formatBytes($row[4]); + my $duration = &General::format_time($row[5]); # Colorize columns. if ($lines % 2) { @@ -291,8 +294,9 @@ unless ($errormessage) { print "$connection_name\n"; 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\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. unless ($lines) { - print "$Lang::tr{'no entries'}\n"; + print "$Lang::tr{'no entries'}\n"; } print "
\n";