Unlang and variables

Ti Ti tt91em at gmail.com
Fri Sep 29 10:09:02 CEST 2017


Thanks.
In case of counters how can I use the policy? Because I have to specify the
db in sql_module_instance

sqlcounter dailycountertime{
    sql_module_instance = db1
    dialect = mysql
    counter_name = Daily-Session-Time
    check_name = Max-Daily-Session
    reply_name = Session-Timeout
    key = User-Name
    reset = daily
    query = "SELECT SUM(acctsessiontime - GREATEST((%%b -
UNIX_TIMESTAMP(acctstarttime)), 0)) FROM radacct WHERE username =
'%{${key}}' AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%%b'"
}

2017-09-28 23:57 GMT+02:00 Alan DeKok <aland at deployingradius.com>:

> On Sep 28, 2017, at 3:50 PM, Ti Ti <tt91em at gmail.com> wrote:
> >
> > Hello,
> > I'm using unlang to discriminate the database to use as described in the
> > code below.
> > Is there a method to use variables so avoid the redundant check of
> NAS-Id?
>
>   You can't mix multiple regular expressions and get multiple different
> outputs.  The regular expression libraries don't allow it.
>
>   If you want to use the same set of "if" statements in multiple places,
> use policies.  Add raddb/policy.d/check-nas-id, and put this into it:
>
> policy check-nas-id {
>      if (&NAS-Identifier =~ /test/i) {
>        db1
>      }
>      if (&NAS-Identifier =~ /test2/i) {
>        db2
>      }
> }
>
>   Then everywhere you need that set of "if" statements, just use:
>
>         check-nas-id
>
>   Alan DeKok.
>
>
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/
> list/users.html


More information about the Freeradius-Users mailing list