From: Terry Burton Date: Fri, 16 Aug 2019 11:09:24 +0000 (+0100) Subject: Cassandra queries.conf: Simplify using expansions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdbaab151e2ddd79a09b86cf262ded938941706a;p=thirdparty%2Ffreeradius-server.git Cassandra queries.conf: Simplify using expansions --- diff --git a/raddb/mods-config/sql/main/cassandra/queries.conf b/raddb/mods-config/sql/main/cassandra/queries.conf index 1fd278c70e7..a575e44d528 100644 --- a/raddb/mods-config/sql/main/cassandra/queries.conf +++ b/raddb/mods-config/sql/main/cassandra/queries.conf @@ -37,6 +37,25 @@ # 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 = "%{expr:${event_timestamp_epoch} * 1000}" + ####################################################################### # Default profile ####################################################################### @@ -139,7 +158,7 @@ accounting { accounting-on { query = "\ INSERT INTO radnasreboot (nasipaddress, timestamp) \ - VALUES ('%{NAS-IP-Address}', %{expr:%{%{integer:Event-Timestamp}:-%l}} * 1000});" + VALUES ('%{NAS-IP-Address}', ${....event_timestamp});" } accounting-off { @@ -183,8 +202,8 @@ accounting { '%{NAS-IP-Address}', \ '%{%{NAS-Port-Id}:-%{NAS-Port}}', \ '%{NAS-Port-Type}', \ - %{expr:%{%{integer:Event-Timestamp}:-%l} * 1000}, \ - %{expr:%{%{integer:Event-Timestamp}:-%l} * 1000}, \ + ${....event_timestamp}, \ + ${....event_timestamp}, \ null, \ '%{Acct-Authentic}', \ '%{Connect-Info}', \ @@ -210,7 +229,7 @@ accounting { acctstarttime \ ) VALUES ( \ '%{Acct-Unique-Session-Id}', \ - %{expr:(%{%{integer:Event-Timestamp}:-%l} - &Acct-Session-Time) * 1000} \ + %{expr:(${....event_timestamp_epoch} - &Acct-Session-Time) * 1000} \ ) IF NOT EXISTS; \ INSERT INTO ${....acct_table1} ( \ acctuniqueid, \ @@ -243,7 +262,7 @@ accounting { '%{NAS-IP-Address}', \ '%{%{NAS-Port-Id}:-%{NAS-Port}}', \ '%{NAS-Port-Type}', \ - %{expr:%{%{integer:Event-Timestamp}:-%l} * 1000}, \ + ${....event_timestamp}, \ null, \ '%{Acct-Authentic}', \ '%{Connect-Info}', \ @@ -270,7 +289,7 @@ accounting { acctstarttime \ ) VALUES ( \ '%{Acct-Unique-Session-Id}', \ - %{expr:(%{%{integer:Event-Timestamp}:-%l} - &Acct-Session-Time) * 1000} \ + %{expr:(${....event_timestamp_epoch} - &Acct-Session-Time) * 1000} \ ) IF NOT EXISTS; \ INSERT INTO ${....acct_table1} ( \ acctuniqueid, \ @@ -304,8 +323,8 @@ accounting { '%{NAS-IP-Address}', \ '%{%{NAS-Port-Id}:-%{NAS-Port}}', \ '%{NAS-Port-Type}', \ - %{expr:%{%{integer:Event-Timestamp}:-%l} * 1000}, \ - %{expr:%{%{integer:Event-Timestamp}:-%l} * 1000}, \ + ${....event_timestamp}, \ + ${....event_timestamp}, \ '%{Acct-Authentic}', \ '%{Connect-Info}', \ %{expr:(&Acct-Input-Gigawords << 32) | &Acct-Input-Octets}, \