rlm_sqlcounter reset value
Hi, I have configured successfully the rlm_sqlcounter module and set the "reset" attribute to daily and its working properly, but I was wondering if it is possible to have this attribute dynamic for each user, based on SQL query, meaning rather than defining a static value in configuration file, is it possible to define a SQL query that runs each time and gets the value from database. Thanks
Yes you can use sql variable on both sides of the operator(if thats what you mean) your question is not very clear. You can have different reset values for every user though. BR, Anirudh Malhotra Sent from a handheld device, Sorry for typos.
On 12-Dec-2015, at 23:50, Muhammad Usman <muhd.usman87@gmail.com> wrote:
Hi, I have configured successfully the rlm_sqlcounter module and set the "reset" attribute to daily and its working properly, but I was wondering if it is possible to have this attribute dynamic for each user, based on SQL query, meaning rather than defining a static value in configuration file, is it possible to define a SQL query that runs each time and gets the value from database. Thanks - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Use unlang Pada tanggal 13 Des 2015 01.21, "Muhammad Usman" <muhd.usman87@gmail.com> menulis:
Hi, I have configured successfully the rlm_sqlcounter module and set the "reset" attribute to daily and its working properly, but I was wondering if it is possible to have this attribute dynamic for each user, based on SQL query, meaning rather than defining a static value in configuration file, is it possible to define a SQL query that runs each time and gets the value from database. Thanks - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Thanks for your replies. Can you please elaborate your answers. I want FreeRadius to get this value from database (stored different values for different users) at runtime. How can i achieve different reset values for different users? On Sun, Dec 13, 2015 at 7:31 AM, johan firdianto <johanfirdi@gmail.com> wrote: > Use unlang > Pada tanggal 13 Des 2015 01.21, "Muhammad Usman" <muhd.usman87@gmail.com> > menulis: > > > Hi, > > I have configured successfully the rlm_sqlcounter module and set the > > "reset" attribute to daily and its working properly, but I was wondering > if > > it is possible to have this attribute dynamic for each user, based on SQL > > query, meaning rather than defining a static value in configuration file, > > is it possible to define a SQL query that runs each time and gets the > value > > from database. Thanks > > - > > List info/subscribe/unsubscribe? See > > http://www.freeradius.org/list/users.html > - > List info/subscribe/unsubscribe? See > http://www.freeradius.org/list/users.html >
Also how can i use unlang for a group rather than a user? On Sun, Dec 13, 2015 at 9:48 AM, Muhammad Usman <muhd.usman87@gmail.com> wrote: > Thanks for your replies. Can you please elaborate your answers. > > I want FreeRadius to get this value from database (stored different values > for different users) at runtime. > How can i achieve different reset values for different users? > > On Sun, Dec 13, 2015 at 7:31 AM, johan firdianto <johanfirdi@gmail.com> > wrote: > >> Use unlang >> Pada tanggal 13 Des 2015 01.21, "Muhammad Usman" <muhd.usman87@gmail.com> >> menulis: >> >> > Hi, >> > I have configured successfully the rlm_sqlcounter module and set the >> > "reset" attribute to daily and its working properly, but I was >> wondering if >> > it is possible to have this attribute dynamic for each user, based on >> SQL >> > query, meaning rather than defining a static value in configuration >> file, >> > is it possible to define a SQL query that runs each time and gets the >> value >> > from database. Thanks >> > - >> > List info/subscribe/unsubscribe? See >> > http://www.freeradius.org/list/users.html >> - >> List info/subscribe/unsubscribe? See >> http://www.freeradius.org/list/users.html >> > >
Did you try changing the query in dailycounter? http://wiki.freeradius.org/modules/Rlm_sqlcounter Follow the link use another sql query instead of %b, to select the time you want to select for the user. BR, Anirudh Malhotra NKN Sent from a handheld device, Sorry for typos. > On 13-Dec-2015, at 10:18, Muhammad Usman <muhd.usman87@gmail.com> wrote: > > Thanks for your replies. Can you please elaborate your answers. > > I want FreeRadius to get this value from database (stored different values > for different users) at runtime. > How can i achieve different reset values for different users? > > On Sun, Dec 13, 2015 at 7:31 AM, johan firdianto <johanfirdi@gmail.com> > wrote: > >> Use unlang >> Pada tanggal 13 Des 2015 01.21, "Muhammad Usman" <muhd.usman87@gmail.com> >> menulis: >> >>> Hi, >>> I have configured successfully the rlm_sqlcounter module and set the >>> "reset" attribute to daily and its working properly, but I was wondering >> if >>> it is possible to have this attribute dynamic for each user, based on SQL >>> query, meaning rather than defining a static value in configuration file, >>> is it possible to define a SQL query that runs each time and gets the >> value >>> from database. Thanks >>> - >>> List info/subscribe/unsubscribe? See >>> http://www.freeradius.org/list/users.html >> - >> List info/subscribe/unsubscribe? See >> http://www.freeradius.org/list/users.html > - > List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
I have already changed the query according to this wiki page, but now i
want to keep the reset paramter as dynamic based on group.
sqlcounter dailycounter {
counter-name = 'Daily-Session-Time'
check-name = 'Max-Daily-Session'
sql_module_instance = 'sql'
key = 'User-Name'
reset = daily (rather defining it one time, I want it to dynamic,
may be an SQL query)
query = "SELECT SUM(AcctSessionTime - GREATEST((%b -
UNIX_TIMESTAMP(AcctStartTime)), 0)) FROM radacct WHERE
UserName='%{${key}}' AND UNIX_TIMESTAMP(AcctStartTime) +
AcctSessionTime > '%b'"
}
On Sun, Dec 13, 2015 at 10:01 AM, Anirudh Malhotra <amalhotra.sp-dl@nkn.in>
wrote:
> Did you try changing the query in dailycounter?
> http://wiki.freeradius.org/modules/Rlm_sqlcounter
>
> Follow the link use another sql query instead of %b, to select the time
> you want to select for the user.
> BR,
> Anirudh Malhotra
> NKN
>
> Sent from a handheld device, Sorry for typos.
>
> > On 13-Dec-2015, at 10:18, Muhammad Usman <muhd.usman87@gmail.com> wrote:
> >
> > Thanks for your replies. Can you please elaborate your answers.
> >
> > I want FreeRadius to get this value from database (stored different
> values
> > for different users) at runtime.
> > How can i achieve different reset values for different users?
> >
> > On Sun, Dec 13, 2015 at 7:31 AM, johan firdianto <johanfirdi@gmail.com>
> > wrote:
> >
> >> Use unlang
> >> Pada tanggal 13 Des 2015 01.21, "Muhammad Usman" <
> muhd.usman87@gmail.com>
> >> menulis:
> >>
> >>> Hi,
> >>> I have configured successfully the rlm_sqlcounter module and set the
> >>> "reset" attribute to daily and its working properly, but I was
> wondering
> >> if
> >>> it is possible to have this attribute dynamic for each user, based on
> SQL
> >>> query, meaning rather than defining a static value in configuration
> file,
> >>> is it possible to define a SQL query that runs each time and gets the
> >> value
> >>> from database. Thanks
> >>> -
> >>> List info/subscribe/unsubscribe? See
> >>> http://www.freeradius.org/list/users.html
> >> -
> >> List info/subscribe/unsubscribe? See
> >> http://www.freeradius.org/list/users.html
> > -
> > List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
>
Finally, i understand your question now. Or maybe i think i do.
Ok so in the authorize section use unlang as johan said use an attribute in radcheck which has value as "reset" or "never" whichever you want.
If("mysql query get attribute for user" == daily)
{
Dailyresetcounter
}
If("mysql query get attribute for user" == never)
{
Neverresetcounter
}
Hope this finally answers your question.
BR,
Anirudh Malhotra
NKN
Sent from a handheld device, Sorry for typos.
> On 13-Dec-2015, at 10:48, Muhammad Usman <muhd.usman87@gmail.com> wrote:
>
> I have already changed the query according to this wiki page, but now i
> want to keep the reset paramter as dynamic based on group.
>
> sqlcounter dailycounter {
> counter-name = 'Daily-Session-Time'
> check-name = 'Max-Daily-Session'
> sql_module_instance = 'sql'
> key = 'User-Name'
> reset = daily (rather defining it one time, I want it to dynamic,
> may be an SQL query)
> query = "SELECT SUM(AcctSessionTime - GREATEST((%b -
> UNIX_TIMESTAMP(AcctStartTime)), 0)) FROM radacct WHERE
> UserName='%{${key}}' AND UNIX_TIMESTAMP(AcctStartTime) +
> AcctSessionTime > '%b'"
> }
>
>
> On Sun, Dec 13, 2015 at 10:01 AM, Anirudh Malhotra <amalhotra.sp-dl@nkn.in>
> wrote:
>
>> Did you try changing the query in dailycounter?
>> http://wiki.freeradius.org/modules/Rlm_sqlcounter
>>
>> Follow the link use another sql query instead of %b, to select the time
>> you want to select for the user.
>> BR,
>> Anirudh Malhotra
>> NKN
>>
>> Sent from a handheld device, Sorry for typos.
>>
>>> On 13-Dec-2015, at 10:18, Muhammad Usman <muhd.usman87@gmail.com> wrote:
>>>
>>> Thanks for your replies. Can you please elaborate your answers.
>>>
>>> I want FreeRadius to get this value from database (stored different
>> values
>>> for different users) at runtime.
>>> How can i achieve different reset values for different users?
>>>
>>> On Sun, Dec 13, 2015 at 7:31 AM, johan firdianto <johanfirdi@gmail.com>
>>> wrote:
>>>
>>>> Use unlang
>>>> Pada tanggal 13 Des 2015 01.21, "Muhammad Usman" <
>> muhd.usman87@gmail.com>
>>>> menulis:
>>>>
>>>>> Hi,
>>>>> I have configured successfully the rlm_sqlcounter module and set the
>>>>> "reset" attribute to daily and its working properly, but I was
>> wondering
>>>> if
>>>>> it is possible to have this attribute dynamic for each user, based on
>> SQL
>>>>> query, meaning rather than defining a static value in configuration
>> file,
>>>>> is it possible to define a SQL query that runs each time and gets the
>>>> value
>>>>> from database. Thanks
>>>>> -
>>>>> List info/subscribe/unsubscribe? See
>>>>> http://www.freeradius.org/list/users.html
>>>> -
>>>> List info/subscribe/unsubscribe? See
>>>> http://www.freeradius.org/list/users.html
>>> -
>>> List info/subscribe/unsubscribe? See
>> http://www.freeradius.org/list/users.html
>> -
>> List info/subscribe/unsubscribe? See
>> http://www.freeradius.org/list/users.html
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Thanks a lot. Now I get the idea about how to achieve this functionality,
would you please also help me in ""mysql query get attribute for user""
this part as well. I have the {sql-user-name} , now how can I find the
group of that user in the default file
How can I check for user group based on the user-name in the default file,
syntax etc?
On Sun, Dec 13, 2015 at 10:34 AM, Anirudh Malhotra <amalhotra.sp-dl@nkn.in>
wrote:
> Finally, i understand your question now. Or maybe i think i do.
>
> Ok so in the authorize section use unlang as johan said use an attribute
> in radcheck which has value as "reset" or "never" whichever you want.
>
> If("mysql query get attribute for user" == daily)
> {
> Dailyresetcounter
> }
> If("mysql query get attribute for user" == never)
> {
> Neverresetcounter
> }
>
> Hope this finally answers your question.
>
> BR,
> Anirudh Malhotra
> NKN
>
> Sent from a handheld device, Sorry for typos.
>
> > On 13-Dec-2015, at 10:48, Muhammad Usman <muhd.usman87@gmail.com> wrote:
> >
> > I have already changed the query according to this wiki page, but now i
> > want to keep the reset paramter as dynamic based on group.
> >
> > sqlcounter dailycounter {
> > counter-name = 'Daily-Session-Time'
> > check-name = 'Max-Daily-Session'
> > sql_module_instance = 'sql'
> > key = 'User-Name'
> > reset = daily (rather defining it one time, I want it to dynamic,
> > may be an SQL query)
> > query = "SELECT SUM(AcctSessionTime - GREATEST((%b -
> > UNIX_TIMESTAMP(AcctStartTime)), 0)) FROM radacct WHERE
> > UserName='%{${key}}' AND UNIX_TIMESTAMP(AcctStartTime) +
> > AcctSessionTime > '%b'"
> > }
> >
> >
> > On Sun, Dec 13, 2015 at 10:01 AM, Anirudh Malhotra <
> amalhotra.sp-dl@nkn.in>
> > wrote:
> >
> >> Did you try changing the query in dailycounter?
> >> http://wiki.freeradius.org/modules/Rlm_sqlcounter
> >>
> >> Follow the link use another sql query instead of %b, to select the time
> >> you want to select for the user.
> >> BR,
> >> Anirudh Malhotra
> >> NKN
> >>
> >> Sent from a handheld device, Sorry for typos.
> >>
> >>> On 13-Dec-2015, at 10:18, Muhammad Usman <muhd.usman87@gmail.com>
> wrote:
> >>>
> >>> Thanks for your replies. Can you please elaborate your answers.
> >>>
> >>> I want FreeRadius to get this value from database (stored different
> >> values
> >>> for different users) at runtime.
> >>> How can i achieve different reset values for different users?
> >>>
> >>> On Sun, Dec 13, 2015 at 7:31 AM, johan firdianto <johanfirdi@gmail.com
> >
> >>> wrote:
> >>>
> >>>> Use unlang
> >>>> Pada tanggal 13 Des 2015 01.21, "Muhammad Usman" <
> >> muhd.usman87@gmail.com>
> >>>> menulis:
> >>>>
> >>>>> Hi,
> >>>>> I have configured successfully the rlm_sqlcounter module and set the
> >>>>> "reset" attribute to daily and its working properly, but I was
> >> wondering
> >>>> if
> >>>>> it is possible to have this attribute dynamic for each user, based on
> >> SQL
> >>>>> query, meaning rather than defining a static value in configuration
> >> file,
> >>>>> is it possible to define a SQL query that runs each time and gets the
> >>>> value
> >>>>> from database. Thanks
> >>>>> -
> >>>>> List info/subscribe/unsubscribe? See
> >>>>> http://www.freeradius.org/list/users.html
> >>>> -
> >>>> List info/subscribe/unsubscribe? See
> >>>> http://www.freeradius.org/list/users.html
> >>> -
> >>> List info/subscribe/unsubscribe? See
> >> http://www.freeradius.org/list/users.html
> >> -
> >> List info/subscribe/unsubscribe? See
> >> http://www.freeradius.org/list/users.html
> > -
> > List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
> -
> List info/subscribe/unsubscribe? See
> http://www.freeradius.org/list/users.html
>
participants (3)
-
Anirudh Malhotra -
johan firdianto -
Muhammad Usman