edisoninfo
Guru
- Joined
- Nov 19, 2007
- Messages
- 505
- Reaction score
- 4
Did you create the trunkalerts_iax.conf file? You may not have any IAX trunks but you still need to create the file I think.
Could you please post the contents of the trunkalerts_sip.conf and trunkalerts_iax.conf in /etc/asterisk
My Line 18 is
open(SIPTRUNKS,"/etc/asterisk/siptrunks");
Have you added another line ?
Who owns the iax and sip files?
OK
Can you post the two lines you have with IAXTRUNKS and SIPTRUNKS Please.
The only issues I ever had was in the email area.
#!/usr/bin/perl -w
use strict;
use warnings;
#no warnings; #Remark out to suppress ALL warnings, also add remark to above line.
################################################## ##################################################
####
#### 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
####
################################################## ##################################################
####
#### Script modified by Charles Pippin Feb 21st 2009 - Added counters for loop retry.
#### if there is any questions please feel free to drop me an email at cwpippin at domain gmail.com
####
################################################## ##################################################
####
#### 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".
####
################################################## ##################################################
####
#### SIP Related Code
####
#print "=============================================\n";
#print "SIP Trunk information\n";
#print "=============================================\n";
open(SIPTRUNKS,"</etc/asterisk/trunkalerts_sip.conf");
while (<SIPTRUNKS>) {
chomp;
my $upcounter = 5;
my $dncounter = 5;
until ($upcounter == 0) {
my $siptrunks = `/usr/sbin/asterisk -rx "sip show registry" | grep \"$_\" | awk '{
print \$4
}
'`;
#print "siptrunks = $siptrunks\n"; #Remove remark to see output from "sip show registry" command
if ($siptrunks =~ "Registered") {
$upcounter = $upcounter - 1;
#print $upcounter,"\n"; #Remove remark to see counter decrement
#print "$_ is up\n" ; #Remove remark to see notification of trunk being "UP"
}
else {
$dncounter = $dncounter - 1;
#print $dncounter,"\n"; #Remove remark to see counter decrement once trunk is found to be down
#print "$_ is down\n" ; #Remove remark to see notification of trunk being "DOWN"
if ($dncounter == 0) {
mailalert();
$upcounter = 0;
#print $upcounter,"\n"; #Remove remark to see counter decrement once trunk is found to be down
print "houston we have a problem\n";
print "$_ trunk is not registering\n";
}
}
}
}
#end of while loop (read SIP file)
################################################## ##################################################
####
#### IAX Related Code
####
#print "\n\n";
#print "=============================================\n";
#print "IAX2 Trunk information\n";
#print "=============================================\n";
open(IAXTRUNKS,"</etc/asterisk/trunkalerts_iax.conf");
while (<IAXTRUNKS>) {
chomp;
my $upcounter = 5;
my $dncounter = 5;
until ($upcounter == 0) {
my $iaxtrunks = `/usr/sbin/asterisk -rx "iax2 show registry" |/bin/grep \"$_\" | awk '{
print \$5
}
'`;
#print "iaxtrunks = $iaxtrunks\n"; #Remove remark to see output from "iax2 show registry" command
if ($iaxtrunks =~ "Registered") {
$upcounter = $upcounter - 1;
#print $counter,"\n"; #Remove remark to see counter decrement
#print "$_ is up\n" ; #Remove remark to see notification of trunk being "UP"
}
else {
$dncounter = $dncounter - 1;
#print $dncounter,"\n"; #Remove remark to see counter decrement once trunk is found to be down
#print "$_ is down\n" ; #Remove remark to see notification of trunk being "DOWN"
if ($dncounter == 0) {
mailalert();
$upcounter = 0;
#print $upcounter,"\n"; #Remove remark to see counter decrement once trunk is found to be down
print "houston we have a problem\n";
print "$_ trunk is not registering\n";
my $subject = "Subject: TRUNK $iaxtrunks is DOWN!!!!\n";
my $content = "TRUNK $iaxtrunks is DOWN!!!!\n";
}
}
}
}
#end of while loop (read IAX file)
################################################## ##################################################
####
#### Email Subroutines
#### Change anywhere below where there is an email address an email addres
#### must have \@ as perl needs to escape the @ symbol
####
################################################## ##################################################
sub mailalert {
my $sendmail = "/usr/sbin/sendmail -t";
my $from= "FROM: <pbx\@YOURCOMPANYNAME.com>\n";
my $reply_to = "Reply-to: <pbx\@YOURCOMPANYNAME.com\n";
my $subject = "Subject: $_ is DOWN!!!!\n";
my $content = "PBX TRUNK $_ is DOWN!!!!\n";
my $send_to = "To:<YOU\@YOUREMAILADDRESS.com>\n";
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL $from;
print SENDMAIL $reply_to;
print SENDMAIL $subject;
print SENDMAIL $send_to;
print SENDMAIL $content;
close(SENDMAIL);
print "An email has been sent!\n\n";
}
#!/usr/bin/perl -w
use strict;
use warnings;
#no warnings; #Remark out to suppress ALL warnings, also add remark to above line.
################################################## ##################################################
####
#### 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
####
################################################## ##################################################
####
#### Script modified by Charles Pippin Feb 21st 2009 - Added counters for loop retry.
#### if there is any questions please feel free to drop me an email at cwpippin at domain gmail.com
####
################################################## ##################################################
####
#### 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".
####
################################################## ##################################################
####
#### SIP Related Code
####
#print "=============================================\n";
#print "SIP Trunk information\n";
#print "=============================================\n";
open(SIPTRUNKS,"/etc/asterisk/trunkalerts_sip.conf");
while (<SIPTRUNKS>) {
chomp;
my $upcounter = 5;
my $dncounter = 5;
until ($upcounter == 0) {
my $siptrunks = `/usr/sbin/asterisk -rx "sip show registry" | grep \"$_\" | awk '{
print \$5
}
'`;
#print "siptrunks = $siptrunks\n"; #Remove remark to see output from "sip show registry" command
if ($siptrunks =~ "Registered") {
$upcounter = $upcounter - 1;
#print $upcounter,"\n"; #Remove remark to see counter decrement
#print "$_ is up\n" ; #Remove remark to see notification of trunk being "UP"
}
else {
$dncounter = $dncounter - 1;
#print $dncounter,"\n"; #Remove remark to see counter decrement once trunk is found to be down
#print "$_ is down\n" ; #Remove remark to see notification of trunk being "DOWN"
if ($dncounter == 0) {
mailalert();
$upcounter = 0;
#print $upcounter,"\n"; #Remove remark to see counter decrement once trunk is found to be down
print "houston we have a problem\n";
print "$_ trunk is not registering\n";
}
}
}
}
#end of while loop (read SIP file)
################################################## ##################################################
####
#### IAX Related Code
####
#print "\n\n";
#print "=============================================\n";
#print "IAX2 Trunk information\n";
#print "=============================================\n";
open(IAXTRUNKS,"/etc/asterisk/trunkalerts_iax.conf");
while (<IAXTRUNKS>) {
chomp;
my $upcounter = 5;
my $dncounter = 5;
until ($upcounter == 0) {
my $iaxtrunks = `/usr/sbin/asterisk -rx "iax2 show registry" |/bin/grep \"$_\" | awk '{
print \$6
}
'`;
#print "iaxtrunks = $iaxtrunks\n"; #Remove remark to see output from "iax2 show registry" command
if ($iaxtrunks =~ "Registered") {
$upcounter = $upcounter - 1;
#print "$upcounter\n"; #Remove remark to see counter decrement
#print "$_ is up\n" ; #Remove remark to see notification of trunk being "UP"
}
else {
$dncounter = $dncounter - 1;
#print $dncounter,"\n"; #Remove remark to see counter decrement once trunk is found to be down
#print "$_ is down\n" ; #Remove remark to see notification of trunk being "DOWN"
if ($dncounter == 0) {
#mailalert();
$upcounter = 0;
#print $upcounter,"\n"; #Remove remark to see counter decrement once trunk is found to be down
print "Erreur:\n";
print "$_ trunk is not registering\n";
print "Nous allons reloader les modules\n";
print `asterisk -rx "restart when convenient"\n`;
print `echo -e Solutions Nursing Mtl trunk is DOWN, Nous avons fais un reload de module. | mail -s "Solutions Nursing Mtl trunk have failed" speedy_2k2\@hotmail.com\n`;
my $subject = "Subject: TRUNK $iaxtrunks is DOWN!!!!\n";
my $content = "TRUNK $iaxtrunks is DOWN!!!!\n";
}
}
}
}
#end of while loop (read IAX file)
################################################## ##################################################
####
#### Email Subroutines
#### Change anywhere below where there is an email address an email addres
#### must have \@ as perl needs to escape the @ symbol
####
################################################## ##################################################
sub mailalert {
my $sendmail = "/usr/sbin/sendmail -t";
my $from= "FROM: <pbx\@solutionsnursing.ca>\n";
my $reply_to = "Reply-to: <pbx\@solutionsnursing.ca\n";
my $subject = "Subject: $_ is DOWN!!!!\n";
my $content = "PBX TRUNK $_ is DOWN!!!!\n";
my $send_to = "To:<speedy_2k2\@hotmail.com.com>\n";
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL $from;
print SENDMAIL $reply_to;
print SENDMAIL $subject;
print SENDMAIL $send_to;
print SENDMAIL $content;
close(SENDMAIL);
print "An email has been sent!\n\n";
}
Link up your team and customers Phone System Live Chat Video Conferencing
Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.
Check your inbox!
We’ve sent you an email. Click on the button in the email body to verify your email address – (if you can not find it, check your spam folder).
Upon verification you will be directed to the 3CX setup wizard.