Hi, I've been working on a SQL based version of the Counter module. This makes use of the excellent new sql_xlat function added by Kostas Kalevras (thank you, thank you!).
I think this may address some of the questions I've seen on the list about using SQL and Counters together. I would really appreciate it if those of you who know the code base well could take a look and see if I've done anything unsafe. The majority of the code comes from the original counter module. I also pulled in some code from the xlat.c file. Very little is actually new (look for the sqlcounter_expand function and the places where it is called). The module uses the accounting data maintained by the SQL module in the 'radacct' table to track total session time, rather than maintaining a separate database for each Counter instance. This module does NOT do any processing of Accounting packets. That is left completely to the SQL module. This should be considered alpha code, but it seems to work in my development environment. I haven't tried it in production yet. You can download a patch file that adds the new module here: http://www.axion-it.net/download/rlm_sqlcounter.patch This patch was built on the 20020415 snapshot. There is a README.txt file in the new src/modules/rlm_sqlcounter directory with some notes on using the module. I don't know if I setup the structure of the module completely right. There were a couple of files in the rlm_counter directory that I don't know if I really need in 'rlm_sqlcounter' (esp. acconfig.h and config.h.in). But it does compile happily on my RedHat 7.1 system. I wrote and tested this using a MySql server. To convert from a unix time integer to the database datetime values, I used the FROM_UNIXTIME() function. I'm not sure if this is portable or if other SQL servers have equivalent functions. If not, I may need to rework the way the SQL query gets translated. One thing I don't really understand is the 'counter_cmp' function. I made what I think is the equivalent 'sqlcounter_cmp' function, but I can't see how this function would ever get called, so I haven't been able to test it. Is this function really necessary? How is it used? Please let me know if you have any comments or concerns. Thanks. Randy Moore Axion Information Technologies, Inc. email [EMAIL PROTECTED] phone 301-408-1200 fax 301-445-3947 - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
