-
-
Save cavearr/054eff3b1bbfadbc44d78bcb3e550a20 to your computer and use it in GitHub Desktop.
Reporte de mensajes enviados y recibidos - Zimbra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z $1 ]; then | |
echo "ERROR: Proporcionar el usuario para le reporte" | |
exit 1 | |
fi | |
sender(){ | |
echo "Sender :" | |
/opt/zimbra/libexec/zmmsgtrace -s "^${1}$" /opt/backup/logs/zimbra.log-202* > /tmp/${1} 2> /dev/null | |
cat /tmp/${1} | grep Recipient -A2 | grep -Ev '^$|^--$' | grep Recipient -B1 | grep -Ev '^$|^--$' | grep -v Recipient | awk -F' - ' '{print $1}' > /tmp/${1}.date | |
cat /tmp/${1} | awk '{print $1}' | awk "/Message/,/Recipient/"'{print $0}' | grep -vE "Message|Recipient|${1}@" > /tmp/${1}.to | |
cat /tmp/${1} | grep Recipient -A3 | grep -Ev '^$|^--$' | grep Recipient -B1 | grep -Ev '^$|^--$' | grep -v Recipient | awk -F' --> ' '{print $2}' > /tmp/${1}.status | |
tail /tmp/${1} -n2 | head -1 | awk -F' - ' '{print $1}' >> /tmp/${1}.date | |
tail /tmp/${1} -n2 | head -1 | awk -F' --> ' '{print $2}' >> /tmp/${1}.status | |
echo "DATE: /tmp/${1}.date" | |
echo "FROM: ${1}" | |
echo "TO : /tmp/${1}.to" | |
echo "STAT: /tmp/${1}.status" | |
echo "----------------------------------" | |
} | |
recipient(){ | |
echo "Recipient :" | |
/opt/zimbra/libexec/zmmsgtrace -r "^${1}$" /opt/backup/logs/zimbra.log-202* > /tmp/${1}2 2> /dev/null | |
cat /tmp/${1}2 | grep Recipient -A2 | grep -Ev '^$|^--$' | grep Recipient -B1 | grep -Ev '^$|^--$' | grep -v Recipient | awk -F' - ' '{print $1}' > /tmp/${1}2.date | |
cat /tmp/${1}2 | grep -E "\-\->$" | awk -F" " '{print $1}' > /tmp/${1}2.from | |
cat /tmp/${1}2 | grep Recipient -A3 | grep -Ev '^$|^--$' | grep Recipient -B1 | grep -Ev '^$|^--$' | grep -v Recipient | awk -F' --> ' '{print $2}' > /tmp/${1}2.status | |
tail /tmp/${1}2 -n2 | head -1 | awk -F' - ' '{print $1}' >> /tmp/${1}2.date | |
tail /tmp/${1}2 -n2 | head -1 | awk -F' --> ' '{print $2}' >> /tmp/${1}2.status | |
echo "DATE: /tmp/${1}2.date" | |
echo "FROM: /tmp/${1}2.from" | |
echo "TO : ${1}" | |
echo "STAT: /tmp/${1}2.status" | |
} | |
sender ${1} | |
recipient ${1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment