Monitor Trunk Failures - Any Scripts that work well?

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.

declare -a array
while read -e ARG && [ "$ARG" ] ; do
array=(` echo $ARG | sed -e 's/://'`)
export ${array[0]}=${array[1]}
[email protected]

DATE=`date "+%m-%d-%Y %H:%M:%S"`
CHANNEL=`echo $agi_channel`
CID=`echo $agi_callerid`
CIDNAME=`echo $agi_calleridname`
EXTENSION=`echo $agi_extension`
DNID=`echo $agi_dnid`
STATUS=`echo $agi_dialstatus`
CAUSE=`echo $agi_causecode`
HANGUPREASON=`echo $agi_hangupcause`
REPORT="Channel Unavailable"
# 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

I had the same question, and didn’t find much aside from a post on the russian asterisk forums.
Here’s my filthy hack that seems to do the trick (mostly untested):

STATUS=echo $agi_dialstatus
read line

No a script, but check this out. Pretty neat.

It never became public again. I hope it will be released again soon…

Ah! Didn’t realize. It was very nice I thought.

Thank you.

I have tried that with minor changes

STATUS=`echo $agi_dialstatus`
#CAUSE=`echo $agi_causecode`
# Above does not work: To fix bug
read line

(I replaced your left & right double quotes by regular ones and added the single quotes to follow the style my other lines)

Unfortunately, nothing seems to have changed.

i dont think $agi_dialstatus is a valid variable name?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.