Detect phone pick-up and write to mysql

I want to setup the following configuration…
There are 4 phones ringing when somebody calls in. When one of the phones is picked up, I want to insert a record in a mysql database. Then I know who is taking the call.
I searched for a long time, but probably with the wrong keywords.

How do I do this?
Where can I find more information?

At the moment I made a group with the 4 SIP-members in a queue. In the future I also want to detect how many calls are waiting and how many phones are active in a group.

The “M” parameter of the Dial() command lets you start a macro upon the connection of a call, voip-info.org/wiki/index.php … +cmd+MYSQL .

Never tried but should work.

Regards.

Marco Bruni