Re: [Asterisk-Users] Polycom Reboot Script PRI errors!!

2004-11-29 Thread Christopher L. Wade
Simon Brown wrote:
Has anyone written an equivalent script to remote reboot Cisco 79XX phones?
Simon 

Check the wiki... there are two versions for cisco, one that uses the 
check-sync sip message, the other that simply logs into the phone via 
telnet and 'reset's the phone.  I have made some changes to the latter 
and use it in production along with some other console commands to 
remotely setup things like my intercom line, server push, etc.

Anyway, the wiki link is 
http://www.voip-info.org/wiki-Asterisk+phone+cisco+79xx

If you look about 1/3 way down the page you'll see a link to 'reboot.pl' 
pointing to http://mklein.bendtel.net/mkreboot.pl

That should get you going.
Chris
--
Christopher L. Wade Unistar-Sparco Computers, Inc.
Senior Systems Administratordba Sparco.com
Email: [EMAIL PROTECTED] 7089 Ryburn Drive
Phone: (901) 872 2272 / (800) 840 8400Millington, TN 38053
Fax:   (901) 872 8482  USA
___
Asterisk-Users mailing list
[EMAIL PROTECTED]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] Polycom Reboot Script PRI errors!!

2004-11-29 Thread Simon Brown
Has anyone written an equivalent script to remote reboot Cisco 79XX phones?

Simon 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of John Baker
Sent: Monday, 29 November 2004 17:29
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [Asterisk-Users] Polycom Reboot Script PRI errors!!

Kevin wrote:
> There is a reboot script posted on the wiki to reboot Polycom 
> telephones.  When I execute this script, I get the following messages.
> I am concerned as this is causing issues with asterisk and the PRI.
> Does anyone have any ideas why this would be happening?
> 
> 
> 
> asterisk console:
> 
> -- Remote UNIX connection
> -- Remote UNIX connection disconnected
> 
> and in the Asterisk Log:
> 
> Nov 28 22:30:42 NOTICE[1099909936]: PRI got event: 6 on Primary 
> D-channel of span 1 Nov 28 22:43:08 NOTICE[1099909936]: PRI got event: 
> 6 on Primary D-channel of span 1
> 
> 
> Script:
> 
> #!/usr/bin/perl -w
> 
> use Net::Ping;
> use Socket;
> 
> $polycompath = '/home//';# Where you keep your config files
> $arp = '/sbin/arp';  # Location of arp command
> $sipserver   = '192.168.XXX.XXX';  # IP of asterisk server
> 
> $phone = shift;
> 
> checkphone("$phone");
> touch( arp2config("$phone") );
> 
> reboot_sip_phone( "$phone", "$sipserver", "Reboot" );
> 
> sub checkphone { # Checks for existence of phone, makes sure
>  # it's in arp table
> $activephone = shift;
> 
> # Populate ARP table
> print "Checking ARP table.\n";
> $p = Net::Ping->new("icmp");
> if ( $p->ping( $activephone, 2 ) ) {
> print "$activephone is ";
> print "reachable.\n";
> }
> else { die "Polycom at ", $activephone, " is not reachable!"; }
> sleep(1);
> $p->close();
> 
> }
> 
> sub arp2config {# Gets mac address from arp table, converts
> # to a polycom config filename, makes sure
> # the config file exists
> $arpip = shift;
> open( ARP, "$arp -an|" ) || die "Couldn't open arp table: $!\n";
> print "checking for polycom config name...", "\n";
> while () {
> chomp;
> $addr = $_;
> $ip   = $_;
> $addr =~ s/.*
> ([\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+).*/$1/;
> $addr =~ s/://g;
> $addr = lc($addr) . '.cfg';
> $ip =~ s/.*?(\d+\.\d+\.\d+\.\d+).*/$1/;
> if ( $ip eq $arpip ) {
> last;
> }
> }
> 
> $polycomconfig = "$polycompath" . "$addr";
> 
> unless ( -e "$polycomconfig" ) {
> print "sorry, polycom config file ", "$polycomconfig",
>   " is not found.\n\n";
> exit;
> }
> 
> return $polycomconfig;
> }
> 
> sub touch {# We need to touch the config files or the phone
># won't reboot - it depends on time synchronization
> 
> print "touching config file ", $polycomconfig, "\n";
> my $now = time;
> local (*TMP);
> foreach my $file (@_) {
> utime( $now, $now, $file )
>   || open( TMP, ">>$file" )
>   || die ("$0: Couldn't touch file: $!\n");
> }
> }
> 
> sub reboot_sip_phone {# Send the phone a check-sync to reboot it
> $phone_ip = shift;
> 
> $local_ip = shift;
> $sip_to   = shift;
> $sip_from = "0";
> $tm   = time();
> $call_id  = $tm . "msgto$sip_to";
> $httptime = `date -R`;
> $MESG = "NOTIFY sip:[EMAIL PROTECTED]:5060 SIP/2.0
> Via: SIP/2.0/UDP $local_ip
> From: 
> To: 
> Event: check-sync
> Date: $httptime
> Call-ID: [EMAIL PROTECTED]
> CSeq: 1300 NOTIFY
> Contact: 
> Content-Length: 0
> 
> ";
> 
> $proto = getprotobyname('udp');
> socket( SOCKET, PF_INET, SOCK_DGRAM, $proto );
> $iaddr = inet_aton("$phone_ip");
> $paddr = sockaddr_in( 5060, $iaddr );
> bind( SOCKET, $paddr );
> $port = 5060;
> 
> $hisiaddr = inet_aton($phone_ip);
> $hispaddr = sockaddr_in( $port, $hisiaddr );
> 
> if ( send( SOCKET, $MESG, 0, $hispaddr ) ) {
> print "reboot of phone ", "$phone_ip", " was successful", "\n";
> }
> else { print "reboot of phone &

RE: [Asterisk-Users] Polycom Reboot Script PRI errors!!

2004-11-29 Thread Simon Brown
Kevin wrote:
> There is a reboot script posted on the wiki to reboot Polycom 
> telephones.  When I execute this script, I get the following messages.
> I am concerned as this is causing issues with asterisk and the PRI.
> Does anyone have any ideas why this would be happening?
> 
> 
> 
> asterisk console:
> 
> -- Remote UNIX connection
> -- Remote UNIX connection disconnected
> 
> and in the Asterisk Log:
> 
> Nov 28 22:30:42 NOTICE[1099909936]: PRI got event: 6 on Primary 
> D-channel of span 1 Nov 28 22:43:08 NOTICE[1099909936]: PRI got event: 
> 6 on Primary D-channel of span 1
> 
> 
> Script:
> 
> #!/usr/bin/perl -w
> 
> use Net::Ping;
> use Socket;
> 
> $polycompath = '/home//';# Where you keep your config files
> $arp = '/sbin/arp';  # Location of arp command
> $sipserver   = '192.168.XXX.XXX';  # IP of asterisk server
> 
> $phone = shift;
> 
> checkphone("$phone");
> touch( arp2config("$phone") );
> 
> reboot_sip_phone( "$phone", "$sipserver", "Reboot" );
> 
> sub checkphone { # Checks for existence of phone, makes sure
>  # it's in arp table
> $activephone = shift;
> 
> # Populate ARP table
> print "Checking ARP table.\n";
> $p = Net::Ping->new("icmp");
> if ( $p->ping( $activephone, 2 ) ) {
> print "$activephone is ";
> print "reachable.\n";
> }
> else { die "Polycom at ", $activephone, " is not reachable!"; }
> sleep(1);
> $p->close();
> 
> }
> 
> sub arp2config {# Gets mac address from arp table, converts
> # to a polycom config filename, makes sure
> # the config file exists
> $arpip = shift;
> open( ARP, "$arp -an|" ) || die "Couldn't open arp table: $!\n";
> print "checking for polycom config name...", "\n";
> while () {
> chomp;
> $addr = $_;
> $ip   = $_;
> $addr =~ s/.*
> ([\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+).*/$1/;
> $addr =~ s/://g;
> $addr = lc($addr) . '.cfg';
> $ip =~ s/.*?(\d+\.\d+\.\d+\.\d+).*/$1/;
> if ( $ip eq $arpip ) {
> last;
> }
> }
> 
> $polycomconfig = "$polycompath" . "$addr";
> 
> unless ( -e "$polycomconfig" ) {
> print "sorry, polycom config file ", "$polycomconfig",
>   " is not found.\n\n";
> exit;
> }
> 
> return $polycomconfig;
> }
> 
> sub touch {# We need to touch the config files or the phone
># won't reboot - it depends on time synchronization
> 
> print "touching config file ", $polycomconfig, "\n";
> my $now = time;
> local (*TMP);
> foreach my $file (@_) {
> utime( $now, $now, $file )
>   || open( TMP, ">>$file" )
>   || die ("$0: Couldn't touch file: $!\n");
> }
> }
> 
> sub reboot_sip_phone {# Send the phone a check-sync to reboot it
> $phone_ip = shift;
> 
> $local_ip = shift;
> $sip_to   = shift;
> $sip_from = "0";
> $tm   = time();
> $call_id  = $tm . "msgto$sip_to";
> $httptime = `date -R`;
> $MESG = "NOTIFY sip:[EMAIL PROTECTED]:5060 SIP/2.0
> Via: SIP/2.0/UDP $local_ip
> From: 
> To: 
> Event: check-sync
> Date: $httptime
> Call-ID: [EMAIL PROTECTED]
> CSeq: 1300 NOTIFY
> Contact: 
> Content-Length: 0
> 
> ";
> 
> $proto = getprotobyname('udp');
> socket( SOCKET, PF_INET, SOCK_DGRAM, $proto );
> $iaddr = inet_aton("$phone_ip");
> $paddr = sockaddr_in( 5060, $iaddr );
> bind( SOCKET, $paddr );
> $port = 5060;
> 
> $hisiaddr = inet_aton($phone_ip);
> $hispaddr = sockaddr_in( $port, $hisiaddr );
> 
> if ( send( SOCKET, $MESG, 0, $hispaddr ) ) {
> print "reboot of phone ", "$phone_ip", " was successful", "\n";
> }
> else { print "reboot of phone ", "$phone_ip", " failed", "\n"; }
> 
> }
> exit;
> 
> ___
> Asterisk-Users mailing list
> [EMAIL PROTECTED]
> http://lists.digium.com/mailman/listinfo/asterisk-users
> To UNSUBSCRIBE or update options visit:
>http://lists.digium.com/mailman/listinfo/asterisk-users
> 
> 


Kevin -

I rewrote this some time ago because of some issues with Polycom's latest
bootroom/sip update.  Try this:

Also, serctl, part of the ser package, has a cisco_restart parameter that
works on Polycoms as well.

John



#!/usr/bin/perl -w

use Net::Ping;
use Socket;

$polycompath = '/home/PlcmSpIp/';# Where you keep your polycom files
$arp = '/sbin/arp';  # Location of arp command
$sipserver   = '192.168.XXX.XXX';  # IP of asterisk server

$phone = shift;

checkphone("$phone");
touch( arp2config("$phone") );

reboot_sip_phone( "$phone", "$sipserver", get_extension($phone) );

sub checkphone { # Checks for existence of phone, 
makes sure
 # it's in arp table
 $activephone = shift;

 # Populate ARP table
 print "Checking ARP table.\n";
 $p = Net::Ping->new("icmp");
 if

Re: [Asterisk-Users] Polycom Reboot Script PRI errors!!

2004-11-28 Thread John Baker
Kevin wrote:
There is a reboot script posted on the wiki to reboot Polycom
telephones.  When I execute this script, I get the following messages.
I am concerned as this is causing issues with asterisk and the PRI.
Does anyone have any ideas why this would be happening?

asterisk console:
-- Remote UNIX connection
-- Remote UNIX connection disconnected
and in the Asterisk Log:
Nov 28 22:30:42 NOTICE[1099909936]: PRI got event: 6 on Primary
D-channel of span 1
Nov 28 22:43:08 NOTICE[1099909936]: PRI got event: 6 on Primary
D-channel of span 1
Script:
#!/usr/bin/perl -w
use Net::Ping;
use Socket;
$polycompath = '/home//';# Where you keep your config files
$arp = '/sbin/arp';  # Location of arp command
$sipserver   = '192.168.XXX.XXX';  # IP of asterisk server
$phone = shift;
checkphone("$phone");
touch( arp2config("$phone") );
reboot_sip_phone( "$phone", "$sipserver", "Reboot" );
sub checkphone { # Checks for existence of phone, makes sure
 # it's in arp table
$activephone = shift;
# Populate ARP table
print "Checking ARP table.\n";
$p = Net::Ping->new("icmp");
if ( $p->ping( $activephone, 2 ) ) {
print "$activephone is ";
print "reachable.\n";
}
else { die "Polycom at ", $activephone, " is not reachable!"; }
sleep(1);
$p->close();
}
sub arp2config {# Gets mac address from arp table, converts
# to a polycom config filename, makes sure
# the config file exists
$arpip = shift;
open( ARP, "$arp -an|" ) || die "Couldn't open arp table: $!\n";
print "checking for polycom config name...", "\n";
while () {
chomp;
$addr = $_;
$ip   = $_;
$addr =~ s/.*
([\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+).*/$1/;
$addr =~ s/://g;
$addr = lc($addr) . '.cfg';
$ip =~ s/.*?(\d+\.\d+\.\d+\.\d+).*/$1/;
if ( $ip eq $arpip ) {
last;
}
}
$polycomconfig = "$polycompath" . "$addr";
unless ( -e "$polycomconfig" ) {
print "sorry, polycom config file ", "$polycomconfig",
  " is not found.\n\n";
exit;
}
return $polycomconfig;
}
sub touch {# We need to touch the config files or the phone
   # won't reboot - it depends on time synchronization
print "touching config file ", $polycomconfig, "\n";
my $now = time;
local (*TMP);
foreach my $file (@_) {
utime( $now, $now, $file )
  || open( TMP, ">>$file" )
  || die ("$0: Couldn't touch file: $!\n");
}
}
sub reboot_sip_phone {# Send the phone a check-sync to reboot it
$phone_ip = shift;
$local_ip = shift;
$sip_to   = shift;
$sip_from = "0";
$tm   = time();
$call_id  = $tm . "msgto$sip_to";
$httptime = `date -R`;
$MESG = "NOTIFY sip:[EMAIL PROTECTED]:5060 SIP/2.0
Via: SIP/2.0/UDP $local_ip
From: 
To: 
Event: check-sync
Date: $httptime
Call-ID: [EMAIL PROTECTED]
CSeq: 1300 NOTIFY
Contact: 
Content-Length: 0
";
$proto = getprotobyname('udp');
socket( SOCKET, PF_INET, SOCK_DGRAM, $proto );
$iaddr = inet_aton("$phone_ip");
$paddr = sockaddr_in( 5060, $iaddr );
bind( SOCKET, $paddr );
$port = 5060;
$hisiaddr = inet_aton($phone_ip);
$hispaddr = sockaddr_in( $port, $hisiaddr );
if ( send( SOCKET, $MESG, 0, $hispaddr ) ) {
print "reboot of phone ", "$phone_ip", " was successful", "\n";
}
else { print "reboot of phone ", "$phone_ip", " failed", "\n"; }
}
exit;
___
Asterisk-Users mailing list
[EMAIL PROTECTED]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Kevin -
I rewrote this some time ago because of some issues with Polycom's 
latest bootroom/sip update.  Try this:

Also, serctl, part of the ser package, has a cisco_restart parameter 
that works on Polycoms as well.

John

#!/usr/bin/perl -w
use Net::Ping;
use Socket;
$polycompath = '/home/PlcmSpIp/';# Where you keep your polycom files
$arp = '/sbin/arp';  # Location of arp command
$sipserver   = '192.168.XXX.XXX';  # IP of asterisk server
$phone = shift;
checkphone("$phone");
touch( arp2config("$phone") );
reboot_sip_phone( "$phone", "$sipserver", get_extension($phone) );
sub checkphone { # Checks for existence of phone, 
makes sure
# it's in arp table
$activephone = shift;

# Populate ARP table
print "Checking ARP table.\n";
$p = Net::Ping->new("icmp");
if ( $p->ping( $activephone, 2 ) ) {
print "$activephone is ";
print "reachable.\n";
}
else { die "Polycom at ", $activephone, " is not reachable!"; }
sleep(1);
$p->close();
}
sub arp2config {# Gets mac address from arp table, converts
# to a polycom config filename, makes sure
   

[Asterisk-Users] Polycom Reboot Script PRI errors!!

2004-11-28 Thread Kevin
There is a reboot script posted on the wiki to reboot Polycom
telephones.  When I execute this script, I get the following messages.
I am concerned as this is causing issues with asterisk and the PRI.
Does anyone have any ideas why this would be happening?



asterisk console:

-- Remote UNIX connection
-- Remote UNIX connection disconnected

and in the Asterisk Log:

Nov 28 22:30:42 NOTICE[1099909936]: PRI got event: 6 on Primary
D-channel of span 1
Nov 28 22:43:08 NOTICE[1099909936]: PRI got event: 6 on Primary
D-channel of span 1


Script:

#!/usr/bin/perl -w

use Net::Ping;
use Socket;

$polycompath = '/home//';# Where you keep your config files
$arp = '/sbin/arp';  # Location of arp command
$sipserver   = '192.168.XXX.XXX';  # IP of asterisk server

$phone = shift;

checkphone("$phone");
touch( arp2config("$phone") );

reboot_sip_phone( "$phone", "$sipserver", "Reboot" );

sub checkphone { # Checks for existence of phone, makes sure
 # it's in arp table
$activephone = shift;

# Populate ARP table
print "Checking ARP table.\n";
$p = Net::Ping->new("icmp");
if ( $p->ping( $activephone, 2 ) ) {
print "$activephone is ";
print "reachable.\n";
}
else { die "Polycom at ", $activephone, " is not reachable!"; }
sleep(1);
$p->close();

}

sub arp2config {# Gets mac address from arp table, converts
# to a polycom config filename, makes sure
# the config file exists
$arpip = shift;
open( ARP, "$arp -an|" ) || die "Couldn't open arp table: $!\n";
print "checking for polycom config name...", "\n";
while () {
chomp;
$addr = $_;
$ip   = $_;
$addr =~ s/.*
([\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+:[\d\w]+).*/$1/;
$addr =~ s/://g;
$addr = lc($addr) . '.cfg';
$ip =~ s/.*?(\d+\.\d+\.\d+\.\d+).*/$1/;
if ( $ip eq $arpip ) {
last;
}
}

$polycomconfig = "$polycompath" . "$addr";

unless ( -e "$polycomconfig" ) {
print "sorry, polycom config file ", "$polycomconfig",
  " is not found.\n\n";
exit;
}

return $polycomconfig;
}

sub touch {# We need to touch the config files or the phone
   # won't reboot - it depends on time synchronization

print "touching config file ", $polycomconfig, "\n";
my $now = time;
local (*TMP);
foreach my $file (@_) {
utime( $now, $now, $file )
  || open( TMP, ">>$file" )
  || die ("$0: Couldn't touch file: $!\n");
}
}

sub reboot_sip_phone {# Send the phone a check-sync to reboot it
$phone_ip = shift;

$local_ip = shift;
$sip_to   = shift;
$sip_from = "0";
$tm   = time();
$call_id  = $tm . "msgto$sip_to";
$httptime = `date -R`;
$MESG = "NOTIFY sip:[EMAIL PROTECTED]:5060 SIP/2.0
Via: SIP/2.0/UDP $local_ip
From: 
To: 
Event: check-sync
Date: $httptime
Call-ID: [EMAIL PROTECTED]
CSeq: 1300 NOTIFY
Contact: 
Content-Length: 0

";

$proto = getprotobyname('udp');
socket( SOCKET, PF_INET, SOCK_DGRAM, $proto );
$iaddr = inet_aton("$phone_ip");
$paddr = sockaddr_in( 5060, $iaddr );
bind( SOCKET, $paddr );
$port = 5060;

$hisiaddr = inet_aton($phone_ip);
$hispaddr = sockaddr_in( $port, $hisiaddr );

if ( send( SOCKET, $MESG, 0, $hispaddr ) ) {
print "reboot of phone ", "$phone_ip", " was successful", "\n";
}
else { print "reboot of phone ", "$phone_ip", " failed", "\n"; }

}
exit;

___
Asterisk-Users mailing list
[EMAIL PROTECTED]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users