Asterisk Event based Trigger/Action Addon

I’ve been working with asterisk for about a month now so i’m not an expert or anything, so let me know if i’m missing something or if this has been discussed or if this already exists. But after trying to integrate asterisk i’ve come to the conclusion that the events system is very lmiting in terms of ease of integration. While it is true that it’s possible to telnet into the AMI and execute Actions and wait for responses or even just sit and monitor events the parsing of events and response are all the responsibility of the programmer trying to integrate with asterisk. Why is this? Why should a 3rd party developer have to parse events just to understand the events. I understand that this gives great flexibility to anyone developing for asterisk as asterisk just dumps raw data, but this seems unnecessary for the vast majority of developers who are just trying to integrate asterisk in a simple manor. I believe that both worlds can and should be accomplished for asterisk to grow further.

Another project that I’ve been given the opportunity to look into and work with is a network monitoring web application called Zabbix. Zabbix has a very similar foundation of event based logs/data however zabbix continues with the event driven architecture and brings about a very useful manor of integration of their application. In Zabbix they have also added the logical structure for triggers and actions, Triggers can be hooked into Events to fire when one or more events occur. These trigger then trigger or call an action which can be defined by the user. For example in the company i work for’s implementation of zabbix if a host goes down an Event will fire off a Trigger which in turns calls the Action and the action is a script that updates a helpdesk/inventory application to alert our technical support team that a host has gone down. I believe the same architecture could GREATLY increase the usability and power of the asterisk project. If i were a better programmer i would take this project on, but sadly i may still be a few years of experience away from something like this.

Asterisk Example/project outline:
Create an addon to monitor events and read in an action.conf and a trigger.conf file.
The action.conf file would contain a format similar to

And the triggers.conf file would contain a list linking events to actions similar to

This would allow a multiple to one or one to multiple situation to occur as well. So now when an event is fired it will look in the triggers.conf file and jump to or fire the action/s linked in the action configuration file. This would allow for easy integration into other applications via database transactions eliminating the dependence on the outdated telnet based AMI.

Please let me know if something like this already exists or if this idea has flaws.

well i can see that this sure is an active community…

Anywho, i just wanted to update anyone who might actually be interested. Since i am more then a few years rusty with C programming and more familiar with perl I’ve decided to implement this same concept in Perl. I’ll post the code once I’m finished polishing it up and maybe i’ll setup a quick perl doc for it, but until then here’s what i have…

a perl script that connects via the AMI and monitors events, it reads in two config files…


# This is an example triggers.conf file
# Syntax: 
#    EventName => ActionName 

ExtensionStatus => agentStatus
QueueMember => updateAgent
QueueParam  => updateQueue

Currently this is only 1 to 1, however the point of the triggers.conf files is to do a multiple to 1 or 1 to multiple event actions combinations.


# actions.conf allows the 
# application to process associated actions 
# with their respective application
# Syntax:
# actionName => applicatoin {EventParameter}
# The action name can be anything, and the application
# is any system command you would like. In order to pass
# the event parameters to the application you must use the 
# { } brackets to enclose the event parameter that you would
# like to recieve from the event. If such a parameter is found
# (Note the EventParameter much be EXACTLY the same as the 
# event's parameter name) then it will replace the {EventParam} 
# with the value of the parameter. 

queueStatus => perl 
agentStatus => perl {Exten} {Status}

These applications can be any command line application you want.

Then if you execute the script, it will execute the or the scripts when ever an event associated with that action’s trigger is fired.

This can be very useful for anyone, who like me, need to have a database driven status of the queue in real time, or if you need events formated in XML for input into other applications… making integration with asterisk a little easier.

example output:

Reading in configuration files...

7: ExtensionStatus => agentStatus
8: QueueParam => queueStatus

19: queueStatus => perl
20: agentStatus => perl {Exten} {Status}

Extension is 58 and Status is 1 (This is generated inside the script)