accounting scripts ?

Miguel mmiranda at 123.com.sv
Thu Oct 20 18:32:04 CEST 2005


Frank Bonnet wrote:

> Hello
>
> I'm searching for scripts that are able to parse the 
> radacct/xxx.xxx.xxx.xxx/detail-xxxxxxx file to perform
> some simple statistics ?
>
> Thanks
>
> - List info/subscribe/unsubscribe? See 
> http://www.freeradius.org/list/users.html
>
what do you mean with parsing?, i got this, i call it summarize.pl, just 
change the attributes that you want to extract, the result is a csv file,
the output is to your screen, so you have to redirecte it to a file, 
etc, with that csv file you can dump it to a db, or wharever. ej:

for standar output: 
# ./summarize.pl name_of_detail_file

for csv file: 
# ./summarize.pl name_of_detail_file > name_of_csv_file


### BEGIN ###

#!/usr/bin/perl
#


# define caracter de separacion para lineas
$/ = "\n\n";

open(SUM,$ARGV[0]) or die "No se encontro archivo detalle";

print "h323-call-origin,h323-call-type,out-intrfc-desc,h323-connect-time,";
print "Acct-Session-Time,h323-disconnect-time,h323-disconnect-cause,";
print "Cisco-NAS-Port,Calling-Station-Id,Called-Station-Id\n";

while (<SUM>){
    s/\t+//g;
    @campos = split(/\n/);
     
    foreach $c (@campos) {
        ($cpo, $vlr) = split(/ = /, $c);
        $vlr =~ s/^ |\"//g;
        #print $cpo,$vlr,"\n";
        if ($cpo eq "h323-call-origin") {$h323_call_origin = $vlr;}
        if ($cpo eq "h323-call-type")   {$h323_call_type = $vlr;}
        if ($cpo eq "Cisco-AVPair") {
            if ($vlr =~ /out-intrfc-desc/) {
                $out_intrfc_desc = (split("=",$vlr))[1];
            }
        }
        if ($cpo eq "h323-connect-time")     {$h323_connect_time = $vlr;}
        if ($cpo eq "Acct-Session-Time")     {$Acct_Session_Time = $vlr;}
        if ($cpo eq "h323-disconnect-time")  {$h323_disconnect_time = $vlr;}
        if ($cpo eq "h323-disconnect-cause") {$h323_disconnect_cause = 
$vlr;}
        if ($cpo eq "Cisco-NAS-Port")        {$Cisco_NAS_Port = $vlr;}
        if ($cpo eq "Calling-Station-Id")    {$Calling_Station_Id = $vlr;}
        if ($cpo eq "Called-Station-Id")     {$Called_Station_Id = 
$vlr;}                          
    }
    print 
"$h323_call_origin,$h323_call_type,$out_intrfc_desc,$h323_connect_time,";
    print 
"$Acct_Session_Time,$h323_disconnect_time,$h323_disconnect_cause,";
    print "$Cisco_NAS_Port,$Calling_Station_Id,$Called_Station_Id\n";
}
close SUM;

### END ###



More information about the Freeradius-Users mailing list