#  -*- text -*-
######################################################################
#
#	This is a sample configuration for "decoupled" accounting.
#	"Decoupled" accounting is where the accounting packets are
#	NOT written "live" to the back-end database.  This method
#	can only be used if you are not interested in "live"
#	accounting.  i.e. Where you can tolerate delays that may be
#	a few seconds, before accounting packets get written to
#	the DB.
#
#	Oddly enough, this method can speed up the processing of
#	accounting packets, as all database activity is serialized.
#
#	This file is NOT meant to be used as-is.  It needs to be
#	edited to match your local configuration.
#
#	$Id: 537a4b4fa1232be4ae232a1f955fc2b7b9c873ca $
#
######################################################################

#  Define a virtual server to write the accounting packets. Any
#  "listen" section that listens on an accounting port should set
#  "virtual_server = write-detail.example.com
server write_detail.example.com {
	recv Accounting-Request {
		#
		#  Write the "detail" files.
		#
		#  See mods-available/detail.example.com for more info.
		detail.example.com
	}

	#  That's it!
}

#  Define a virtual server to process the accounting packets.
server read-detail.example.com {
	#  Read accounting packets from the detail file(s) for the home
	#  server.
	listen {
		type = detail
		filename = "${radacctdir}/detail.example.com/detail-*:*"
		load_factor = 10
		track = yes
	}

	#  All packets read from the detail file are processed through the
	#  preacct && accounting sections.
	#
	#  The following text is copied verbatim from
	#  sites-available/default. You should edit it for your own local
	#  configuration.

#
#  Pre-accounting. Decide which accounting type to use.
#
recv Accounting-Request {
	#
	#  Ensure that we have a semi-unique identifier for every request,
	#  and many NAS boxes are broken.
	acct_unique

	#
	#  Read the 'acct_users' file
	files
}

#
#  Accounting. Log the accounting data.
#
send Accounting-Response {
	#
	#  Create a 'detail'ed log of the packets. Note that accounting
	#  requests which are proxied are also logged in the detail file.
	detail
#	daily

	#
	#  Return an address to the IP Pool when we see a stop record.
	#
	#  Ensure that control.IP-Pool.Name is set to determine which pool of
	#  IPs are used.
	#
	sqlippool

	#
	#  Log traffic to an SQL database.
	#
	#  NOTE! You will have to ensure that any accounting packets NOT
	#  handled by the SQL module (e.g. "stop with zero session length"
	#  result in the accounting section still returning "ok".
	#
	#  Otherwise, the server will think that the accounting packet was
	#  NOT handled properly, and will keep trying to process it through
	#  this virtual server!
	#
	#  See "Accounting queries" in
	#  `mods-config/sql/main/$driver/queries.conf`
	#	sql

	#
	#  Instead of sending the query to the SQL server, write it into a
	#  log file.
	#
	#	sql_log

	#  Cisco VoIP specific bulk accounting
	#	pgsql-voip

	#  Filter attributes from the accounting response.
	attr_filter.accounting_response
}
