Date: Wed, 19 Jun 2002 11:02:09 -0400 From: "David S. Jackson" <deepbsd@earthlink.net> To: Steven Lake <raiden@shell.core.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Determining # of mail's per user Message-ID: <20020619150205.GC6184@scee.dsj.net> In-Reply-To: <Pine.GSO.4.44L0.0206161529060.22536-100000@shell.core.com> References: <Pine.GSO.4.44L0.0206161529060.22536-100000@shell.core.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jun 16, 2002 at 03:33:51PM -0500 Steven Lake <raiden@shell.core.com> wrote:
> What's the easiest way to determin how many emails a given user
> has on the mail server?
I understand you already found a solution, but you might have a look at
from. Not sure if it's in the standard installation or the ports tree.
You might also look at newmail, which I think is in the ports tree.
> I need to generate a list of how many emails and
> how much space each mail file is taking up per user. ocd /var/mail;
Something like this should help...
#!/usr/local/bin/bash
maildir=/var/mail # or wherever yours is
maxsize=1234 # decide on acceptable mailbox size...
maxnum=100 # maxnumber of emails allowed
message="Your email mailbox size has exceeded $maxsize.
Your number of emails has exceeded $maxnum. Please
delete emails until your mailbox size is less than $maxsize."
domain="yourdomain.net"
cd $maildir
for i in *; do
temp=/tmp/mailmessage.$i.txt
size=`ls -sk $i | cut -d' ' -f1`
num=`grep 'From:' $i | wc -l`
if [ $size -gt $maxsize -o $num -gt $maxnum ]; then
cat >> $temp <<EOF
You have $num emails stored on the mail server
that take up $size kilobytes of space.
${message}
Sincerely,
${USER}, Your friendly local SysAdmin
EOF
mail -s "Your mailbox size is $size" $i@$domain < $message
fi
done
> I'm having a space
> problem on one of the mail servers and I want to create a simple formatted
> output that I can put into a spreadsheet program and view who are the
> biggest offenders. I could do it by mail file sizes, but to the less
> experienced telling them they have 150 megs of email on the server doesn't
> make as big an impact as saying they have 25,000 emails just sitting there
> idle and taking up space. Plus it gives me some tangeble numbers to put
> in the records.
forspreadsheet=/tmp/spreadsheet.$$
if [ -e $forspreadsheet -a -w $spreadsheet ]; then
rm $forspreadsheet
fi
cd $maildir
for i in *; do
size=`du $i | cut -d' ' -f1`
num=`grep 'From:' $i | wc -l`
line=`echo -e $i\t$num\t$size\n`
cat $line >> $forspreadsheet
done
> There's also the fact that some users recieve large files on a
> regular basis but are good about checking their mail and cleaning it out
> regularly, so I don't want to punish them while punishing the true
> offenders. Anyone got any good suggestions for me?
The first script above checks for $size being greater than $maxsize
before sending out an email.
--
David S. Jackson dsj@dsj.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I have a map of the United States. It's actual size.
I spent last summer folding it. People ask me where
I live, and I say, "E6". -- Steven Wright
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020619150205.GC6184>
