<div dir="ltr"><div> </div>
<div>Hey,</div>
<div> </div>
<div>I'm experimenting with some sqlcounter directives in radiusd.conf and chilli as the NAS.</div>
<div>I've defined the following sqlcounter stanza for a daily traffic limit:</div>
<div> </div>
<div class="de2">sqlcounter defined in radiusd.conf:</div>
<div class="de1">
<div class="de2">(the query was corrected as suggested by tnt on a previous thread on the list, correct me if I got it wrong please)</div></div>
<div class="de1"> </div>
<div class="de2"> sqlcounter counterChilliSpotMaxDailyOctets {</div>
<div class="de1"> counter-name = ChilliSpot-Max-Daily-Octets</div>
<div class="de2"> check-name = ChilliSpot-Max-Daily-Octets</div>
<div class="de1"> reply-name = ChilliSpot-Max-Total-Octets</div>
<div class="de2"> sqlmod-inst = sql</div>
<div class="de1"> key = User-Name</div>
<div class="de2"> reset = daily</div>
<div class="de1"> error-msg = "Sorry, your maximum traffic usage (download and upload) has exceed the provided limit"</div>
<div class="de2"> query = "SELECT (SUM(AcctInputOctets + AcctOutputOctets)) FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"</div>
<div class="de1"> }</div>
<div class="de2"> </div>
<div class="de2"> </div>
<div class="de2"> </div>
<div class="de2">In the authorization phase, I'm seeing the following in debug log:</div>
<blockquote style="MARGIN-RIGHT: 0px">
<div class="de2">rlm_sqlcounter: Entering module authorize code</div>
<div class="de2">sqlcounter_expand: 'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE UserName='%{User-Name}''</div>
<div class="de2">radius_xlat: 'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE UserName='tester1''</div>
<div class="de2">sqlcounter_expand: '%{sql:SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE UserName='tester1'}'</div>
<div class="de2">radius_xlat: Running registered xlat function of module sql for string 'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE UserName='tester1''</div>
<div class="de2">rlm_sql (sql): - sql_xlat</div>
<div class="de2">radius_xlat: 'tester1'</div>
<div class="de2">rlm_sql (sql): sql_set_user escaped user --> 'tester1'</div>
<div class="de2">radius_xlat: 'SELECT (SUM(AcctInputOctets)+SUM(AcctOutputOctets)) FROM radacct WHERE UserName='tester1''</div>
<div class="de2">rlm_sql (sql): Reserving sql socket id: 2</div>
<div class="de2">rlm_sql (sql): - sql_xlat finished</div>
<div class="de2">rlm_sql (sql): Released sql socket id: 2</div>
<div class="de2">radius_xlat: '24004370'</div>
<div class="de2">rlm_sqlcounter: (Check item - counter) is greater than zero</div>
<div class="de2">rlm_sqlcounter: Authorized user tester1, check_item=26214400, counter=24004370</div>
<div class="de2">rlm_sqlcounter: Sent Reply-Item for user tester1, Type=ChilliSpot-Max-Total-Octets, value=26239950</div>
<div class="de2"> modcall[authorize]: module "counterChilliSpotMaxDailyOctets" returns ok for request 0</div></blockquote>
<div class="de2">The entry in radcheck is as follows:</div>
<div class="de2"> </div>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<div class="de2">| 346 | tester1 | ChilliSpot-Max-Daily-Octets | := | 26214400 |</div></blockquote>
<div class="de2">What happens is that it seems the counter doesn't work as expected. When a user logs in, performs some traffic usage, logs out and logs in again,</div>
<div class="de2">the replied back attribute for chilli doesn't contain a value which is the remainder of the traffic usage, but something else.</div>
<div class="de2"> </div>
<div class="de2">According to the radius debug above, if check_item=26214400 and counter=24004370, how come value=26239950?</div>
<div class="de2">So I'm guessing I'm missing something but I'm too obsessed with the sqlcounter to notice it. (is the subtractation not a normal decimal action?)</div>
<div class="de2"> </div>
<div class="de2">The FreeRADIUS version used is 1.1.7</div>
<div> </div>
<div> </div>
<div> </div>
<div>Regards,</div>
<div>Liran.</div>
<div> </div></div>