How to get DIALSTATUS from AMI?

I need to read the ${dialstatus} variable after a call is originated via AMI. I know that I can use something like below to pass it on to my script:

exten=>n,System(file_name.php ${DIALSTATUS})

However, the problem is that my script is on a remote webserver and not Asterisk. Is there a way to fget() the variable via AMI? or have I got it completely wrong?!
I am on Asterisk 13.14 with Asterisk Call Manager 2.9.

There are a ton of asterisk manager libraries out there. You should use one of those instead of writing it yourself using fgets. You’ll save so much time.

Here’s the one freepbx uses:


Ok so I am using Fastagi now as below in my dial plan:


the remote host is a Windows webserver and I am not sure if AGI is able to reach the script. The variable is definitely not passed through. Any idea how to test/debug the connection?

Thing to check #1 would be to make sure that your Webserver had access to the phone server. By default, most of the ‘admin’-style accounts only work on connections from

1 Like