LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Sendmail message size (https://www.linuxquestions.org/questions/linux-software-2/sendmail-message-size-41787/)

pk21 01-17-2003 05:19 AM

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
----

unSpawn 01-17-2003 08:45 AM

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)
echo "aprox  $(echo $size_t / 1024 / 1024 | bc -l | cut -c 0-3) MB"
echo "aprox  $(echo $size_t / 1024 | bc -l | cut -c 0-5) KB"
echo "exactly $size_t Bytes"
echo "exactly $(echo $size_t \* 8 | bc -l ) bits"
done


pk21 01-17-2003 03:53 PM

Great! Thanks!


All times are GMT -5. The time now is 05:03 PM.