Ascend Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (ASCEND) Radius accounting
On Mon, 15 Jun 1998, Glenn Howard wrote:
> Hi There,
>
> We are a single POP ISP using a Max4000 for dial up. We have are using
> radius for both authentification as well as accounting. Up to this
> point, we have not done much with the accounting side. What we would
> like to do is be able to check the accounting data for overtime hours,
> etc, as well as have a system where users can log into a web page and
> check how many hours that they have used.
>
> Is there a "standard" package that people use? Do most people import
> the detail file into an SQL database and use PHP?
>
Here's a parser I wrote that will create/update a dbm file and keep up
with a users online time... easily accessed with a cgi script to check the
users online time, and also usable to check the hours used in a month for
billing purposes... We run it once nightly on each days logs, and rotate
the db file at the end of the month... I've found it to be accurate on our
system... removes any duplicate logs it finds by keeping up with all the
semi-unique session-ids for the month... you may need to tweak it a bit
for your system.
+-----------------------------------------------------------------+
| Kevin Smith x Computer Cafe System Administrator |
| bladez@cafes.net x ksmith@poconos.net x cosc0073@mtsu.edu |
| "Once, I was a mudflap... on a truck" |
+-----------------------------------------------------------------+
------ Cut Here ------
#!/usr/local/bin/perl
##############################################################################
# radparser.pl <bladez@cafes.net> #
##############################################################################
# #
# COPYRIGHT NOTICE #
# Copyright 1998 Kevin D. Smith. All Rights Reserved. #
# #
# radparser.pl may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Kevin D. Smith from any liability that might #
# arise from it's use. #
# #
##############################################################################
# Ensure there is a file to parse
my $detail_file = shift;
die "USAGE: radparser.pl <detail_file>\n" unless $detail_file;
my $path_to_db="/etc/usage/";
my $usage_db="usage";
my $log_db="id";
# Open the dbm file for log entries and session-id logging
dbmopen(%USAGE,"$path_to_db$usage_db",0664) or die "Error opening usage db file: $!\n";
dbmopen(%LOG,"$path_to_db$log_db",0664) or die "Error opening session-id db file: $!\n";
open(IN,"<$detail_file") or die "Error opening $detail_file\n";
# Init local variables
my $line="";
my $login="";
my $time="";
my $id="";
my $status="";
my $crap="";
my $temp="";
# Until the end of the file
while(<IN>) {
# Strip the eol
chop;
# copy over to our working variable
$line=$_;
# Repeat until the end of the current record
# (each record ends with a blank line)
while($line) {
# Grab a new line (the first line is never needed.. just a timestamp)
$line=<IN>;
# strip the eol
chop($line);
# check for usable values
if($line=~/User-Name/) {
($crap,$login,$crap)=split(/\"/,$line);
} elsif ($line=~/Acct-Status-Type/) {
($crap,$status)=split(/=/,$line);
$status=~s/\ //g;
} elsif ($line=~/Acct-Session-Id/) {
($crap,$id,$crap)=split(/\"/,$line);
} elsif ($line=~/Acct-Session-Time/) {
($crap,$time)=split(/=/,$line);
$time=~s/\ //g;
}
}
# Check if the current record is a stop record (and all values
# that are needed were grabbed)
if(($status=~/Stop/) and ($login) and ($id) and ($time)) {
# Make sure this is not a duplicate session-id
$temp=$LOG{$id};
if($temp) {
} else {
# Otherwise, log the session-id, and add the time
$LOG{$id}=$login;
$USAGE{$login}=$USAGE{$login}+$time;
}
}
}
# Close the radius detail file, and the log dbms....
close(IN);
dbmclose(%LOG);
dbmclose(%USAGE);
------ Cut Here ------
++ Ascend Users Mailing List ++
To unsubscribe: send unsubscribe to ascend-users-request@bungi.com
To get FAQ'd: <http://www.nealis.net/ascend/faq>
References: