If you want to get a glimpse of what's grinding away in your
postfix MTA's mail queue, this simple bash one liner will give you the
top 15 domains that it's working with:
To break it down, we're first getting a queue list by running the mailq command. Then we pipe that to grep and filter for only those lines that begin (^) with a capital letter [A-Z or (\|) a number 0-9], which gives all lines that begin with a Queue-ID.
If we look at one of those lines, we see that the 7th field contains the email address of the sender and that's what we grab using the awk statement. Then we split the email address on the @ symbol and just grab the second field which is the domain (cut -d@ -f2).
Then we sort those results and pipe them to the uniq utility which we use to count the references. With those counts in place, we do a reverse sort on the counts (sort -rn) in order to give us the busiest domains first and then use the head statement to just give us the top 15.
When it's all done, you get something like this as output:
$ mailq | grep ^[A-Z\|0-9] | awk '{print $7}' | cut -d@ -f2 | sort | uniq -c | sort -rn | head -15
To break it down, we're first getting a queue list by running the mailq command. Then we pipe that to grep and filter for only those lines that begin (^) with a capital letter [A-Z or (\|) a number 0-9], which gives all lines that begin with a Queue-ID.
If we look at one of those lines, we see that the 7th field contains the email address of the sender and that's what we grab using the awk statement. Then we split the email address on the @ symbol and just grab the second field which is the domain (cut -d@ -f2).
Then we sort those results and pipe them to the uniq utility which we use to count the references. With those counts in place, we do a reverse sort on the counts (sort -rn) in order to give us the busiest domains first and then use the head statement to just give us the top 15.
When it's all done, you get something like this as output:
1274 example100.com 89 example2.com 85 example3.org 83 example5.net 68 example8.info 64 example10.org 57 example7.com 55 example15.com 50 example1.net 50 example20.com 45 example45.com 41 example60.net 40 example33.com 38 example6.com 38 example34.com
This post has been edited by Jim-J: 02 February 2010 - 07:10 AM
No hay comentarios:
Publicar un comentario