Hi I got the script as follows and it works on SIP AND IAX TRUNKS
ZAP TRUNKS IS NOT WORKING
#!/usr/bin/perl
################################################## ################################################## ###########################
Trunk Alerts script written by Jim Hribnak Oct 7th 2007
if there is any questions please feel free to drop me an email at jimh at domain nucleus.com
Called using Cron job
################################################## ################################################## ###########################
Create the following 2 files in /etc/asterisk
in the files below add the hosts entry from asterisk -rx “sip show registry” and
from asterisk -rx “iax2 show registry”.
open(IAXTRUNKS,"/etc/asterisk/trunkalerts_iax.txt");
open(SIPTRUNKS,"/etc/asterisk/trunkalerts_sip.txt");
open(ZAPTRUNKS,"/etc/asterisk/trunkalerts_zap.txt");
################################################## ################################################## ###########################
ZAP Related Code
#print “================================================= ===========\n”;
#print “ZAP Trunk information\n”;
#print “================================================= ===========\n”;
while () {
chomp;
$zaptrunks = /usr/sbin/asterisk -rx "dahdi show status" |grep \"$_\" | awk '{print $2}'
;
print “zaptrunks = $zaptrunks\n”;
if ($zaptrunks =~ “OK”) {
print “$_ is up\n” ;
} else {
print “We have a problem\n”;
print “$_ trunk is not registering\n”;
mailalert();
}
} #end of while loop (read ZAP file)
and when i ran the script as follows
root@asterisk]# /var/lib/asterisk/agi-bin/trunkmonitor
I get the following results below:
zaptrunks =
We have a problem
trunk is not registering
An email has been sent!
zaptrunks =
We have a problem
trunk is not registering
An email has been sent!
zaptrunks =
We have a problem
trunk is not registering
An email has been sent!
zaptrunks =
We have a problem
trunk is not registering
An email has been sent!
i have text file as follows:
vim /etc/asterisk/trunkalerts_zap.txt
T4XXP (PCI) Card 0 Span 1
T4XXP (PCI) Card 0 Span 2
T4XXP (PCI) Card 0 Span 3
T4XXP (PCI) Card 0 Span 4