Use the following script to see POP3/IMAP usage in bytes (it reads /var/log/maillog file and outputs the bandwidth usage for every email user (period of time counted depends on logrotate)):
Code:
#!/bin/sh
for u in `ls /usr/local/directadmin/data/users`; do
{
echo "$u";
echo -n "POP3: "
grep "($u)" /var/log/maillog | awk '/pop3/ && /retr/ && /Disconnected/ {print $11}' | cut -d/ -f2 | cut -d, -f1 | awk '{sum+=$1} END {printf("%0.0f\n", sum)}'
echo -n "IMAP: "
grep "($u)" /var/log/maillog | awk '/imap/ && /bytes/ && /Disconnected/ {print $10}' | cut -d/ -f2 | cut -d, -f1 | awk '{sum+=$1} END {printf("%0.0f\n", sum)}'
for d in `cat /usr/local/directadmin/data/users/$u/domains.list`; do
{
for eu in `cat /etc/virtual/$d/passwd | cut -d: -f1`; do
{
echo "$eu@$d";
echo -n "POP3: "
grep "($eu@$d)" /var/log/maillog | awk '/pop3/ && /retr/ && /Disconnected/ {print $11}' | cut -d/ -f2 | cut -d, -f1 | awk '{sum+=$1} END {printf("%0.0f\n", sum)}'
echo -n "IMAP: "
grep "($eu@$d)" /var/log/maillog | awk '/imap/ && /bytes/ && /Disconnected/ {print $10}' | cut -d/ -f2 | cut -d, -f1 | awk '{sum+=$1} END {printf("%0.0f\n", sum)}'
}
done;
}
done;
}
done;
exit 0;
Last edited: