Skip to content
Permalink
Browse files

Cassandra queries.conf: Simplify using expansions

  • Loading branch information
terryburton authored and alandekok committed Aug 16, 2019
1 parent 72b40e3 commit cdbaab151e2ddd79a09b86cf262ded938941706a
Showing with 27 additions and 8 deletions.
  1. +27 −8 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}, \

0 comments on commit cdbaab1

Please sign in to comment.
You can’t perform that action at this time.