Is there way to convert output octets and input octets to KB

Alan DeKok aland at deployingradius.com
Sun Jun 16 15:01:03 CEST 2019


On Jun 16, 2019, at 7:56 AM, Mustafa Nassir <mustafa.n.gaid at gmail.com> wrote:
> 
> ok , i need to limit total octets for users so i add sqlcounter :
> 
> sqlcounter total_limit{
>            counter_name = 'Max-Total-Bandwidth'
>            check_name = 'Total-Bandwidth'
>            sql_module_instance = sql
>            key = 'User-Name'
>            dialect = mysql
>            reset = never
>  query = "SELECT SUM(acctinputoctets) + SUM(acctoutputoctets) FROM radacct
> WHERE UserName='%{${key}}'"
> }
> 
> its work fine for 4 GB but if i need to limit it to 10 GB or more the
> server give another value not what i add some examble :

  You shouldn't need to do that.  The sqlcounter module has supported 64-bit counters since 3.0.4, in 2014.

> insert into radcheck (username,attribute,op,value) values ("sw392","
> Cleartext-Password",":=","sw");
> insert into radcheck (username,attribute,op,value) values ("sw392","
> Monthly-Bandwidth ",":="," 10737418240");
> 
> when i do radtest sw392 sw 127.0.0.1 10 XXXXX
> 
> i get
> 
> User-Name = "sw392"
>        User-Password = "sw"
>        NAS-IP-Address = 127.0.0.1
>        NAS-Port = 10
>        Message-Authenticator = 0x00
>        Cleartext-Password = "sw"
> Received Access-Accept Id 61 from 127.0.0.1:1812 to 0.0.0.0:0 length 26
>        Session-Timeout = 2147483648
> 
> the session-timeout is my Monthly-Bandwidth attribute as you see i get
> different value from what i insert in sql

  Yes, because Session-Timeout is a 32-bit integer.

  If you're doing to put values larger than 4G into a 32-bit integer, it won't work.

  If you're going to limit bandwidth by putting bandwidth values into Session-Timeout, it won't work.

  The sqlcounter module supports 64-bit values just fine.   One issue, though is that the module is made to count *time* not *bandwidth*.  All of the documentation and examples show it counting time.  And when you test it, you see the module setting Session-Timeout.  *Not* any bandwidth limitation.

  So again, what are you trying to do?  You've posted a configuration here, but you're not really describing the problem.

  Are you trying to limit bandwidth that the users can download?  Did you *READ* my previous response which explained the problem with that?

  Alan DeKok.




More information about the Freeradius-Users mailing list