Asterisk Manager API Action SIPpeers

Action: Sippeers

Show the list of the peers

Response: Success
Message: Peer status list will follow

Event: PeerEntry
Channeltype: SIP
ObjectName: 9915057
ChanObjectType: peer
IPaddress: 10.64.72.166
IPport: 5060
Dynamic: yes
Natsupport: no
ACL: no
Status: OK (5 ms)

Event: PeerEntry
Channeltype: SIP
ObjectName: 9965168
ChanObjectType: peer
IPaddress: 10.64.78.158
IPport: 5060
Dynamic: yes
Natsupport: no
ACL: no
Status: OK (4 ms)

...


Event: PeerlistComplete
ListItems: 205

Example in Perl, tested on Asterisk 1.6.2.9

use Asterisk::Manager;
#
# Connect to Asterisk
#
my
  $asterisk = new Asterisk::Manager;
$asterisk->user('<username>');
$asterisk->secret('<password>');
$asterisk->host('<hostname>');
$asterisk->connect
  || die "Could not connect to Asterisk on <hostname>: ", $asterisk->error, "\n";
#
# Get connected peers
my
  @peer_response = $asterisk->sendcommand(Action=>'SIPPeers');
print "Peers:\n";
foreach( @peer_response )
{
  print "$_\n";
}
#
# Get each peer
while( 1 )
{
  my
    @peer = $asterisk->read_response;
  last
    if $peer[0] =~ /PeerlistComplete/;
  print "\nPeer:\n";
  foreach ( @peer )
  {
    print "$_\n";
  }
}
exit(0);


Action: Sippeers

Show the list of the peers

Response: Success
Message: Peer status list will follow

Event: PeerEntry
Channeltype: SIP
ObjectName: 9915057
ChanObjectType: peer
IPaddress: 10.64.72.166
IPport: 5060
Dynamic: yes
Natsupport: no
ACL: no
Status: OK (5 ms)

Event: PeerEntry
Channeltype: SIP
ObjectName: 9965168
ChanObjectType: peer
IPaddress: 10.64.78.158
IPport: 5060
Dynamic: yes
Natsupport: no
ACL: no
Status: OK (4 ms)

...


Event: PeerlistComplete
ListItems: 205

Example in Perl, tested on Asterisk 1.6.2.9

use Asterisk::Manager;
#
# Connect to Asterisk
#
my
  $asterisk = new Asterisk::Manager;
$asterisk->user('<username>');
$asterisk->secret('<password>');
$asterisk->host('<hostname>');
$asterisk->connect
  || die "Could not connect to Asterisk on <hostname>: ", $asterisk->error, "\n";
#
# Get connected peers
my
  @peer_response = $asterisk->sendcommand(Action=>'SIPPeers');
print "Peers:\n";
foreach( @peer_response )
{
  print "$_\n";
}
#
# Get each peer
while( 1 )
{
  my
    @peer = $asterisk->read_response;
  last
    if $peer[0] =~ /PeerlistComplete/;
  print "\nPeer:\n";
  foreach ( @peer )
  {
    print "$_\n";
  }
}
exit(0);


Created by: cripiland, Last modification: Tue 23 of Nov, 2010 (03:27 UTC) by rajmathur
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+