Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $# -eq 0 ]
- then
- echo "Mail Activity Report"
- echo "####################"
- echo "No arguments supplied"
- echo "Please use the following format:"
- echo ""
- echo " start_date|rep_dir|audited_email"
- echo "./report_email_act.sh 20180120 /tmp test@domain.com"
- exit 1
- fi
- tar_date=`date -d $1 +"%Y%m%d"`
- today=`date +"%Y%m%d"`
- #log_depth=`ls -t1 /var/log/maillog* | head -n 2`
- log_depth=`ls -t1 /var/log/maillog*`
- echo "Mail Activity Report"
- echo "####################"
- echo "Starting LOG files processing:"
- [ -f $2/report.$1-$today ] && rm -fr $2/report.$1-$today
- while [ $tar_date -ne $today ]
- do
- echo "Processing date "`date -d $tar_date +"%d.%m.%Y"`
- received=`/opt/zimbra/libexec/zmmsgtrace $log_depth -r "$3" --time "$tar_date,$tar_date"|grep "Message ID "|uniq|wc -l`
- sent=`/opt/zimbra/libexec/zmmsgtrace $log_depth -s "$3" --time "$tar_date,$tar_date"|grep "Message ID "|uniq|wc -l`
- received_length=`expr length $received`
- sent_length=`expr length $sent`
- if [ $received_length == 1 ]
- then
- received="00"$received
- fi
- if [ $received_length == 2 ]
- then
- received="0"$received
- fi
- if [ $sent_length == 1 ]
- then
- sent="00"$sent
- fi
- if [ $sent_length == 2 ]
- then
- sent="0"$sent
- fi
- echo "Mail Received: "$received -- "Sent: "$sent -- "E-Mail: "$3 "Date: "`date -d $tar_date +"%d.%m.%Y"`>>$2/report.$1-$today.txt
- tar_date=`date -d "$tar_date +1 day" +"%Y%m%d"`
- #echo " " >>$2/report.$1-$today
- done
- echo "####################"
- echo "Done"
- echo "Review the report at : "$2/report.$1-$today.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement