Last active
October 26, 2016 16:02
-
-
Save airtonzanon/cda1e7c4d0f0ae04ccb3759fb7264c28 to your computer and use it in GitHub Desktop.
E-mail log para verificar a fila do exim (emails que estão por mais de 12 horas nela)
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 | |
# info: Send email log to email | |
# options: NONE | |
# | |
#----------------------------------------------------------# | |
# Variable&Function # | |
#----------------------------------------------------------# | |
subject="Log Diário - Fila E-mail" | |
from="naoresponder@dominio.com.br" | |
to="webmaster@dominio.com.br" | |
dir="/tmp/logfila" | |
dest="$dir/dest.txt" | |
log="$dir/log.txt" | |
#----------------------------------------------------------# | |
# Action # | |
#----------------------------------------------------------# | |
if [ -d "$dir" ]; then | |
rm -rf "$dir" | |
fi | |
mkdir "$dir" | |
exiqgrep -i -o 43200 | xargs -I{} exigrep {} /var/log/exim4/mainlog >> "$log" | |
echo "E-MAILS QUE ESTÃO NA FILA POR MAIS DE 12 HORAS - VERIFICAR" >> "$dest" | |
echo "" >> "$dest" | |
echo "E-mails envolvidos:" >> "$dest" | |
echo "" >> "$dest" | |
grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" "$dir/log.txt" | sort | uniq | while read -r line ; do | |
echo "$line" >> "$dest" | |
done | |
echo "" >> "$dest" | |
echo "Lista dos e-mails que estão há mais de 12 horas na fila:" >> "$dest" | |
exiqgrep -b -o 43200 >> "$dest" | |
echo "" >> "$dest" | |
echo "" >> "$dest" | |
echo "TALVEZ ISTO MEREÇA ATENÇÃO! VERIFIQUE O LOG ANEXO!" >> "$dest" | |
echo "" >> "$dest" | |
echo "" >> "$dest" | |
dataHora=$(date) | |
echo "Quantidade de e-mails na fila (total) as $dataHora:" >> "$dest" | |
exim -bpc >> "$dest" | |
/usr/bin/mail -r $from -a "$log" -s "$subject" $to < "$dest" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment