#!/usr/bin/perl

$path = "radius.log";
#$path = "/var/log/radius.log";

open(RADIUSLOG, "< $path") or die "Couldn't open $path for reading: $!\n";


while(<RADIUSLOG>){

	if (/^.*?\[(.*?)\].*?$/){

		if ($1 !~ /\w\/.*/){
			$users{$1}++;
			$total++;
		}else{
			$badlogins++;
		}
	}else{
		print "could not parse $_\n";
	}
}  


foreach $key (keys(%users)){
#	print ( "$key = $users{$key}\n" );
	$totalunique++;

}
print "total user logins     =     $total\n";
print "total bad logins      =     $badlogins\n";
print "total unique logins   =     $totalunique\n";
