{"id":139,"date":"2016-06-03T18:51:51","date_gmt":"2016-06-03T18:51:51","guid":{"rendered":"http:\/\/symbioticindia.in\/docu\/?p=139"},"modified":"2016-06-03T18:57:09","modified_gmt":"2016-06-03T18:57:09","slug":"agi-script-for-trunk-failure-alert-via-email-in-freepbx","status":"publish","type":"post","link":"http:\/\/symbioticindia.in\/docu\/2016\/06\/03\/agi-script-for-trunk-failure-alert-via-email-in-freepbx\/","title":{"rendered":"agi script for trunk failure alert via email in freepbx"},"content":{"rendered":"<div class=\"article-header\"><\/div>\n<div class=\"article-content entry-content\">\n<div dir=\"ltr\">\n<div class=\"separator\"><\/div>\n<div dir=\"ltr\">1.go to agi dir \u00a0cd \u00a0\/var\/lib\/asterisk\/agi-bin<br \/>\n2.create a agi file \u00a0for eg: \u00a0alert.agi<br \/>\n3.copy the below script to the alert.agi<br \/>\n4.give permission \u00a0chmod 755 alert.agi<a name=\"more\"><\/a><br \/>\n5.now go to freepbx =&gt; trunk=&gt;select your trunk=&gt;select enable for\u00a0Monitor Trunk Failures:<\/p>\n<div class=\"separator\"><\/div>\n<div class=\"separator\"><a href=\"http:\/\/3.bp.blogspot.com\/-ajh3uQgRZb0\/TdE6d6gwGAI\/AAAAAAAAABw\/tyqFRuS9D7k\/s1600\/trunkfailure.JPG\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/3.bp.blogspot.com\/-ajh3uQgRZb0\/TdE6d6gwGAI\/AAAAAAAAABw\/tyqFRuS9D7k\/s320\/trunkfailure.JPG\" width=\"320\" height=\"57\" border=\"0\" \/><\/a><\/div>\n<p>script<\/p>\n<p>#!\/bin\/bash<\/p>\n<p>DATE=`date &#8220;+%d.%m.%Y. %H:%M&#8221;`<br \/>\nHOST=`hostname`<br \/>\n# initializing agi variables<br \/>\ndeclare -a array<br \/>\nwhile read -e ARG &amp;&amp; [ &#8220;$ARG&#8221; ] ; do<br \/>\narray=(` echo $ARG | sed -e &#8216;s\/:\/\/&#8217;`)<br \/>\nexport ${array[0]}=${array[1]}<br \/>\ndone<\/p>\n<p>MESSAGE=&#8221;Incident happend $DATE.\\n$agi_calleridname [$agi_callerid] tried to dial number $agi_dnid.\\nCall could not be established on channel $agi_channel.&#8221;<br \/>\n# write log<br \/>\necho &#8220;$DATE Call could not be established. $agi_calleridname [$agi_callerid] &#8211;&gt; $agi_dnid&#8221; &gt;&gt; \/var\/log\/asterisk\/trunk<br \/>\n# send email<br \/>\necho -e &#8220;$MESSAGE&#8221; | mail -s &#8220;PRI DOWN AT SYNERGY $HOST IP-PBX&#8221; yourname@gmail.com &#8212; -F &#8220;AsteriskPRIAlert&#8221;<\/p>\n<p>note: \u00a0change the yourname@gmail.com with you emailid<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1.go to agi dir \u00a0cd \u00a0\/var\/lib\/asterisk\/agi-bin 2.create a agi file \u00a0for eg: \u00a0alert.agi 3.copy the below script to the alert.agi 4.give permission \u00a0chmod 755 alert.agi 5.now go to freepbx =&gt; trunk=&gt;select your trunk=&gt;select enable for\u00a0Monitor Trunk Failures: script #!\/bin\/bash DATE=`date &#8220;+%d.%m.%Y. %H:%M&#8221;` HOST=`hostname` # initializing agi variables declare -a array while read -e ARG &amp;&amp; ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"http:\/\/symbioticindia.in\/docu\/2016\/06\/03\/agi-script-for-trunk-failure-alert-via-email-in-freepbx\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-139","post","type-post","status-publish","format-standard","hentry","category-asterisk"],"_links":{"self":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/comments?post=139"}],"version-history":[{"count":2,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/139\/revisions"}],"predecessor-version":[{"id":141,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/posts\/139\/revisions\/141"}],"wp:attachment":[{"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/symbioticindia.in\/docu\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}