Reporting de HylaFAX

Aquí dejo un pequeño script para sacar la información de los logs del HylaFAX.

La información que saca (report) la envía por mail. Aquí dejo un extracto de la información enviada:

Ejemplo de report

En dicho report podemos ver los envíos con errores del tipo:

Busy signal detected; too many attempts to dial

Failure to train remote modem at 2400 bps or minimum speed

No carrier detected

No carrier detected; too many attempts to dial

No local dialtone; too many attempts to dial

No receiver protocol (T.30 T1 timeout)

No response to PPS repeated 3 times

RSPREC error/got DCN (sender abort)

etc…

Aquí dejo el documento para la descarga

Y aquí el código.

#!/bin/bash
echo “Haciendo limpieza”
rm -R /tmp/temporales
mkdir /tmp/temporales
cd /var/spool/hylafax/doneq/
echo “Realizando check del dia $2”
find ./ -newermt “$1 $2, $3” -ls| while read line;do export FILE=$(echo “${line}”|awk ‘{print $11}’); cp ${FILE} /tmp/temporales/; done
echo “Realizando check del dia $5”
find ./ -newermt “$4 $5, $6” -ls| while read line;do export FILE=$(echo “${line}”|awk ‘{print $11}’); cp ${FILE} /tmp/temporales/; done
export DIR_FAXES=”/tmp/temporales/”
export RUTA_FINAL=”/root/hylaing/pruebas-hylafax/ch”
export STATE_8=”/root/hylaing/pruebas-hylafax/ch/S8″
export FAXES_ERRONEOS=”/root/hylaing/pruebas-hylafax/informe_faxes_$(date +%s).txt”
echo “Realizando fichero de errores”
find ${DIR_FAXES} -name “q*” |while read file ; do
export STATE=$(grep “state:” ${file} | cut -d ‘:’ -f2 )
mkdir ${RUTA_FINAL}/S${STATE} 2>/dev/null
cp ${file} ${RUTA_FINAL}/S${STATE}/
done
echo “Fecha|identificador del fax|numero de telf-fax destino|Documento|Estado de error”>> ${FAXES_ERRONEOS}
echo “Realizando paso 2 de fichero de errores”
find ${STATE_8} -name “q*”| while read line; do
export FECHA=$(cat ${line} | grep “tts:” | cut -d ‘:’ -f2 | awk ‘{print $1}’)
FECHA=$(date -d@${FECHA})
export TELF_FAX=$(cat ${line} | grep “external:”| cut -d ‘:’ -f2 | awk ‘{print $1}’)
export STATUS=$(cat ${line} | grep “status:”| cut -d ‘:’ -f2 )
export DOC=$(cat ${line} | grep “tiff:”| cut -d ‘:’ -f4 )
export FAX=$(echo “${DOC}”| cut -d ‘/’ -f2| cut -d ‘.’ -f1|cut -d ‘c’ -f2)
echo “${FECHA}|${FAX}|${TELF_FAX}|/var/spool/hylafax/${DOC}|${STATUS}” >> ${FAXES_ERRONEOS}
done
echo “Realizando limpiaza”
rm -R ${RUTA_FINAL}/S* 2>/dev/null
echo “Comprimiendo fichero”
zip ${FAXES_ERRONEOS}.zip ${FAXES_ERRONEOS}
echo “Enviando mail”
mutt -s “Informe Faxes” -a ${FAXES_ERRONEOS}.zip mail@dominio.com < /dev/null
echo “Proceso finalizado”

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s