If you can post an example of what the log file looks like and tell us how you need to group the data we can come up with something. Tracy Dryden
tracy@bydisn.com
You're absolutely right - should have given more info. Office was a bit hectic yesterday :?)
The log file is a mixture of logs from a Cistron RADIUS daemon, and an Ascend RADIUS daemon. For each user connection, there should be a start record and a stop record.
Apologies for the length of this post. Also, I have masked client-specific data.
Each Stop/Start record is separated by a blank line. I think the order of the fields can change.
The information I want for each client is the User-name, Remote IP address, Dialling number and Incoming ISDN number . That is {User-Name, Framed-IP-Address, Called-Station-Id, Calling-Station-Id respectively for Cistron } and {User-Name, Framed-Address, Client-Port-DNIS, Caller-Id respectively for Ascend}. All this information is in the Stop records - some is missing from the Start recrods. So I would think I can ignore the latter.
It seems fairly easy to split each line into fields 1, 2 and 3, and then label field 3 as IP_address, etc. My main difficulty is knowing how to group each block - i.e. keep records separate.
Are the records actually broken up into multiple lines like that, or did you just format them that way to make them easier to read? It would be a lot easier to handle if they were all one line.
Tracy Dryden
tracy@bydisn.com
Would this give you a start? (include your data file after the __END__ token, or change the <DATA>'s to <>'s and specify your file on the command line)
[tt]
use strict;
my $type;
while(<DATA>){
# find the first "start record:" type line
next until /record:/;
chomp($type = $_);
print "\n$type";
$_=<DATA>; # throw the following blank line
# then process the file until we get another blank line
while(<DATA>){
chomp;
# if this is a blank line
last if /^\s*$/;
# ok then - we've got data to play with
while (/^\s/){
s/^\s+//g;
}
if($type =~ /Cistron/){
# User-Name, Framed-IP-Address, Called-Station-Id, Calling-Station-Id
if(/User-Name/){
print " $_";
} elsif (/Framed-IP-Address/){
print " $_";
} elsif (/Called-Station-Id/){
print " $_";
} elsif (/Calling-Station-Id/){
print " $_";
}
} elsif ($type =~ /Ascend/){
# User-Name, Framed-Address, Client-Port-DNIS, Caller-Id
if(/User-Name/){
print " $_";
} elsif (/Framed-Address/){
print " $_";
} elsif (/Client-Port-DNIS,/){
print " $_";
} elsif (/Caller-Id/){
print " $_";
}
}
}
}
__END__
[/tt]
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.