Simple PHP based CLI tool to publish Asterisk AMI events to a Rabbit Message Queue
Note: PAMI Requires PHP 5.3+. PHP versions 5.3.9 and 5.3.10 WILL NOT WORK due to a bug introduced in stream_get_line() in 5.3.9. Please use 5.3.11+ or up to 5.3.8 (see README.PHP-5.3.9-and-5.3.10).
Clone the repo:
git clone https://github.com/opensoft/AsterBunny.git
Now install dependencies with composer
curl https://getcomposer.org/installer | php
php composer.phar install
The CLI tool is located at bin/asterbunny
and has a lot of configuration options relating to specifying hostnames, ports,
usernames, and passwords for Asterisk connections and RabbitMQ servers.
It's recommended to run the following to learn the configuration set, and defaults
./bin/asterbunny listen --help
All asterisk events emitted by the Asterisk AMI interface are encoded as JSON and then sent to a configured RabbitMQ server.
Specifically, https://www.voip-info.org/wiki/view/asterisk+manager+events are:
- Keys are converted to lowercase
- The message is converted to JSON
And then submitted to the configured exchange with the fanout
exchange type
{
"event": "Agentlogoff",
"agent": "<agent>",
"logintime": "<logintime>",
"uniqueid": "<uniqueid>"
}
Message headers are as follows:
timestamp
=> The unix timestamp of when the event occured as seen by AsterBunnycontent_type
=>application\json
delivery_mode
=>2
- Indicates that the message should be persisted by RabbitMQ
A default log4php configuration file is included with this tool.
$ cp log4php.dist.xml log4php.xml
Configure logging by editing the file according to instructions found here
- PHP 5.3
- RabbitMQ
- Asterisk AMI
AsterBunny is licensed under the MIT License - see the LICENSE file for details