Hi Pau | list,

I had that in the back of my mind, so i finally got a chance to do it, i
tested it and works.

Hope you all find it usefull. Using it in something like :

for i in ´cat /etc/passwd | cut -d¨:¨ -f1
do; quotacheck.pl $i; done

in your crontab looks pretty good...

Anyhow, make changes as you need, and let me know any extra functionality
you add ! :)

Regards,




#!/usr/bin/perl

#
# quotacheck.pl
# Urivan Saaib <[EMAIL PROTECTED]>
#
# Usage: quotacheck.pl username
# Returns: Email with message of current user quota status.
#
# Distribution License : GPL
#

if (! $ARGV[0] )
{ print "Usage: quotacheck.pl username \n"; exit; }


$ADMIN="admin";
$TMP_FILE="/tmp/.quota_$ARGV[0]";

open (EXEC,"|quotastats $ARGV[0] | grep : | cut -d\":\" -f2 | \
              cut -d\" \" -f2 > $TMP_FILE") || 
        die "Error reading quotas.\n";
close (EXEC);

open (QUOTA,"$TMP_FILE") || die "Unable to load quota file.\n";
$quotaTOP = <QUOTA>;
$quotaUSE = <QUOTA>;
close (QUOTA);

$quotaTOP =~ chop $quotaTOP; $quotaTOP =~ chop $quotaTOP;
$quotaUSE =~ chop $quotaUSE; $quotaUSE =~ chop $quotaUSE;

#print "quotaTOP=$quotaTOP, quotaUSE=$quotaUSE.\n";
open (MAIL, "| sendmail -t") || die "Unable to send email.\n";
print MAIL "To: $ADMIN\nSubject: User Quota Report.\n\n";

if ($quotaTOP > 0 )
{
    if ($quotaUSE == $quotaTOP)
    { print MAIL "User $ARGV[0] has reached his disk quota.\n"; }
    if ($quotaUSE < $quotaTOP)
    { print MAIL "User $ARGV[0] has ".($quotaTOP-$quotaUSE)."K available.\n"; }
}

close (MAIL);



---Reply to mail from Pau Marshall about quota management script?

> Hi,
> 
> Well, I got quotas setup last week, and I can confirm they work as their 
> supposed to. Maybe a little too good. Unfortunately, I was the guinea pig. 
> I exceeded my quota yesterday, and as a result missed a day's worth of 
> email. Live and learn. Does anyone have a script for checking quotas on a 
> regular basis and notifying users? If not, I'll work on it and make it 
> available.
> 
> Take care,
> 
> Paul
> 

---End reply

_______________________________________________________
Urivan Saaib
Presidente
CiberNET Mexico
Email: [EMAIL PROTECTED]
Tel: (6) 175.71.95
Cel: (6) 170.40.88



Reply via email to