| 1 |
#!/usr/local/bin/perl |
| 2 |
|
| 3 |
# Report Quota |
| 4 |
# |
| 5 |
# Please keep my name associated with this program. If you add features to it, |
| 6 |
# please drop me a copy. |
| 7 |
# |
| 8 |
# This is a little util I wrote to report users who have NO quotas. |
| 9 |
# use at your own risk as I could only test on a BSDI 2.1 machine |
| 10 |
# It does not modify any quotas, just reads each users quota... |
| 11 |
# And email you the results. |
| 12 |
# |
| 13 |
# Written by Jim Hribnak ([email protected]) Aug 28 1997 |
| 14 |
# |
| 15 |
|
| 16 |
use Quota; |
| 17 |
|
| 18 |
$mailprog = '/usr/sbin/sendmail'; # change path to sendmail |
| 19 |
$email = '[email protected]'; # put your email address here |
| 20 |
$from = '[email protected]'; # put root@yourdomain here |
| 21 |
$subject = "User Quota Report\n"; |
| 22 |
$dev1= "/"; #filesystem with quota |
| 23 |
$dev2="/usr"; #filesystem with quota |
| 24 |
$dev3="/bbsusers"; #filesystem with quota |
| 25 |
&Email; |
| 26 |
|
| 27 |
# |
| 28 |
# uncomment format if you wish to use this header |
| 29 |
# |
| 30 |
|
| 31 |
#format STDOUT_TOP = |
| 32 |
#Quota's for @<<<<<<<<<<<<<<<< UID[@>>>>>>] |
| 33 |
#$user, $uid |
| 34 |
# Blocks Quota Quota |
| 35 |
#Filesystem Used Limit |
| 36 |
#---------------------------------------------------------------------------- |
| 37 |
#. |
| 38 |
|
| 39 |
format STDOUT = |
| 40 |
@<<<<<<<<< @###### @>>>>>> @>>>>>> Username: @<<<<<<<<<<<<<<<< |
| 41 |
$dev, $bc, $bs, $bh, $user |
| 42 |
. |
| 43 |
open (PW, "/etc/passwd") || die "Error opening password file"; |
| 44 |
while (<PW>) { |
| 45 |
($user,$passwd,$uid)=split(/:/); |
| 46 |
|
| 47 |
# |
| 48 |
# Change $dev to match a filesystem with Quotas |
| 49 |
# |
| 50 |
|
| 51 |
$dev=$dev1; |
| 52 |
|
| 53 |
($bc,$bs,$bh,$bt,$fc,$fs,$fh,$ft) = Quota::query($dev, $uid); |
| 54 |
if(defined($bc)) { |
| 55 |
|
| 56 |
&Sub1; |
| 57 |
|
| 58 |
write ; |
| 59 |
} |
| 60 |
else { |
| 61 |
warn Quota::strerr,"\n\n"; |
| 62 |
} |
| 63 |
# |
| 64 |
# Change $dev to match a filesystem with Quotas |
| 65 |
# |
| 66 |
|
| 67 |
$dev=$dev2; |
| 68 |
($bc,$bs,$bh,$bt,$fc,$fs,$fh,$ft) = Quota::query($dev, $uid); |
| 69 |
if(defined($bc)) { |
| 70 |
&Sub1; |
| 71 |
write; |
| 72 |
} |
| 73 |
else { |
| 74 |
warn Quota::strerr,"\n\n"; |
| 75 |
} |
| 76 |
# |
| 77 |
# Change $dev to match a filesystem with Quotas |
| 78 |
# |
| 79 |
$dev=$dev3; |
| 80 |
($bc,$bs,$bh,$bt,$fc,$fs,$fh,$ft) = Quota::query($dev, $uid); |
| 81 |
if(defined($bc)) { |
| 82 |
&Sub1; |
| 83 |
write; |
| 84 |
print "----------------------------------------------------------------------------"; |
| 85 |
print "\n"; |
| 86 |
} |
| 87 |
else { |
| 88 |
warn Quota::strerr,"\n\n"; |
| 89 |
} |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
close(MAIL); |
| 94 |
exit; |
| 95 |
|
| 96 |
sub Sub1 |
| 97 |
{ |
| 98 |
if (($bh eq "0") && ($bs eq "0")) { |
| 99 |
$bh = "None"; |
| 100 |
$bs = "None"; |
| 101 |
print MAIL "$user does not have a quota on $dev\n" |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
sub Email |
| 106 |
{ |
| 107 |
open(MAIL,"|$mailprog -t"); # open accessto Sendmail |
| 108 |
print MAIL "To: $email\n"; |
| 109 |
print MAIL "From: $from\n"; |
| 110 |
print MAIL "Subject: $subject \n\n"; |
| 111 |
print MAIL "\n"; |
| 112 |
} |
| 113 |
|