Adding custom SQL counter

Lorenzo Milesi maxxer at ufficyo.com
Fri Feb 27 17:34:25 CET 2015


Hi. I'm trying to create a custom counter which basically is the same as Max-Daily-Session but restricted to the current Called-Station-Id.

I added this to sql/mysql/counter.conf:
sqlcounter dailycounterlocation {
            counter-name = Daily-Session-Location-Time
            check-name = Max-Daily-Session-Location
            reply-name = Session-Timeout
            sqlmod-inst = sql 
            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') \
                 AND calledstationid = '%{Called-Station-Id}' "
}

then in sites-enabled/default:
[...]
authorize {
    dailycounterlocation {
        reject = 1
    }
    if(reject){
        update reply {
            Reply-Message := "You have reached your daily time limit from this location"
        }
        reject
    }
}


but it's not working at all...
Compared to a Max-Daily-Session attribute, in the radius debug I see the value gets returned just after the group check query. Instead with my custom attribute the value is never returned, the check query returns null (when there's no previous activity in radacct) so the user can stay connected forever (for the first session, from the second on it works).

What am I doing wrong? Why the default session timeout is not returned?
thanks
-- 
Lorenzo Milesi - lorenzo.milesi at yetopen.it

YetOpen S.r.l. - http://www.yetopen.it/


More information about the Freeradius-Users mailing list