Ascend Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(ASCEND) radius detail files.
Here you go Andy,
Slightly modified version, it only requires the name and/or location of
the detail file, it then throws the output to STDOUT, which can be piped
into a new condensed version.
----------------Begin Script userlog5.pl --------------------------
#!/usr/local/bin/perl
##
# userlog - this program prints a log of a user's activity.
#
# Usage: userlog username detailfile
# where username = the login of the user in question
# detailfile = the name of a RADIUS detail file
#
# Copyright (C) 1995
# -Dave Andersen <angio@aros.net>
#
# Modified from Dave's "Lineparser" to work with 1 user
# 1/1/96 - Joe Hartley <jh@brainiac.com>
##
# set the user to look for from the command line
# Open the file specified on the command line
open(IN, $ARGV[0]) ||
die "Could not open file $ARGV[0]\n";
$begin_record = 1;
$end_record = 0;
# Variables
# $date - 09/11/75 format
# $daytime - hh:mm:ss format of _logout_ time
# $username
# $time - time online
while (<IN>) {
chop;
if (!length($_)) {
if ($end_record) {
if (1) {
printf("%-20.20s %-7.7s %-8.8s %-8.8s %-8.8s
%-8.8s %-8.8s\n",
$username, $time, $date, $daytime,
$port, $inoctet, $outoctet);
}
}
$end_record = 0;
$begin_record = 1;
next;
}
if ($begin_record && /^[a-zA-Z]/) {
($wday, $month, $mday, $daytime, $year) = split;
$month = &convert_month($month);
$year =~ s/19//;
$date = sprintf("%2.2d/%2.2d/%2.2d",
$month, $mday, $year);
$begin_record = 0;
$end_record = 1;
next;
}
if ($begin_record) {
next;
}
if (/User-Name/) {
s/[^\"]*"([^\"]*).*/$1/;
s/\s+//g;
$username = sprintf("%-8s", $_);
next;
}
if (/Client-Port-Id/) {
s/Client-Port-Id = //;
s/\s+//g;
$port = $_;
next;
}
if (/Acct-Input-Octets/) {
s/Acct-Input-Octets = //;
s/\s+//g;
$inoctet = $_;
next;
}
if (/Acct-Output-Octets/) {
s/Acct-Output-Octets = //;
s/\s+//g;
$outoctet = $_;
next;
}
if (/Acct-Status-Type/) {
if (!/Stop/) {
$begin_record = $end_record = 0;
next;
}
}
if (/Acct-Session-Time/) {
s/Acct-Session-Time = //;
s/\s+//g;
$time = $_ / 60;
next;
}
}
sub convert_month {
local($_) = $_[0];
if ($_ eq "Jan") { "01"; }
elsif ($_ eq "Feb") { "02"; }
elsif ($_ eq "Mar") { "03"; }
elsif ($_ eq "Apr") { "04"; }
elsif ($_ eq "May") { "05"; }
elsif ($_ eq "Jun") { "06"; }
elsif ($_ eq "Jul") { "07"; }
elsif ($_ eq "Aug") { "08"; }
elsif ($_ eq "Sep") { "09"; }
elsif ($_ eq "Oct") { "10"; }
elsif ($_ eq "Nov") { "11"; }
elsif ($_ eq "Dec") { "12"; }
else { "-1"; }
}
++ Ascend Users Mailing List ++
To unsubscribe: send unsubscribe to ascend-users-request@bungi.com
To get FAQ'd: <http://www.nealis.net/ascend/faq>