Managing called extensions with MySQL

Hello. I would like to set up a web-based application for users to change their Asterisk configuration, e.g. the extension numbers that ring on incoming calls and the times when calls are directed straight to voicemail. Currently, I use variables in extensions.conf to achieve this, but I have to edit the file to change the variables every time there’s a change.

My thought was to store the extension numbers and times in a MySQL database, write a php front end for the users to change the data, and use the MySQL add-ons in the dialplan so Asterisk would read the data from the database every time there was an incoming call.

So my question is - is this the best approach? If not, how would you suggest I do it?

Thanks,
Ian.

Yes, the mysql method is better than modify the configuration file, another option is to retrieve/set the variables from/in the Asterisk internal database, see voip-info.org/wiki/view/Asterisk+database .

Cheers.

Marco Bruni

Ok, thanks. I would prefer the MySQL option, since it makes writing PHP to allow users to update their own data easier.

Regards,
Ian.

Hi This is possible on a small not heavy loaded system. But you will start to have issues as the load goes up.

Best to use the internal DB and just write the PHP to set the variables in that.

Ian

The problem with that is the Apache server through which users would access their configuration is running on a different machine. I suppose I would have to NFS mount the file system with the Asterisk internal database on the web server machine and manipulate it directly?

Regards,
Ian.

Hi Not realy. as long as PHP and apache is running on Asterisk. and in 99% of installations it is. Then you just do a post from your front end to the php script on asterisk.

I always have my php written this way for Asterisk so it doesn’t matter where the front end is.

Ian

Sorry, I’m not following you. Apache is not running on the Asterisk machine, that’s the problem (actually it’s by design, keeping the Asterisk machine dedicated to Asterisk.) Can you give me an example of how you do it?

Regards,
Ian.

Hi

Why do you not have apache running on the servers ? As you have now said that mysql will be on a remote server I can see expecting to retrive varibles during a call you could have some issues with latency.

you could use your remote server to access the AMI on the server to set the database if you really don’t want apache on the server

Ian

(1) As I said, to avoid loading the production Asterisk machine with unnecessary tasks and (2) to keep the public web server separate, which makes life much easier if I have problems with one or the other.

Actually I didn’t say that, although it could be running on the web server machine, it could also be running on the Asterisk machine with the php application on the web server accessing it remotely.

I guess so, which it I asked the question - before embarking on the project I’d like to know thebest way to do it!

Thanks,
Ian

Hi

Running Apache puts very little overhead on a box. Running mysql will, especially if calls to it are being made for every call. and the cdr data being written to it at the end of the call.

How many concurrent calls are you expecting ? and how many extensions ?

Ian

Not many, a max of 5/40. Anyway, I think I’ll use the AMI, it seems to do everything I need.

Thanks,
Ian.