3

Asterisk Call Manager/1.3 .After login I am able to retrieve all peer detail as a string.

fwrite($socket, "Action: Command\r\n");
fwrite($socket, "Command: sip show peer ".$sip_no."\r\n\r\n");

I need to know whether the channel is busy or not.

How Can I get only the status like

function checkstatus(sip_no){
   .....
  return status;
}

Based on the status I need to do further processing.

Arun Unnikrishnan
  • 2,339
  • 2
  • 25
  • 39

1 Answers1

4

You can query the Asterisk manager and get a response for each of your peers, using the sip command, in your case, i.e.:

sip show peer PEERNAME

Where PEERNAME is the name of your peer.

Here's a page with an example script for this:

http://www.venturevoip.com/news.php?rssid=2217

Filippos Karapetis
  • 4,367
  • 21
  • 39
  • Thanks.I searched a lot but didn't come across this document.let me play with this code. – Arun Unnikrishnan Jun 18 '13 at 15:37
  • 1
    note, use something like described is BAD BAD BAD idea. Asterisk can hangs if you use alot of such requests(bugs maybe?) correct solution - check AMI events and maintain info about channels, like asternic.org FOP panel do. – arheops Jun 19 '13 at 04:59
  • 4
    You're much better off using the actual AMI command that perform those functions, rather than using the CLI command over AMI approach. Exposing the command class authorization is generally not a good idea, as it gives the ability for any remotely connected client the ability to execute CLI commands on your system. Peer Status: https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerAction_SIPpeerstatus Channels: https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerAction_CoreShowChannels – Matt Jordan Jun 20 '13 at 03:57