[asterisk-users] How does AMI work with events ?

Jonas Kellens jonas.kellens at telenet.be
Mon Sep 5 07:41:50 CDT 2011


Hello list,

I don't really understand how AMI works.

I read some information and examples on the net, but they all show how 
you login to the AMI, give an action and receive a response. The end.
I guess you just re-run the script every time you want the action to be 
executed.

How then does this work when you use events ? If I want to use 
"PeerStatus" to monitor the state of a SIP peer, how can I run a script 
on change of peer status ?

If I make a php script to login and send an event, where does every 
status change then go to ??


//* Connection details */
$manager_host = "127.0.0.1";
$manager_user = "admin";
$manager_pass = "iamgod";

/* Default Port */
$manager_port = "5038";

/* Connection timeout */
$manager_connection_timeout = 30;

/* Connect to the manager */
$fp = fsockopen($manager_host, $manager_port, $errno, $errstr, 
$manager_connection_timeout);

     $login = "Action: login\r\n";
     $login .= "Username: $manager_user\r\n";
     $login .= "Secret: $manager_pass\r\n";
     $login .= "Event: PeerStatus//\r\n";
     $login .= "\r\n";
     fwrite($fp,$login);/


That's it. I'm logged in and I have been subscribed to receive peer 
status changes. Where do these peer changes appear ? I really don't get 
that.

If I want to send an email on every peer status change... where do I 
have to look for peer status changes ?



Kind regards,
Jonas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110905/22f1b7b3/attachment.htm>


More information about the asterisk-users mailing list