Added the STATS_DURATION script environment variable.

This variable reports the duration of the session in seconds.
This commit is contained in:
Nikos Mavrogiannopoulos
2014-05-04 11:19:12 +02:00
parent 593ce2c9fa
commit d6583945f9
4 changed files with 9 additions and 3 deletions

2
NEWS
View File

@@ -1,6 +1,8 @@
* Version 0.3.5 (unreleased)
- Corrected issue in the stats reporting for resumed processes.
- Added the STATS_DURATION script environment variable which reports
the duration of the session in seconds.
* Version 0.3.4 (released 2014-05-01)

View File

@@ -8,7 +8,7 @@ if [ "$REASON" = "connect" ];then
else
iptables -D INPUT -i $DEVICE -j ACCEPT
echo "User '$USERNAME' from '$IP_REAL' disconnected (in: $STATS_BYTES_IN, out: $STATS_BYTES_OUT)."
echo "User '$USERNAME' from '$IP_REAL' disconnected (in: $STATS_BYTES_IN, out: $STATS_BYTES_OUT, time: $STATS_DURATION)."
fi
exit 0

View File

@@ -129,6 +129,10 @@ const char* script;
setenv("STATS_BYTES_IN", remote, 1);
snprintf(remote, sizeof(remote), "%lu", (unsigned long)proc->bytes_out);
setenv("STATS_BYTES_OUT", remote, 1);
if (proc->conn_time > 0) {
snprintf(remote, sizeof(remote), "%lu", (unsigned long)(time(0)-proc->conn_time));
setenv("STATS_DURATION", remote, 1);
}
setenv("REASON", "disconnect", 1);
}

View File

@@ -234,8 +234,8 @@ rekey-method = ssl
# ID (a unique numeric ID); REASON may be "connect" or "disconnect".
# The disconnect script will received the additional values: STATS_BYTES_IN,
# STATS_BYTES_OUT, that contain a 64-bit counter of the bytes output from the
# tun device.
# STATS_BYTES_OUT, STATS_DURATION that contain a 64-bit counter of the bytes
# output from the tun device, and the duration of the session in seconds.
#connect-script = /usr/bin/myscript
#disconnect-script = /usr/bin/myscript