[Postfix-br] Post-la

Gabriel Francisco frc.gabriel em gmail.com
Terça Outubro 29 11:54:04 BRST 2013


Aguimar,
você também pode tentar visualizar a mensagem no formato original. No
Gmail fica no menu da direita logo ao lado do botão Reply da mensagem!

Cordialmente.

Gabriel Francisco
----------------------------
Linux User #507840
phone: (041) 9195-5010
email: frc.gabriel[at]gmail.com


On Tue, Oct 29, 2013 at 11:46 AM, Junior Plug Tecnologia
<arezendejunior em gmail.com> wrote:
> Bom dia Gabriel
>
> O ideal seria converter para modo texto antes?
>
> Gabriel Francisco <frc.gabriel em gmail.com> escreveu:
>>
>> Bom dia Aguimar,
>> provavelmente pelo email estar em HTML pode ter causado a separação
>> dos caracteres <<.
>>
>> Cordialmente.
>>
>> Gabriel Francisco
>> ----------------------------
>> Linux User #507840
>> phone: (041) 9195-5010
>> email: frc.gabriel[at]gmail.com
>>
>>
>> On Tue, Oct 29, 2013 at 10:37 AM, Aguimar Rezende Junior
>> <arezendejunior em gmail.com> wrote:
>>>
>>> Oi Mateus na verdade seria este mais antigo:
>>>
>>> Mas não consegui descobrir este erro:
>>>
>>> ./post-la.sh: line 59: syntax error near unexpected token `<'
>>> ./post-la.sh: line 59: `        done < < '($egrep (delivered to mail|Ok:
>>> queued as)' $dirlog/$nomelog |$awk {'print $6'} |$uniq)'
>>>
>>>
>>>
>>> #!/bin/sh
>>>
>>> #######################################
>>> # v1.1.2
>>> # Desenvolvido por Henrique Bueno
>>> # henriquebueno em gmail.com
>>> # http://hbueno.eti.br
>>> # http://post-la.kibibit.com.br
>>> #
>>> # Este programa esta licenciado sob
>>> # uma licenca creative Commons
>>> #
>>> #######################################
>>>
>>>
>>> function main(){
>>> whereis=/usr/bin/whereis
>>> cut=/usr/bin/cut
>>> grep=$($whereis -b grep |$cut -d " " -f2)
>>> tr=$($whereis -b tr |$cut -d " " -f2)
>>> egrep=$($whereis -b egrep |$cut -d " " -f2)
>>> cat=$($whereis -b cat |$cut -d " " -f2)
>>> ls=$($whereis -b ls |$cut -d " " -f2)
>>> bc=$($whereis -b bc |$cut -d " " -f2)
>>> sort=$($whereis -b sort |$cut -d " " -f2)
>>> uniq=$($whereis -b uniq |$cut -d " " -f2)
>>> awk=$($whereis -b awk |$cut -d " " -f2)
>>> sed=$($whereis -b sed |$cut -d " " -f2)
>>>
>>> # Alterar esta
>>> variavel caso tenha instalado em um diretorio
>>> # diferente de /etc/post-la (sem "/" no final)
>>> dirinst="/etc/post-la"
>>>
>>> # Pega as variaveis do arquivo de configuracao
>>> dir=$($grep DIRPOST $dirinst/post-la.conf |$cut -c 9-)
>>> dirlog=$($grep DIRLOG $dirinst/post-la.conf |$cut -c 8-)
>>> nomelog=$($grep NOMELOG $dirinst/post-la.conf |$cut -c 9-)
>>> TAG=$($grep TAG $dirinst/post-la.conf |$cut -c 5-)
>>>
>>> dataarq="$(echo $(date +%Y))-$(echo $(date +%m))-$(echo $(date
>>> +%d)).log"
>>> if test -f "$dir/dados/$dataarq"; then rm $dir/dados/$dataarq; fi
>>> touch $dir/dados/$dataarq
>>> if test -f "$dir/resumo/$dataarq"; then rm $dir/resumo/$dataarq; fi
>>> touch $dir/resumo/$dataarq
>>>
>>> while read LINHA
>>> do
>>> PegaCampos
>>> if test $PULA="NAO"
>>> then
>>> if test -n "$(echo $FROM |$cut -c 4-)" || test -n
>>> "$(echo $TO |$cut -c 4-)"
>>> then
>>> PegaTamanho
>>> LimparString
>>> ArrumaData
>>> echo
>>> "$DATA|$HORA|$ASSUNTO|$FROM|$TO|$TAM"
>>>>>
>>>>> "$dir/dados/$dataarq"
>>>
>>> fi
>>> fi
>>> done < < '($egrep (delivered to mail|Ok: queued as)'
>>> $dirlog/$nomelog |$awk {'print $6'} |$uniq)
>>> Resumo
>>> }
>>>
>>> function PegaCampos(){
>>> PULA="NAO"
>>> ID=$(echo $LINHA |$sed 's/://')
>>> EMAIL=$($grep $ID $dirlog/$nomelog |$grep $TAG |$tr -d '%')
>>> if test -z "$EMAIL"
>>> then
>>> IDR="$($grep $ID $dirlog/$nomelog |$grep -i Requeue |$awk
>>> {'print $7'} |$cut -d. -f1)"
>>> if test -z "$IDR"
>>> then
>>> PULA=SIM
>>> else
>>> EMAIL=$($grep $IDR $dirlog/$nomelog |grep $TAG)
>>> echo "PAM=$LINHA/$EMAIL" >> $dir/erro.log
>>> fi
>>> fi
>>> DATA="$(echo $(date +%Y) $(echo $EMAIL |$awk {'print
>>> $1" "$2'}))"
>>> HORA="HR=$(echo $EMAIL |$awk {'print $3'})"
>>> FROM="DE=$(echo $EMAIL |$sed 's/from=</|/' |$sed 's/to=</|/' |$cut
>>> -d\| -f2 |$sed 's/>//' |$tr -d '%')"
>>> TO="PR=$(echo $EMAIL |$sed 's/from=</|/' |$sed 's/to=</|/' |$cut
>>> -d\| -f3 |$cut -d\> -f1 |$sed 's/>//' |$tr -d '%')"
>>> TAM="$($grep "$ID" $dirlog/$nomelog |$grep size |$awk {'print $8'}
>>> |$cut -c 6- |$sed 's/,//' |$uniq)"
>>> ASSUNTO=$(echo $EMAIL |$sed 's/Subject:/|/' |$sed 's/from /|/' |$cut
>>> -d\| -f2 | $cut -c 0-150 |$tr -d '%')
>>> }
>>>
>>> function PegaTamanho(){
>>> if (( "$TAM" >= 1000000 ))
>>> then
>>> TAM="TM=$(echo "scale=2; $TAM/1000000" |$bc) mb"
>>> else
>>> TAM="TM=$(echo "scale=2; $TAM/1000" |$bc) kb"
>>> fi
>>> }
>>>
>>> function ArrumaData(){
>>> mes=$(echo $DATA |$awk {'print $2'})
>>> case "$mes" in
>>> Jan) mes=01;;
>>> Feb) mes=02;;
>>> Mar) mes=03;;
>>> Apr) mes=04;;
>>> May) mes=05;;
>>> Jun) mes=06;;
>>> Jul)
>>> mes=07;;
>>> Aug) mes=08;;
>>> Sep) mes=09;;
>>> Oct) mes=10;;
>>> Nov) mes=11;;
>>> Dec) mes=12;;
>>> esac
>>> dia=$(echo $DATA |$awk {'print $3'})
>>> ano=$(echo $DATA |$awk {'print $1'})
>>> DATA="DT=$dia"/"$mes"/"$ano"
>>> }
>>>
>>> function LimparString(){
>>> ASSUNTO="$(echo $ASSUNTO |$tr [:upper:] [:lower:] |$tr -d '%')"
>>> carac[1]="=c3=a3;a"
>>> carac[2]="=c3=b5;o"
>>> carac[3]="=\?iso-8859-1\?q\?;"
>>> carac[4]="=e1;a"
>>> carac[5]="=e7;c"
>>> carac[6]="=e3;a"
>>> carac[7]="=f5;o"
>>> carac[8]="=c7=c3;ca"
>>> carac[10]="=c3=a7;c"
>>> carac[11]="=e9;e"
>>> carac[12]="=c3;a"
>>> carac[13]="\?windows-1252\?q\?;"
>>> carac[14]="=d4;o"
>>> carac[15]="=c7;a"
>>> carac[16]="=5b;"
>>> carac[17]="=5d;"
>>> carac[18]="=f3;o"
>>> carac[19]="=f4;o"
>>> carac[20]="\?;"
>>> carac[21]="=;"
>>> carac[22]="_; "
>>>
>>> for teste in "${carac[@]}"
>>> do
>>> ASSUNTO="${ASSUNTO//$(echo $teste |$cut -d\; -f1)/$(echo
>>> $teste |$cut -d\; -f2)}"
>>> done
>>> if test -z "$ASSUNTO"
>>> then
>>> ASSUNTO="(sem assunto)"
>>> fi
>>> ASSUNTO="AS=$ASSUNTO"
>>> }
>>>
>>> function Resumo(){
>>> # pega contas que enviaram e-mails
>>> while read dom
>>> do
>>> $cat "$dir/dados/$dataarq" |$cut -d\| -f4 |$cut -c 4- |$cut
>>> -d: -f1 |$grep @$dom |$sort |$uniq >> $dir/contas.tmp
>>> done < <($cat $dirinst/dominios)
>>>
>>> # compara com contas que receberam e-mails
>>> while read dom
>>> do
>>> while read LINHA
>>> do
>>> if test -z "$($grep $LINHA $dir/contas.tmp)"; then
>>> echo "$LINHA" >> $dir/contas.tmp;fi
>>> done < <($cat "$dir/dados/$dataarq" |$cut -d\| -f5 |$cut -c
>>> 4- |$cut -d: -f1 |$grep @$dom |$sort |$uniq)
>>> done < <($cat $dirinst/dominios)
>>>
>>> while read LINHA
>>> do
>>> EMAIL="$LINHA"
>>> ENVIADOS=$($grep "DE=$EMAIL" $dir/dados/$dataarq | wc -l)
>>> RECEBIDOS=$($grep "PR=$EMAIL" $dir/dados/$dataarq | wc -l)
>>> tamenv=0
>>> tamrec=0
>>>
>>> # pega
>>> tamanho de emails enviado
>>> while read tamanho
>>> do
>>> PegaTamanhoResumo
>>> tamenv=$(echo "scale=2; $tamenv+$TAM" |$bc)
>>> done < <($grep DE=$EMAIL $dir/dados/$dataarq |$cut -d\| -f6)
>>> #if test "$(echo $tamenv |$cut -d. -f1)" -ge 1000
>>> #then
>>> #        tamenv="$(echo "scale=2; $tamenv/1000" |$bc) mb"
>>> #else
>>> #tamenv="$tamenv"
>>> #        tamenv="$tamenv kb"
>>> #fi
>>>
>>> # pega tamanho de e-mails recebidos
>>> while read tamanho
>>> do
>>> PegaTamanhoResumo
>>> tamrec=$(echo "scale=2; $tamrec+$TAM" |$bc)
>>> done < <($grep PR=$EMAIL $dir/dados/$dataarq |$cut -d\| -f6)
>>>
>>> #if test "$(echo $tamrec |$cut -d. -f1)" -ge 1000
>>> #then
>>> #        tamrec="$(echo "scale=2; $tamrec/1000" |$bc) mb"
>>> #else
>>> #tamrec="$tamrec"
>>> #        tamrec="$tamrec kb"
>>> #fi
>>> echo "$EMAIL|$ENVIADOS|$tamenv|$RECEBIDOS|$tamrec" >>
>>> "$dir/resumo/$dataarq"
>>> done < <($cat $dir/contas.tmp |$sort |$uniq)
>>> rm $dir/contas.tmp
>>> }
>>>
>>> function PegaTamanhoResumo(){
>>> var="$(echo $tamanho |$awk {'print $2'})"
>>> valor="$(echo $tamanho |$awk {'print $1'} |$cut -c 4-)"
>>> if test  "$var" = mb
>>> then
>>> TAM=$(echo "scale=2; $valor*1000" |$bc)
>>> else
>>> TAM=$valor
>>> fi
>>> }
>>>
>>> main
>>>
>>>
>>>
>>> ######################################
>>>
>>>
>>>
>>>
>>>
>>> Em 29/10/2013 09:13, mateus schott escreveu:
>>>
>>> Seria esse??
>>>
>>> #!/bin/bash
>>>
>>> if [ -r /etc/post-la2/post-la.conf ]; then
>>> . /etc/post-la2/post-la.conf
>>> else
>>> echo "Nao foi possivel carregar as configuracoes de
>>> /etc/post-la2/post-la.conf"
>>> exit 1
>>> fi
>>>
>>> printf "\n"
>>> printf "#\n"
>>> printf "# POST-LA (Postfix Log Analyzer) v2.0 \n"
>>> printf "\n"
>>> printf "Inicio Processamento: $(date "+%D-%T")...\n"
>>>
>>> #Definindo Variaveis
>>> YEAR="$(date +%Y)"
>>> YN="NULL|$(date +%Y)"
>>>
>>> function
>>> validos(){
>>> printf "Filtrando mensagens validas..."
>>> PID="$(grep -E '(delivered (to mail|via jeguepanel|to command |via
>>> maildrop service)|Ok: queued as)' $LOG |awk {'print $6'} |sed 's/://g' |
>>> uniq)"
>>> printf " ok\n"
>>>
>>> printf "Pegando tamanho das mensagens..."
>>> tamanho="$(awk '$8~/^size=/{SIZE=gensub(/[^0-9]/,"","G",$8)/1024;
>>> printf "%s%.2f\n", $6,SIZE}' $LOG | sort -u)"
>>> printf " ok\n"
>>>
>>> printf "Pegando destinatarios..."
>>> destinatarios="$(cat $LOG |grep "to=<" |grep Ok |awk {'print $6"
>>> "$7'} |sed 's/to=<\|>\|://g')"
>>> printf " ok\n"
>>>
>>> printf "Pegando assunto e remetente..."
>>> assunto="$(awk ' /POST-LA/ {
>>> subj=""
>>> for (i=10;i<=NF;i++){ if ($i=="from") {j=i;i=NF} else
>>> {subj=subj" "$i} } print $1"-"$2"|"$3"|"$6"|"subj"|"$(j+2) }' $LOG )"
>>> printf " ok\n"
>>>
>>> printf "Arrumando data..."
>>> sed
>>>
>>> 's/^Jan/'$YEAR'-01/;s/^Feb/'$YEAR'-02/;s/^Mar/'$YEAR'-03/;s/^Apr/'$YEAR'-04/;s/^May/'$YEAR'-05/;s/^Jun/'$YEAR'-06/;s/^Jul/'$YEAR'-07/;s/^Aug/'$YEAR'-08/;s/^Sep/'$YEAR'-09/;s/^Oct/'$YEAR'-10/;s/^Nov/'$YEAR'-11/;s/^Dec/'$YEAR'-12/;s/\(from=\|<\|>\)//gi'
>>> <<<"$assunto" > $TMPDIR/assunto1.tmp
>>> printf " ok\n"
>>>
>>> printf "Convertendo charset..."
>>> php -f /etc/post-la2/convert.php $TMPDIR/assunto1.tmp >
>>> $TMPDIR/assunto.tmp
>>> rm -rf $TMPDIR/assunto1.tmp
>>> printf " ok\n"
>>>
>>> printf "Gerando arquivo para importar ao MySQL..."
>>>>
>>>> $TMPDIR/messages.tmp
>>>
>>> for ID in $PID
>>> do
>>> registro="$(grep $ID $TMPDIR/assunto.tmp |sed 's/:|/|/g'
>>> |tail -1)"
>>> if [ ! -z "$registro" ]; then
>>> tam="$(awk -F ":" '/'$ID'/ {printf $2}' <<<
>>> "$tamanho" |tail -1)"
>>> dest="$(awk '/'$ID'/ {printf
>>> tolower($2)}' <<<
>>> "$destinatarios" |sed 's/,$//;s/,/, /g')"
>>> echo "NULL|$registro|$tam|$dest" >>
>>> $TMPDIR/messages.tmp
>>> fi
>>> done
>>> # done <<< "$PID"
>>> rm -rf $TMPDIR/assunto.tmp
>>> printf " ok \n"
>>> }
>>>
>>> function import_mails(){
>>> printf "Importando dados para MySQL..."
>>> mysql -u$dbuser -p$dbsenha -e "load data infile
>>> '$TMPDIR/messages.tmp' into table mails fields terminated by '|'"
>>> $database
>>> rm -rf $TMPDIR/messages.tmp
>>> printf " ok \n"
>>> }
>>>
>>> function invalidos(){
>>> reject_postfix
>>> #reject_amavis
>>> reject_bounced
>>> arruma_data_reject
>>> }
>>> function reject_postfix(){
>>> awk '/reject:/{
>>> ERRO=""
>>> ERRO2=""
>>> for (i=7;i<=NF;i++){
>>> if (match($i,/from=</)){
>>> FROM=$i
>>> for (j=7;j<i;j++){
>>> ERRO=ERRO" " $j
>>> }
>>> }
>>> if (match($i,/to=</)){
>>> TO=$i
>>> k=i;
>>> }
>>> if (i>k){
>>> ERRO2=ERRO2" "$i
>>> }
>>> }
>>> print
>>> $1"-"$2"|"$3"|"FROM"|"TO"|"$6" "ERRO"|"ERRO2
>>> }' $LOG > $TMPDIR/reject0.tmp
>>> }
>>>
>>> function reject_bounced(){
>>> awk '/status=bounced/ {
>>> ERRO=""
>>> for (i=8;i<=NF;i++){
>>> ERRO=ERRO" "$i
>>> }
>>> print $1"-"$2"|"$3"| |"$7"|"$6"|"ERRO
>>> }' $LOG > $TMPDIR/reject-id.tmp
>>> while IFS=\| read data hora from to id erro
>>> do
>>> from="$(grep $id $LOG |grep "from=<" |awk {'print $7'}
>>> |uniq)"
>>> echo "$data|$hora|$from|$to|$erro |sed 's/,$//g'" >>
>>> $TMPDIR/reject0.tmp
>>> done < $TMPDIR/reject-id.tmp
>>> rm -rf $TMPDIR/reject-id.tmp
>>> }
>>>
>>> function reject_amavis(){
>>> awk '/Blocked / {
>>> ERRO=""
>>> for (i=7;i<=NF;i++){
>>> if (match($i,/->/)){
>>> FROM=$(i-1)
>>> TO=$(i+1)
>>> ERRO=$(i+2)" "$(i+3)
>>> }
>>> }
>>> print $1"-"$2"|"$3"|"FROM"|"TO"|"$7" "$8" "$9" "ERRO
>>> }' $LOG >> $TMPDIR/reject0.tmp
>>> }
>>>
>>> function import_reject(){
>>> mysql -u$dbuser -p$dbsenha -e "load
>>> data infile '$TMPDIR/reject.tmp'
>>> into table reject fields terminated by '|'" $database
>>> rm -rf $TMPDIR/reject.tmp
>>> }
>>>
>>> function arruma_data_reject(){
>>> sed
>>>
>>> 's/^Jan/'$YN'-01/;s/^Feb/'$YN'-02/;s/^Mar/'$YN'-03/;s/^Apr/'$YN'-04/;s/May/'$YN'-05/;s/Jun/'$YN'-06/;s/Jul/'$YN'-07/;s/Aug/'$YN'-08/;s/Sep/'$YN'-09/;s/Oct/'$YN'-10/;s/Nov/'$YN'-11/;s/Dec/'$YN'-12/;s/\(from=\|to=\|<\|>\)//gi'
>>> <$TMPDIR/reject0.tmp > $TMPDIR/reject.tmp
>>> rm -rf $TMPDIR/reject0.tmp
>>> }
>>>
>>>
>>> function finaliza(){
>>> printf "Limpando variaveis..."
>>> unset dbuser dbsenha database PID  registro tam dest tamanho
>>> destinatarios assunto TMPDIR
>>> printf " ok \n"
>>> printf "Finalizado, dados importados com sucesso. $(date
>>> "+%D-%T").\n\n"
>>> }
>>>
>>> case "$1" in
>>> validos)
>>> echo "Gerando relatorio de e-mails validos..."
>>> validos
>>> # import_mails
>>> finaliza
>>> ;;
>>> invalidos)
>>> printf "Gerando relatorio de e-mails
>>> invalidos..."
>>> invalidos
>>> # import_reject
>>> finaliza
>>> printf "ok \n"
>>> ;;
>>> *)
>>> echo "Gerando relatorio completo (validos e
>>> invalidos)"
>>> validos
>>> # import_mails
>>> invalidos
>>> # import_reject
>>> finaliza
>>> ;;
>>> esac
>>>
>>>
>>>
>>> 2013/10/25 Aguimar Rezende Junior <arezendejunior em gmail.com>
>>>
>>>> Boa noite pessoal
>>>>
>>>> Alguém tem um cópia do antigo script post-la ?
>>>>
>>>>
>>>> Aguimar Rezende
>>>> ________________________________
>>>>
>>>> Postfix-br mailing list
>>>> Postfix-br em listas.softwarelivre.org
>>>> http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/postfix-br
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Mateus Schott
>>> Administrador de Redes
>>> LPI 1 - Junior Level Linux Certification
>>> Novell Certified Linux
>>> Administrator
>>>
>>>
>>> “A caixa dizia: Requer MS Windows ou superior. Então instalei Linux.”
>>>
>>>
>>> ________________________________
>>>
>>> Postfix-br mailing list
>>> Postfix-br em listas.softwarelivre.org
>>> http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/postfix-br
>>>
>>>
>>>
>>> ________________________________
>>>
>>> Postfix-br mailing list
>>> Postfix-br em listas.softwarelivre.org
>>> http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/postfix-br
>>
>>
>> ________________________________
>>
>> Postfix-br mailing list
>> Postfix-br em listas.softwarelivre.org
>> http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/postfix-br
>
>
> --
> E-mail enviado do meu celular Android usando K-9 Mail. Por favor, desculpe
> minha brevidade.
>
> _______________________________________________
> Postfix-br mailing list
> Postfix-br em listas.softwarelivre.org
> http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/postfix-br
>


More information about the Postfix-br mailing list