I hacked this up to resolve this:
Modified [ext-fax] to insert “Fax Finish Time is:” statement.
(yes, this will be overwritten whenever freepbx reloads/saves information.)
[ext-fax]
.
…
…
exten => s,n,Noop(Receiving Fax for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)})
exten => s,n(receivefax),Noop(Start time is: ${STRFTIME(${EPOCH},%b %d %H:%M:%S)})
exten => s,n,Set(FAXSTARTTIME=${STRFTIME(${EPOCH},%b %d %H:%M:%S)})
exten => s,n,rxfax(${ASTSPOOLDIR}/fax/${UNIQUEID}.tif|debug)
exten => h,1,GotoIf($["${FAXSTATUS:0:6}" = “FAILED”]?failed)
exten => h,n(process),GotoIf($[${LEN(${FAX_RX_EMAIL})} = 0]?end)
exten => h,n,System(${ASTVARLIBDIR}/bin/fax-process.pl --to ${FAX_RX_EMAIL} --from "[email protected]" --dest “${FROM_DID}” --subject "New $
exten => h,n,Noop(Fax finish time is: ${STRFTIME(${EPOCH},%b %d %H:%M:%S)})
exten => h,n,Set(FAXFINISHTIME=${STRFTIME(${EPOCH},%b %d %H:%M:%S)})
exten => h,n,System(/var/lib/asterisk/bin/calltrace.sh “${FAXSTARTTIME}” “${FAXFINISHTIME}”)
exten => h,n(end),Macro(hangupcall,)
exten => h,process+101(failed),Noop(FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)})
exten => h,n,Macro(hangupcall,)
I have a bash script in /var/lib/asterisk/bin that looks like this:
It looks in the /var/log/asterisk/full log for the “Fax Finish Time is:” line with an additional timestamp, and pulls the wanted number out of the log.
#!/bin/bash
#will locate a specific calltrace number within the Asterisk full log.
# StartCallTime is passed via $1 and FinishCallTime is passed via $2
#sleep for 3 seconds to let the live log information be written to full.
sleep 3
echo ========================================================= >>/var/log/asterisk/fax-in.log
echo Start Call Time: $1 >>/var/log/asterisk/fax-in.log
A=cat /var/log/asterisk/full |grep "Fax finish time is:" |grep "$2"
#echo $A
#echo ${A##*VERBOSE}
B=echo ${A##*VERBOSE}
CALLNUM=echo ${B:1:7} |sed 's/[^0-9]*//g'
#echo $CALLNUM
cat /var/log/asterisk/full |grep $CALLNUM >>/var/log/asterisk/fax-in.log
echo Finish Fax Time: $2 >>/var/log/asterisk/fax-in.log
I’ve got a rough log of just incoming faxes at this point.