Re: Accounting scripts for RADIUS detail file

Mury Andrew Johnson (mury@main.goldengate.net)
Tue, 17 Oct 1995 00:14:03 -0500 (CDT)

On Sat, 14 Oct 1995, Jim Covington wrote:

> I am looking for a script that will give me a client-id and account time in
> seconds or hours from the detail file created by RADIUS. I want to be able
> to dump this info into some database or accounting program and bill
> customers for time as well as unlimited access.

A lot of people have been asking for something like this. I do have a
better solution, but unfortunately I can't share it with you yet.
However the following will get you started with awk scripts. Get the
O'Reilly book on sed and awk.

The reason I'm posting this here, is because I received about 30
responses that I didn't get a chance to reply to the last time I said
learn sed and awk, but also mentioned I would give people something to
get started with. And I have since lost all the responses, so here's
your chance...

This is a total hack job, but it should get you
started. Maybe you already have something better than this, if so share
it please, there are a lot of people who would like to see it.

put this line in your alias file:

report awk -f rad.awk1 /usr/adm/radacct/name of your portmaster directory/detail | grep Session | awk -f rad.awk22|sort|grep Oct| awk -f rad.awk33|grep Total|more

For whatever month you want change the grep part to the abbreveiation for
that month.

Below this line is the rad.awk1 file referred to in the alias line.
------------------------------------------------------------------
BEGIN {FS = "\n"; RS = ""}

{print $3, $1, $7}
-------------------------------------------------------------------

Next is the rad.awk22 file...
-------------------------------------------------------------------
{print $3, $5, $6, $7, $11}
-------------------------------------------------------------------

And finally this is the rad.awk33 file
-------------------------------------------------------------------

$1 == LastName {
balance += $5
print "\t" $2, $3, $4, $5, balance/3600, "Hours"
}
$1 != LastName {
print name, "\tTotal Hours = ", "\t" balance/3600
balance = 0
name = $1
LastName = $1
print $1
balance = $5
print "\t" $2, $3, $4, $5, balance/3600 }
------------------------------------------------------------------

There are a milllion and one ways to customize this to fit your needs. I
don't expect you to understand this poor layout with no notes, so if you
have questions ask. If I have time, I will send you the better way,
please don't ask for it, or why I can't send it now.

______________________________________________________________________________
mury@goldengate.net Have GoldenGate Internet Services
(612) 574-2200 Office A Nice PO Box 32031
(612) 574-2444 Fax Day! Fridley, MN 55432
------------------------------------------------------------------------------