|
|
Howdy folks,
here's my own solution to the problem I originally addressed and, I'm guessing, is troublesome for many of you as well. This script finds all mbox-files over 1.7Gb and sends a notice email to the owner of the mailfolder (and cc to admin, if you want).
I'm far from being a good shell scripter, but at least this is relatively universal and should work in most environments. Feel free to improve it!
1) run this command via cron at desired intervals
find /path/to/CommuniGate/ -name "*.mbox" -size +1700M -exec /path/to/mailbox_size_checker.sh {} \;
2) create the (bash) shell script 'mailbox_size_checker.sh'
### Change these variables to match your environment
ROOTDOMAIN='your_CGP_rootdomain.dom'; #enter your CGP root domain here
FILE='/path/to/cgp_mailbox_size_check.tmp'; # enter a path and name for the temporary workfile
EMAIL='/path/to/cgp_mailbox_size_checker_email.txt'; # enter a path and name for the temporary email file
WARNINGCC='admin@email.com' # enter the administrator's email if you wish to receive a copy of the warning emails
###
echo "$1" >"$FILE";
SIZE=`du -h "$1" | egrep -o '^[0-9]*\.[0-9]*'`;
MAILBOX=`egrep -o '([^\/]*)\.mbox$' "$FILE"`;
ACCOUNT=`egrep -o '([^\/]*)\.macnt' "$FILE" | egrep -o '^[^\.]*'`;
DOMAIN=`egrep -o 'Domains/[^\/]*\.[^\/]*' "$FILE" | egrep -o '[^\.]*\.[^\.]*'`;
echo "Hello,\n\n" >>"$EMAIL";
echo "Your mailfolder '$MAILBOX' size is currently $SIZE Gb. The maximum size of a single mailfolder in CommuniGate is 2.0 Gb. \n" >>"$EMAIL";
echo "Please empty this mailfolder before it reaches maximum size. Messages may be lost if the mailfolder size exceeds the limit.\n\n" >>"$EMAIL";
echo "This message was sent automatically." >>"$EMAIL";
if [ "$DOMAIN" != "" ];
then
/usr/sbin/CommuniGatePro/mail -s "ATTENTION! Mailfolder $MAILBOX size is near maximum" -c "$WARNINGCC" "$ACCOUNT@$DOMAIN" <"$EMAIL";
else
/usr/sbin/CommuniGatePro/mail -s "ATTENTION! Mailfolder $MAILBOX size is near maximum" -c "$WARNINGCC" "$ACCOUNT@$ROOTDOMAIN" <"$EMAIL";
fi
rm -f "$FILE";
rm -f "$EMAIL";
On 14.9.2011, at 11:50, Kirnauskis Postmaster wrote:
> Dana, looks kinda complicated to me. :)
>
> Why not just:
>
> find /path/to/CommuniGate/ -name "*.mbox" -size +1900M -exec du -h {} \;
>
> I'm thinking of developing this to strip the domain, account, and mailbox names from the file path (../CommuniGate/Accounts/<account>.macnt/<mailbox>.mbox for the main domain and ../CommuniGate/Domains/<domain>/<account>.macnt/<mailbox>.mbox for all other domains), making them variables and using them to send a warning email to the user.
>
> Accommodating this to mdirs, if necessary, should be a walk in the park.
>
>
> On 13.9.2011, at 23:12, dhazzard@yoursummit.com wrote:
>
>> Below is a python script I put together just to check mbox size and display them. You could probably do some work to make this work as you want.
>>
>>
>> ### start script ###
>> #!/usr/bin/python
>>
>> import os,glob
>>
>> def processDirectory ( args, dirname, filenames ):
>> #print 'Directory',dirname,'\n\n'
>>
>> for infile in glob.glob(os.path.join(dirname, '*.mbox')):
>> if os.path.getsize(infile) > (1024*1024*1024*1.8): # Greater than n in megabytes
>> print "current file is: " + infile + " - size is: " + str(os.path.getsize(infile)/(1024*1024)) + "MB"
>> #for filename in filenames:
>> # print ' File',filename
>>
>>
>> top_level_dir = "/var/CommuniGate/"
>> os.path.walk(top_level_dir, processDirectory, None )
>> ### end script ###
>>
>> Hope this helps,
>> -Dana
>>
>>
>> -----Original Message-----
>> From: CommuniGate Pro Discussions [mailto:CGatePro@mail.stalker.com] On Behalf Of Kirnauskis Postmaster
>> Sent: Monday, September 12, 2011 2:29 AM
>> To: CommuniGate Pro Discussions
>> Subject: Re: 2GB mbox checker script
>>
>> John,
>>
>> thanks for your response. I believe your script just checks the sizes of main domain maliboxes and lists them. I'm thinking a "perfect" script would account for other domains as well and, most importantly, inform (email) the account owner.
>>
>>
>>
>> On 8.9.2011, at 10:43, John Kougoulos wrote:
>>
>>> Hi,
>>>
>>> we are using this in Solaris in order to get an early warning:
>>>
>>> find /var/CommuniGate/Accounts -size +1800000000c -follow -ls
>>>
>>> John
>>>
>>> On Thu, 8 Sep 2011, Kirnauskis Postmaster wrote:
>>>
>>>> How are you handling the 2GB mbox size limit? AFAIK, CGP doesn't produce an error message when a single mailbox is closing the size limit (unless you have set the whole account quota to <2Gb). Has anyone developed any scripts to check the mailbox sizes and produce a warning message?
>>>>
>>>>
>>>> --
>>>> Kirnauskis Postmaster
>>>> postmaster@kirnauskis.com
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> #############################################################
>>>> This message is sent to you because you are subscribed to
>>>> the mailing list <CGatePro@mail.stalker.com>.
>>>> To unsubscribe, E-mail to: <CGatePro-off@mail.stalker.com>
>>>> To switch to the DIGEST mode, E-mail to <CGatePro-digest@mail.stalker.com>
>>>> To switch to the INDEX mode, E-mail to <CGatePro-index@mail.stalker.com>
>>>> Send administrative queries to <CGatePro-request@mail.stalker.com>
>>>>
>>>
>>> #############################################################
>>> This message is sent to you because you are subscribed to
>>> the mailing list <CGatePro@mail.stalker.com>.
>>> To unsubscribe, E-mail to: <CGatePro-off@mail.stalker.com>
>>> To switch to the DIGEST mode, E-mail to <CGatePro-digest@mail.stalker.com>
>>> To switch to the INDEX mode, E-mail to <CGatePro-index@mail.stalker.com>
>>> Send administrative queries to <CGatePro-request@mail.stalker.com>
>>
>>
>> --
>> Kirnauskis Postmaster
>> postmaster@kirnauskis.com
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list <CGatePro@mail.stalker.com>.
>> To unsubscribe, E-mail to: <CGatePro-off@mail.stalker.com>
>> To switch to the DIGEST mode, E-mail to <CGatePro-digest@mail.stalker.com>
>> To switch to the INDEX mode, E-mail to <CGatePro-index@mail.stalker.com>
>> Send administrative queries to <CGatePro-request@mail.stalker.com>
>>
>>
>>
>>
>> #############################################################
>> This message is sent to you because you are subscribed to
>> the mailing list <CGatePro@mail.stalker.com>.
>> To unsubscribe, E-mail to: <CGatePro-off@mail.stalker.com>
>> To switch to the DIGEST mode, E-mail to <CGatePro-digest@mail.stalker.com>
>> To switch to the INDEX mode, E-mail to <CGatePro-index@mail.stalker.com>
>> Send administrative queries to <CGatePro-request@mail.stalker.com>
>
>
> --
> Kirnauskis Postmaster
> postmaster@kirnauskis.com
>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list <CGatePro@mail.stalker.com>.
> To unsubscribe, E-mail to: <CGatePro-off@mail.stalker.com>
> To switch to the DIGEST mode, E-mail to <CGatePro-digest@mail.stalker.com>
> To switch to the INDEX mode, E-mail to <CGatePro-index@mail.stalker.com>
> Send administrative queries to <CGatePro-request@mail.stalker.com>
--
Kirnauskis Postmaster
postmaster@kirnauskis.com
|
|