I’m migrating over from my old 2.11 to a current system and cannot find any recent scripts.
So I have taken my old script (I think 2009 vintage written for PIAF). That script did not do everything that it was supposed to but it was usable.
It works basically as before but it now does not show the number being dialed - it always appears as unknown.
The code is as below.
On the 2.11 system $DNID contained the outgoing number and now it is always ‘unknown’
An example of an old system message:
A call from channel [SIP/211-0000040e]
With CID : [unknown] - [02088889999]
has failed on host [pbxunique.local] at 05-17-2018 16:20:59
Number that was dialed : [0022334455667788] on trunk [???]
with error : [] and hangup cause is : []
while on the current system we get
A call from channel [PJSIP/233-0000056e]
With CID : [unknown] - [02088889999]
has failed on host [F-PBX-A14-03] at 05-10-2018 13:07:50
Number that was dialed : [unknown] on trunk [???]
with error : [] and hangup cause is : []
Not having the called number show up is a major issue for us.
It would also be nice if the $STATUS and $CAUSE fields could be made to work.
Same for the trunk name, but from what I have seem elsewhere getting the trunk name is not trivial though it must be possible.
#!/bin/bash
declare -a array
while read -e ARG && [ "$ARG" ] ; do
array=(` echo $ARG | sed -e 's/://'`)
export ${array[0]}=${array[1]}
done
[email protected]
DATE=`date "+%m-%d-%Y %H:%M:%S"`
CHANNEL=`echo $agi_channel`
CID=`echo $agi_callerid`
CIDNAME=`echo $agi_calleridname`
HOST=`hostname`
EXTENSION=`echo $agi_extension`
DNID=`echo $agi_dnid`
STATUS=`echo $agi_dialstatus`
CAUSE=`echo $agi_causecode`
HANGUPREASON=`echo $agi_hangupcause`
REASON=${REASON}
REPORT=$EXTENSION
if [ "$EXTENSION" = "s-CHANUNAVAIL" ]
then
REPORT="Channel Unavailable"
fi
# Message Formating
MSG="\n\n A call from channel [$CHANNEL] \n"
MSG="$MSG With CID : [$CIDNAME] - [$CID] \n\n"
MSG="$MSG has failed on host [$HOST] at $DATE \n\n"
MSG="$MSG Number that was dialled : [$DNID] on trunk [???] \n\n"
MSG="$MSG with error : Status: [$STATUS] and hangup cause is : [$CAUSE] \n\n"
MSG="$MSG Hangup reason : [$HANGUPREASON] \n\n"
MSG="$MSG Reason : [$REASON] \n\n"
MSG="$MSG Extension : [$REPORT] \n\n"
# Create log for emailing
echo >> /var/log/asterisk/trunkfailure.log
echo -e "$MSG" >> /var/log/asterisk/trunkfailure.log
# Send an email
(echo -e "$MSG" | mail -s " Failed call on host [$HOST] - dialling [$DNID] - " "$EMAIL" &) | nohup