On this post explain get bandwidth usage report through email  and want install vnstat package in it.

#!/bin/bash
#create a file in /tmp directory
# touch /tmp/bandwidth_usage.txt
# Calculate Total Bandwidth


getstat=`vnstat | tail -1 | awk '{print $8}'`

#Get Your Server IP Address

IP=`/sbin/ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' |
awk '{print $1}'`
TO_ADDRESS="toemail@gmail.com"
SUBJECT="Over Crossing Bandwidth "

#set bandwidth limit : 10GiB
b=10

#find Bandwidth report

if [ $(echo "$getstat >  $b" | bc) -ne 0 ]
then
     echo $getstat
    echo > /tmp/bandwidth_usage.txt
    vnstat > /tmp/bandwidth_usage.txt
    mail -s "$SUBJECT - $getstat GiB in :$HOSTNAME-$IP" $TO_ADDRESS  <
/tmp/bandwidth.txt
else
       echo "None of the condition met"
fi