How to store Asterisk Manager events in text file [SOLVED]


I have integrated asterisk PHP and C# application through AMI.

I have some problem with events. What i want to do is that i want all AMI events to store in TXT file. Because if sometimes my AMI events are missing in my PHP and C# applications. So what i have decide is that if i store all events txt file then i can compare the PHP’s AMI events and my txt file events. So i can check whether its missing or what.

If i right any code for that i can get only Answered calls. i am initiating calls from PHP and C# applications through AMI. using console i can see the monitor. if the customer pick up the call then only my extensions.conf code works (only answered). if the customer didnt pick up then extension.conf wont execute.

I know I can monitor using Master.CSV. but i want another script. like any perl or PHP script to capture AMI events.

Please help me…

Thanks in advance…




You can use ngrep ( ) tool (can be installed on Ubuntu with ‘apt-get install ngrep’) to dumpy all AMI traffic to a text file. On your Asterisk box run:

ngrep -W byline port 5038 > AMI-packets.log


Thank you very much…let me try this…




I have tried windows version. But there is some errors like “dll file is missing” when i execute the exe file.

Now i am going to check the linux version.


CRIZ :frowning:

What kind of Events are you missing ? Find out that first and check whether that events have you put in manager.conf file.


This software works in Linux. I have tried it. I got all events.

I have installed on the Linux server and executed this command. I am getting all information. :smiley:

@chrisM8 : Thank you very much. now i have compare this log file with my own log that i have created using SYSTEM command. This one is very useful for me.

@Ketan.jadav : Thanks for your support.

Thanks & Regards,

CRIZ :smiley: