-----------------------MAIN----------------------------------------
#!/bin/bash
echo "PM0"
pmline /var/adm/radacct/pm0.jeffnet.org/detail > /sbin/daily.log
echo "PM1"
pmline /var/adm/radacct/pm1.jeffnet.org/detail >> /sbin/daily.log
echo "PM2"
pmline /var/adm/radacct/pm2.jeffnet.org/detail >> /sbin/daily.log
echo "PM3"
pmline /var/adm/radacct/pm3.jeffnet.org/detail >> /sbin/daily.log
#
/sbin/daily.use
echo "making summary...."
/sbin/summarize < /sbin/today.log > /sbin/today.totals
echo "finding offenders..."
/sbin/get.offend
----------------------daily.use-----------------------------------
#!/usr/bin/perl
#
# find todays date in DD/MM/YY format, grep lines matching date
#
#
$date = `date`;
#print "$date";
@dates = split (' ', $date);
$day = $dates[2];
print "today is day number: $day \n";
exec("grep \"/$day/\" /sbin/daily.log > /sbin/today.log");
------------------------get.offend---------------------------------------
#!/usr/bin/perl
#
# get todays user info from /sbin/today.totals write usernames with
# over 8hrs of use to /sbin/locked.today
#
open (TODAY, "cat /sbin/today.totals |");
open (LOCKED, "> /sbin/locked.today");
while ($linex = <TODAY>) {
@fields = split(' ', $linex);
@ttime = split(':', $fields[4]);
if ($ttime[0] >= "08"){
print LOCKED "$fields[0] \n";
print "$fields[0] $fields[4] \n";
}
}
---------------------------resetem-------------------------------
#!/usr/bin/perl
#
# use pmcommand to reset ports with users listed in /sbin/locked.today
# do not reset users listed in /etc/exempt.users
#
$date = `date`;
$any = "no";
$pmcom = "/sbin/pmcommand";
open (LOG, "> /sbin/reset.log");
print LOG "Subject: Punishing offenders \n \n";
print LOG "The following users have exceeded thier daily limit, but keep \n";
print LOG "logging back in. \n $date \n";
open (PORTS, "pm0 |");
while ($linex = <PORTS>) {
@fields = split (' ', $linex);
# print "$fields[0] $fields[1] \n";
open (USERS, "cat /sbin/locked.today |");
while ($liney = <USERS>) {
# print "$liney \n";
open (EXEMPT, "cat /etc/exempt.users |");
while ($linez = <EXEMPT>) {
if ($linez =~ /$liney/) { $liney = "xxx"; }
}
if ($liney =~ /$fields[1]/) {
open (PMCOM, "|$pmcom pm0 password") || next ;
print PMCOM "reset $fields[0] \n";
$any = "yes";
print LOG "Reset $fields[0] $liney \n";
print PMCOM "exit \n";
close (PMCOM);
}
}
}
open (PORTS, "pm1 |");
while ($linex = <PORTS>) {
@fields = split (' ', $linex);
# print "$fields[0] $fields[1] \n";
open (USERS, "cat /sbin/locked.today |");
while ($liney = <USERS>) {
# print "$liney \n";
open (EXEMPT, "cat /etc/exempt.users |");
while ($linez = <EXEMPT>) {
if ($linez =~ /$liney/) { $liney = "xxx"; }
}
if ($liney =~ /$fields[1]/) {
open (PMCOM, "| $pmcom pm1 password") || next;
print PMCOM "reset $fields[0] \n";
$any = "yes";
print LOG "Reset $fields[0] $liney \n";
print PMCOM "exit \n";
close (PMCOM);
}
}
}
open (PORTS, "pm2 |");
while ($linex = <PORTS>) {
@fields = split (' ', $linex);
# print "$fields[0] $fields[1] \n";
open (USERS, "cat /sbin/locked.today |");
while ($liney = <USERS>) {
# print "$liney \n";
open (EXEMPT, "cat /etc/exempt.users |");
while ($linez = <EXEMPT>) {
if ($linez =~ /$liney/) { $liney = "xxx"; }
}
if ($liney =~ /$fields[1]/) {
open (PMCOM, "| $pmcom pm2 password") || next;
print PMCOM "reset $fields[0] \n";
$any = "yes";
print LOG "Reset $fields[0] $liney \n";
print PMCOM "exit \n";
close (PMCOM);
}
}
}
open (PORTS, "pm3 |");
while ($linex = <PORTS>) {
@fields = split (' ', $linex);
# print "$fields[0] $fields[1] \n";
open (USERS, "cat /sbin/locked.today |");
while ($liney = <USERS>) {
# print "$liney \n";
open (EXEMPT, "cat /etc/exempt.users |");
while ($linez = <EXEMPT>) {
if ($linez =~ /$liney/) { $liney = "xxx"; }
}
if ($liney =~ /$fields[1]/) {
open (PMCOM, "| $pmcom pm3 password") || next;
print PMCOM "reset $fields[0] \n";
$any = "yes";
print LOG "Reset $fields[0] $liney \n";
print PMCOM "exit \n";
close (PMCOM);
}
}
}
close (LOG);
if ($any eq "yes") {
exec ('sendmail support-dist < /sbin/reset.log');
}
-----------------------EOF-----------------------------------------
\\|// ^^^^^ )))(( %%%%% ,,,,,
(- -) (o o) (- o) (0-0) (* *)
+--ooO-(_)-Ooo--oo0-(_)-0oo--ooO-(_)-Ooo--oo0-(_)-0oo--ooO-(_)-Ooo--+
| NETWORK OPERATIONS CENTER |
| mailto:support@friendly.jeffnet.org Voice # 800-876-8797 |
| http://jeffnet.org/linuxisp 541-776-3283 |
| Mike Taylor - Network Services Manager |
+-------------------------------------------------------------------+