#
sql_user_name = "%{User-Name}"
+#######################################################################
+# Query config: Event-Timestamp
+#######################################################################
+# event_timestamp_epoch is the basis for the time inserted into
+# accounting records. Typically this will be the Event-Timestamp of the
+# accounting request, which is usually provided by a NAS.
+#
+# Uncomment the next line, if you want the timestamp to be based on the
+# request reception time recorded by this server, for example if you
+# distrust the provided Event-Timestamp.
+#event_timestamp_epoch = "%l"
+
+event_timestamp_epoch = "%{%{integer:Event-Timestamp}:-%l}"
+
+# event_timestamp is the SQL snippet for converting an epoch timestamp
+# to an SQL date.
+
+event_timestamp = "DATEADD(SS, ${event_timestamp_epoch}, '19700101')"
+
#######################################################################
# Authorization Queries
#######################################################################
query = "\
UPDATE ${....acct_table1} \
SET \
- AcctStopTime='%S', \
- AcctSessionTime=unix_timestamp('%S') - \
- unix_timestamp(AcctStartTime), \
+ AcctStopTime=${....event_timestamp}, \
+ AcctSessionTime=${....event_timestamp_epoch} - \
+ DATEDIFF(SS, '1970-01-01', AcctStartTime), \
AcctTerminateCause='%{%{Acct-Terminate-Cause}:-NAS-Reboot}', \
AcctStopDelay = %{%{Acct-Delay-Time}:-0} \
WHERE AcctStopTime = 0 \
AND NASIPAddress = '%{NAS-IP-Address}' \
- AND AcctStartTime <= '%S'"
+ AND AcctStartTime <= ${....event_timestamp}"
}
accounting-off {
'%{NAS-IP-Address}', \
'%{%{NAS-Port-ID}:-%{NAS-Port}}', \
'%{NAS-Port-Type}', \
- '%S', \
+ ${....event_timestamp}, \
'0', \
'%{Acct-Authentic}', \
'%{Connect-Info}', \
query = "\
UPDATE ${....acct_table1} \
SET \
- AcctStartTime = '%S', \
+ AcctStartTime = ${....event_timestamp}, \
AcctStartDelay = '%{%{Acct-Delay-Time}:-0}', \
ConnectInfo_start = '%{Connect-Info}' \
WHERE AcctUniqueId = '%{Acct-Unique-Session-ID}' \
query = "\
UPDATE ${....acct_table2} \
SET \
- AcctStopTime = '%S', \
+ AcctStopTime = ${....event_timestamp}, \
AcctSessionTime = '%{Acct-Session-Time}', \
AcctInputOctets = convert(bigint, '%{%{Acct-Input-Gigawords}:-0}' * POWER(2.0, 32)) | '%{%{Acct-Input-Octets}:-0}', \
AcctOutputOctets = convert(bigint, '%{%{Acct-Output-Gigawords}:-0}' * POWER(2.0, 32)) | '%{%{Acct-Output-Octets}:-0}', \
'%{NAS-IP-Address}', \
'%{%{NAS-Port-ID}:-%{NAS-Port}}', \
'%{NAS-Port-Type}', \
- '%S', \
+ ${....event_timestamp}, \
'%{Acct-Session-Time}', \
'%{Acct-Authentic}', \
'', \