[RADIATOR] run perl hook after accounting start

Heikki Vatiainen hvn at open.com.au
Fri Mar 8 02:35:32 CST 2013


On 03/06/2013 03:57 PM, Thomas Kurian wrote:

> 1. After receiving a accounting start packet , If (switched=false 
> ,type=Q and quotacounter> or = quotamax)
> The above values are to be compared with the current values of these 
> fields in a sql table called quotasubscribers (field names are 
> switched,type , quotacounter and quotamax).



> 2. If the above conditions matches, then a perl script is to be run . ( 
> Which type of hook is to be called when the scenario is "after an 
> accounting stack packet is received"?)

You could user PreProcessingHook or PostAuthHook in a Handler. The first
runs before the packet is processed, and e.g., before AcctSQLStatement
is run, and the second runs after AuthBy has done all its work.

> The following is my current radiator configuration (for reference with 
> the above) , kindly answer with respect to below and add required config 
> lines to the below config.

If PostAuthHook should do the work, the config would like this:


<Handler Request-Type = Accounting-Request>
  PreProcessingHook file:"/etc/radiator/createavpairs.pl"
  <AuthBy SQL>
    # ...
  </AuthBy>
  PostAuthHook file:"/etc/radiator/..."
</Handler>

Note: the order of parameters does not matter. Placing PostAuthHook
after the AuthBy clause is just to remind it runs *after* the AuthBy.
Likewise for PreProcessingHook which runs *before* the AuthBy.

If you want to use PreProcessingHook, you could move createavpairs to
e.g., ClientHook or just incorporate this code into your hook.

Thanks,
Heikki



> AcctPort 1813
> BindAddress 0.0.0.0
> 
> LogDir /var/log/radius
> DbDir /etc/radiator
> # Use a low trace level in production systems. Increase
> # it to 4 or 5 for debugging, or use the -trace flag to radiusd
> Trace 4
> 
> # You will probably want to add other Clients to suit your work site,
> # one for each NAS you want to work with
> 
> 
> <Client DEFAULT>
> Secret XXXX
> DupInterval 0
> </Client>
> 
> 
> <Client 10.50.1.4>
> Secret XXXX
> DupInterval 0
> NasType Cisco
> IgnoreAcctSignature
> </Client>
> 
> # Accept processing of other accounting requests of the genre stop
> 
> 
> <Handler Request-Type = Accounting-Request>
> PreProcessingHook file:"/etc/radiator/createavpairs.pl"
> <AuthBy SQL>
> 
> DBSource dbi:ODBC:IRONMAN
> DBUsername XXXXX
> DBAuth XXXX
> 
> 
> #AccountingStopsOnly
> AccountingTable ACCOUNTING
> AcctColumnDef USERNAME, User-Name
> AcctColumnDef ACCTSTATUSTYPE,Acct-Status-Type
> AcctColumnDef FRAMEDIPADDRESS,Framed-IP-Address
> AcctColumnDef ACCTINPUTOCTETS,Acct-Input-Octets,integer
> AcctColumnDef ACCTOUTPUTOCTETS,Acct-Output-Octets,integer
> AcctColumnDef TIME_STAMP,Event-Timestamp,integer-date
> AcctColumnDef ACCTSESSIONTIME,Acct-Session-Time,integer
> AcctColumnDef ACCTDELAYTIME,Acct-Delay-Time,integer
> AcctColumnDef ACCTSESSIONID,Acct-Session-Id
> AcctColumnDef ACCTTERMINATECAUSE,Acct-Terminate-Cause
> AcctColumnDef NASIDENTIFIER,NAS-Identifier
> AcctColumnDef NASPORT,NAS-Port,integer
> AcctColumnDef PARENTSESSIONID,parent-session-id
> 
> AcctSQLStatement update quotasubscribers set monthlycounter = 
> monthlycounter + 0%{Acct-Output-Octets}, totalcounter = totalcounter + 
> 0%{Acct-Output-Octets}, timestamp = %{Event-Timestamp} \
> where username='%n' \
> And Type = 'Q'
> 
> 
> 
> </AuthBy>
> #Log accounting to a detail file
> AcctLogFileName %L/detail
> 
> 
> </Handler>
> 
> 
> 
> 
> <Handler Request-Type=Disconnect-Request>
> <AuthBy RADIUS>
> 
> <Host 10.50.1.4>
> Secret XXXX
> </Host>
> </AuthBy>
> </Handler>
> 


-- 
Heikki Vatiainen <hvn at open.com.au>

Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS,
NetWare etc.


More information about the radiator mailing list