On Tue, 11 Jun 2002, Kenneth Lee wrote:
>
> I am using counter module, any method/command I can use so that the time
> quota left can be checked?
>
> Thanks a lot!
>
> Kenneth
No not really. If you are using sql accounting though you could just use the
dialup_admin interface which will show you the remaining time.
I am also attaching a small perl script to read the counter files and find
information for users.
--
Kostas Kalevras Network Operations Center
[EMAIL PROTECTED] National Technical University of Athens, Greece
Work Phone: +30 10 7721861
'Go back to the shadow' Gandalf
#!/usr/local/bin/perl5.00503
use GDBM_File ;
if(($ARGV[0] eq "-h") or ($ARGV[0] eq "--help")){
print "Usage: rgdbm <username>\t\t(show user)\n";
print " rgdbm\t\t\t(show all users)\n";
exit;
}
if($ARGV[0]){
$user=$ARGV[0];
}
$day="/users-data/local/radiusd/var/db.day";
$week="/users-data/local/radiusd/var/db.week";
tie(%daily, 'GDBM_File', $day, &GDBM_READER,0600) or die("can't tie gdbm file:
$day\n");
tie(%weekly, 'GDBM_File', $week, &GDBM_READER,0600) or die("can't tie gdbm file:
$week\n");
if($user && ($user ne "html")) {
$d=unpack("i",$daily{$user});
$w=unpack("i",$weekly{$user});
unless($d){
$d="-";
}
unless($w){
$w="-";
}
if($ARGV[1] eq "html"){
print"<tr><td>$user</td><td>$d</td><td>$w</td></tr>\n";
}else{
print"$user:\t$d\t$w\n";
}
} elsif($user eq "html"){
while(($key,$val)= each %weekly){
$d=unpack("i",$daily{$key});
$w=unpack("i",$weekly{$key});
unless($d){
$d="-";
}
print"<tr><td>$key</td><td>$d</td><td>$w</td></tr>";
}
} else {
while(($key,$val)= each %daily){
$time=unpack("i",$val);
print "Day:\t$key:\t$time\n";
}
print "\n\n";
while(($key,$val)= each %weekly){
$time=unpack("i",$val);
print "Week:\t$key:\t$time\n";
}
}
untie(%daily) or die("can't untie gdbm file\n");
untie(%weekly) or die("can't untie gdbm file\n");