Hosted Vicidial server starts from $39 Contact Us Buy Now!

agi script email alert trunk fail

Estimated read time: 1 min

Description: asterisk agi script to alert trunk failure over email 


asterisk-agi-trunk-status


1.go to agi dir  cd  /var/lib/asterisk/agi-bin
2.create a agi file  for eg:  alert.agi
3.copy the below script to the alert.agi
4.give permission  chmod 755 alert.agi


5.now go to freepbx => trunk=>select your trunk=>select enable for Monitor Trunk Failures:

trunk failure alert freepbx







script

#!/bin/bash

DATE=`date "+%d.%m.%Y. %H:%M"`
HOST=`hostname`
# initializing agi variables
declare -a array
while read -e ARG && [ "$ARG" ] ; do
array=(` echo $ARG | sed -e 's/://'`)
export ${array[0]}=${array[1]}
done

MESSAGE="Incident happend $DATE.\n$agi_calleridname [$agi_callerid] tried to dial number $agi_dnid.\nCall could not be established on channel $agi_channel."
# write log
echo "$DATE Call could not be established. $agi_calleridname [$agi_callerid] --> $agi_dnid" >> /var/log/asterisk/trunk
# send email
echo -e "$MESSAGE" | mail -s "PRI DOWN AT SYNERGY $HOST IP-PBX" yourname@gmail.com -- -F "AsteriskPRIAlert"



note:  change the yourname@gmail.com with you emailid

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.