Sendmail message size
I am trying to calculate how many MB of mail there has been sent to a domain. In the sendmail log i grep for all the "size=" lines. But when i add them up i get to 5078658 kb. This is way to much.
What am i doing wrong this time? i typed this from command line: ---- grep "Jan 15" /var/log/maillog|grep "from="|grep -v domain.nl|grep -v "to="| awk '{ print $8 }'|sed -e "s/size=//g"|sed -e "s/[,]//g" > /root/mailsize ---- And this as a little script: ---- #!/bin/bash aantal=$((0)) cat mailsize | while read line; do aantal=$(($aantal + $line)) echo $aantal done ---- |
Shouldn't that be bytes? (Cap b, lowercase b being bits, 8 bits in a Byte): Bytes / 1024 (KBytes) / 1024 (KBytes): "echo 5078658 / 1024 / 1024 | bc -l"
Code:
size_t=0; cat /var/log/maillog | grep "from=" | grep "size=" | cut -d "=" -f 3 | cut -d "," -f 1 | while read size_m; do size_t=$(expr $size_t + $size_m) |
Great! Thanks!
|
All times are GMT -5. The time now is 05:03 PM. |