Commit f04c558b authored by Angel L. Mateo's avatar Angel L. Mateo
Browse files

Add more parameters to freeradius::sql

The parameters added are to configure connection pool
parent c88a39a9
......@@ -776,6 +776,28 @@ Table to keep radius client info. Default: `nas`.
Set to `yes` to read radius clients from the database (`$nas_table`) Clients will ONLY be read on server startup. For performance
and security reasons, finding clients via SQL queries CANNOT be done "live" while the server is running. Default: `no`.
##### `pool_start`
Connections to create during module instantiation. Default: 1.
##### `pool_min`
Minimum number of connnections to keep open. Default: 1.
##### `pool_spare`
Spare connections to be left idle. Default: 1.
##### `pool_idle_timeout`
Idle timeout (in seconds). A connection which is unused for this length of time will
be closed. Default: 60.
##### `pool_connect_timeout`
Connection timeout (in seconds). The maximum amount of time to wait for a new
connection to be established. Default: '3.0'.
#### `freeradius::statusclient`
Define RADIUS clients, specifically to connect to the status server for monitoring.
......
......@@ -2,31 +2,36 @@
define freeradius::sql (
$database,
$password,
$server = 'localhost',
$login = 'radius',
$radius_db = 'radius',
$num_sql_socks = '${thread[pool].max_servers}',
$query_file = 'sql/${database}/queries.conf',
$custom_query_file = '',
$lifetime = '0',
$max_queries = '0',
$ensure = present,
$acct_table1 = 'radacct',
$acct_table2 = 'radacct',
$postauth_table = 'radpostauth',
$authcheck_table = 'radcheck',
$authreply_table = 'radreply',
$groupcheck_table = 'radgroupcheck',
$groupreply_table = 'radgroupreply',
$usergroup_table = 'radusergroup',
$deletestalesessions = 'yes',
$sqltrace = 'no',
$sqltracefile = '${logdir}/sqllog.sql',
$server = 'localhost',
$login = 'radius',
$radius_db = 'radius',
$num_sql_socks = '${thread[pool].max_servers}',
$query_file = 'sql/${database}/queries.conf',
$custom_query_file = '',
$lifetime = '0',
$max_queries = '0',
$ensure = present,
$acct_table1 = 'radacct',
$acct_table2 = 'radacct',
$postauth_table = 'radpostauth',
$authcheck_table = 'radcheck',
$authreply_table = 'radreply',
$groupcheck_table = 'radgroupcheck',
$groupreply_table = 'radgroupreply',
$usergroup_table = 'radusergroup',
$deletestalesessions = 'yes',
$sqltrace = 'no',
$sqltracefile = '${logdir}/sqllog.sql',
$connect_failure_retry_delay = '60',
$nas_table = 'nas',
$read_groups = 'yes',
$port = '3306',
$readclients = 'no',
$nas_table = 'nas',
$read_groups = 'yes',
$port = '3306',
$readclients = 'no',
$pool_start = 1,
$pool_min = 1,
$pool_spare = 1,
$pool_idle_timeout = 60,
$pool_connect_timeout = '3.0',
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
......@@ -51,7 +56,7 @@ define freeradius::sql (
unless is_integer($port) {
fail('$port must be an integer')
}
unless is_integer($num_sql_socks) {
unless is_integer($num_sql_socks) or $num_sql_socks == '${thread[pool].max_servers}' {
fail('$num_sql_socks must be an integer')
}
unless is_integer($lifetime) {
......@@ -63,6 +68,18 @@ define freeradius::sql (
unless is_integer($connect_failure_retry_delay) {
fail('$connect_failure_retry_delay must be an integer')
}
unless is_integer($pool_start_delay) {
fail('$pool_start_delay must be an integer')
}
unless is_integer($pool_min_delay) {
fail('$pool_min_delay must be an integer')
}
unless is_integer($pool_spare_delay) {
fail('$pool_spare_delay must be an integer')
}
unless is_integer($pool_idle_timeout_delay) {
fail('$pool_idle_timeout_delay must be an integer')
}
# Fake booleans (FR uses yes/no instead of true/false)
unless $deletestalesessions in ['yes', 'no'] {
......
......@@ -140,10 +140,10 @@ sql <%= @name %> {
# connections during instantiation it will exit.
# Set to 0 to allow the server to start without the
# database being available.
start = 1
start = <%= @pool_start %>
# Minimum number of connections to keep open
min = 1
min = <%= @pool_min %>
# Maximum number of connections
#
......@@ -162,7 +162,7 @@ sql <%= @name %> {
#
# NOTE: Idle connections WILL be closed if "idle_timeout"
# is set. This should be less than or equal to "max" above.
spare = 1
spare = <%= @pool_spare %>
# Number of uses before the connection is closed
#
......@@ -179,7 +179,7 @@ sql <%= @name %> {
# idle timeout (in seconds). A connection which is
# unused for this length of time will be closed.
idle_timeout = 60
idle_timeout = <%= @pool_idle_timeout %>
# Connection timeout (in seconds). The maximum amount of
# time to wait for a new connection to be established.
......@@ -188,7 +188,7 @@ sql <%= @name %> {
# rlm_sql_oracle - Not possible.
# rlm_sql_postgresql - Should be set via the radius_db string instead.
#
connect_timeout = 3.0
connect_timeout = <%= @pool_connect_timeout %>
# NOTE: All configuration settings are enforced. If a
# connection is closed because of "idle_timeout",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment