Top 10 Mailbox size notification for Zimbra [Daily Basis]
Step: 01
vi /tmp/topmailbox.sh
#!/bin/bash
input=$(mktemp)
output=$(mktemp)
email=$(mktemp)
sender="adminx@drbdtest.com"
recipients="bolcorp@drbdtest.com"
number=10
date=$(date +"%a, %d %b %Y %H:%M:%S %z (%Z)")
datef="$(date +%F)"
/opt/zimbra/bin/zmprov getQuotaUsage `zmhostname` | awk {'print $1" "$3" "$2'} >> ${input}
cat $input | sort -rn -k 2 | while read line
do
usage=`echo $line | cut -f2 -d " "`
quota=`echo $line | cut -f3 -d " "`
user=`echo $line | cut -f1 -d " "`
echo "`expr $usage / 1024 / 1024` of `expr $quota / 1024 / 1024` MB $user" >> ${output}
done
cat << EOF > ${email}
Date: ${date}
From: ${sender}
To: ${recipients}
Subject: Daily quota report for ${datef}
top ${number} mailboxes by disk usage (quota)
--------------------------------------
EOF
head -${number} ${output} >> ${email}
cat ${email} | /opt/zimbra/common/sbin/sendmail -t ${recipients}
rm -f ${input} ${output} ${email}
Step: 02
chown zimbra.zimbra /tmp/topmailbox.sh
Step: 03
/tmp/topmailbox.sh
[Set it on the cron]
Sample output:
top 50 mailboxes by disk usage (quota)
--------------------------------------
0 of 0 MB adminx@drbdtest.com
0 of 0 MB bolcorp@drbdtest.com
0 of 0 MB virus-quarantine.bmzkxiw7@drbdtest.com
0 of 0 MB spam.zjsm75b5fz@drbdtest.com
0 of 0 MB ham.bnf51kfx@drbdtest.com
0 of 0 MB galsync.yqe1ifp3x@drbdtest.com
vi /tmp/topmailbox.sh
#!/bin/bash
input=$(mktemp)
output=$(mktemp)
email=$(mktemp)
sender="adminx@drbdtest.com"
recipients="bolcorp@drbdtest.com"
number=10
date=$(date +"%a, %d %b %Y %H:%M:%S %z (%Z)")
datef="$(date +%F)"
/opt/zimbra/bin/zmprov getQuotaUsage `zmhostname` | awk {'print $1" "$3" "$2'} >> ${input}
cat $input | sort -rn -k 2 | while read line
do
usage=`echo $line | cut -f2 -d " "`
quota=`echo $line | cut -f3 -d " "`
user=`echo $line | cut -f1 -d " "`
echo "`expr $usage / 1024 / 1024` of `expr $quota / 1024 / 1024` MB $user" >> ${output}
done
cat << EOF > ${email}
Date: ${date}
From: ${sender}
To: ${recipients}
Subject: Daily quota report for ${datef}
top ${number} mailboxes by disk usage (quota)
--------------------------------------
EOF
head -${number} ${output} >> ${email}
cat ${email} | /opt/zimbra/common/sbin/sendmail -t ${recipients}
rm -f ${input} ${output} ${email}
Step: 02
chown zimbra.zimbra /tmp/topmailbox.sh
Step: 03
/tmp/topmailbox.sh
[Set it on the cron]
Sample output:
top 50 mailboxes by disk usage (quota)
--------------------------------------
0 of 0 MB adminx@drbdtest.com
0 of 0 MB bolcorp@drbdtest.com
0 of 0 MB virus-quarantine.bmzkxiw7@drbdtest.com
0 of 0 MB spam.zjsm75b5fz@drbdtest.com
0 of 0 MB ham.bnf51kfx@drbdtest.com
0 of 0 MB galsync.yqe1ifp3x@drbdtest.com
Comments
Post a Comment