Fwd: rlm_sqlcounter always return 0
Alan DeKok
aland at deployingradius.com
Tue Jan 8 01:05:08 CET 2013
Mike Russell wrote:
> I tried to search the mail archives for the similar topic but did not
> find matched results. Then read wiki again to crosscheck that if i have
> done it well before posting on the mailing list. I am sorry if similar
> post has been answered before. I have problem with "rlm_sqlcounter"
> module. That is "noresetcounter" it always return "0". But if
> i manually run the query to gerp the users accounting data from MySQL
> DB, i get accounting results. it seems that everything is in place but
> unable to know why sql counter still returns zero. whereas dailycounter
> works fine without any problem.
The sqlcounter module should be pretty simple. Configure accounting
data to go into SQL, and ensure that the server is receiving accounting
packets. Then, configure the sqlcounter module.
> My rlm_sqlnoresetcounter module:
>
> sqlcounter noresetcounter {
> driver = rlm_sqlcounter
Don't invent configuration. This line does NOTHING. DELETE IT.
> counter-name = Max-All-Session-Time
> check-name = Max-All-Session
> sqlmod-inst = sql
> key = User-Name
> reset = never
> query = "SELECT IFNULL(SUM(AcctSessionTime),0) FROM
> radacct WHERE UserName='${key}'"
You edited the default configuration, and broke it. Don't do that.
The default uses %{${key}}, not ${key}. They're different.
> To Prove the point i would also need to send radtest results for comparison:
It would help to read the output.
> sqlcounter_expand: 'SELECT IFNULL(SUM(AcctSessionTime),0) FROM radacct
> WHERE UserName='User-Name''
...
> [noresetcounter] expand: SELECT IFNULL(SUM(AcctSessionTime),0)
> FROM radacct WHERE UserName='User-Name' -> SELECT
> IFNULL(SUM(AcctSessionTime),0) FROM radacct WHERE UserName='User-Name'
Is the UserName field in SQL "User-Name"?
I know that there's a lot of debugging output. But the entire point
if it is for you to *read it*. Look for inconsistencies.
> Now lets grep the accounting value from database for the same user
> (returned "0" earlier)
> This user has "Max-All-Session" attribute applied and exist in
> "radgroupreply" table.
>
> mysql> SELECT IFNULL(SUM(AcctSessionTime),0) FROM radacct WHERE
> UserName='KV60Rp2vtrEe5B';
You see how that's different from the query in the debug output?
You're testing *different things*.
The point of debugging output is for you to CUT & PASTE the SQL
queries, to see what they do when run manually. You didn't do that.
You ran a *different* query.
> Why rlm_counter returns the zero value.
Don't break the server.
Alan DeKok.
More information about the Freeradius-Users
mailing list