Usage monitoring Perl script

amanda edades amanda.edades at gmail.com
Sat Dec 1 01:24:53 CET 2012


Hello,

I am new to FreeRADIUS and am trying to implement QoS policing using
FreeRADIUS, where the RADIUS server assigns users QoS policies by usergroup
membership.  The server monitors usage, and throttles a user's bandwidth by
originating a CoA assigning the throttled group if he exceeds the data cap
defined for his group.

I have data usage being calculated by a Perl script - I define a group's
data cap in the radgroupcheck table, and reference it using

$RAD_CHECK{'Data-Cap'}

I am able to run the script correctly in the authorize section, but when
calling it from the accounting section, it does not grab the value, and
just designates the cap as 0, causing all future comparisons to conclude
the user is over the cap.

It appears that in the accounting section, $RAD_CHECK does not reference
the radgroupcheck table.  I have worked around this by hardcoding data caps
for usergroups in the Perl script, but I would like to store these caps in
a SQL table so they can easily be modified in the future without having to
touch the FreeRADIUS config.

How do I reference radgroupcheck from the accounting section of my Perl
script to pull these values?

Here is a portion of my workaround code:

sub accounting {
        my $Group1_cap = 5368709120;
        # define other caps here: $Group2_cap, $Group3_cap, etc.
        my $cap = 0;

        if ($RAD_CHECK{'Group-Name'} = "Group1") {
                $cap = $Group1_cap;
        }

        # *I would like to replace $cap with $RAD_CHECK{'Data-Cap'}, but
this does not pull values defined in radgroupcheck*
        $RAD_CHECK{'Avail-Bytes'} = $cap - $RAD_CHECK{'Used-Bytes'};

        if ($RAD_CHECK{'Avail-Bytes'} < 0) {
                # usage cap exceeded
                return RLM_MODULE_NOOP;
        }

        return RLM_MODULE_UPDATED;
}

Thank you in advance,

Amanda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20121130/5fb648ab/attachment.html>


More information about the Freeradius-Users mailing list