RE: (PM) Radius Log Parser?

Jeremy Malli (jeremy@Vcn.Com)
Mon, 1 Feb 1999 12:51:05 -0700

Here's a perl script I downloaded from somewhere and modified so that it
will display when the user logged in, how long the user was on and what IP
Address they had been assigned for that session:

#!/usr/bin/perl5
##
# 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
$testuser = sprintf("%-8s", $ARGV[0]);

# Open the file specified on the command line
open(IN, $ARGV[1]) ||
die "Could not open file $ARGV[1]\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

print("Activity log for user $testuser\n");
print(" Date Logout Username Minutes Address\n");
print("--------------------------------------------\n");

while (<IN>) {
chop;
if (!length($_)) {
if ($end_record) {
if ($username =~ $testuser) {
printf("%-8.8s %-8.8s %-8.8s %-7.7s %-15s\n",
$date, $daytime, $username, $time,
$address);
}
}
$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 (/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;
}

if (/Framed-IP-Address/) {
s/Framed-IP-Address = //;
s/\s+//g;
$address = $_ ;
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"; }
}

> -----Original Message-----
> From: owner-portmaster-users@livingston.com
> [mailto:owner-portmaster-users@livingston.com]On Behalf Of John
> Gonzalez/netMDC admin
> Sent: Monday, February 01, 1999 12:36 PM
> To: portmaster-users@livingston.com
> Subject: (PM) Radius Log Parser?
>
>
> I'm looking for a radius log parser that can give me a time when a user
> has been online. I need to parse it for security reasons to see who was on
> what IP address at what time :) Anybody know of such a beast?
>
> _ __ _____ __ _________
> ______________ /_______ ___ ____ /______ John Gonzalez/Net.Tech
> __ __ \ __ \ __/_ __ `__ \/ __ /_ ___/ MDC Computers/netMDC!
> _ / / / `__/ /_ / / / / / / /_/ / / /__ (505)437-7600/fax-437-3052
> /_/ /_/\___/\__/ /_/ /_/ /_/\__,_/ \___/ http://www.netmdc.com
> [---------------------------------------------[system info]-----------]
> 12:35pm up 113 days, 16:14, 4 users, load average: 0.07, 0.12, 0.09
>
> -
> To unsubscribe, email 'majordomo@livingston.com' with
> 'unsubscribe portmaster-users' in the body of the message.
> Searchable list archive: <URL:http://www.livingston.com/Tech/archive/>
>

-
To unsubscribe, email 'majordomo@livingston.com' with
'unsubscribe portmaster-users' in the body of the message.
Searchable list archive: <URL:http://www.livingston.com/Tech/archive/>