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
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);