Operate on users registration

Hi,

I have a bunch of SIP phones(behind NAT) registering on my * box. I want to find out when they register and de-register. I also want to operate on it, so when they register/de-register, I want to insert calldate into a mysql DB, etc…

Now I am aware of regcontext, but it only creates a 1,NoOP for that user, I want it to execute that, so I can have this maybe:

exten => 666,2,AGI(Registraion.agi)

so when my users register 666,1,NoOp will be created and execution can start there.

I don’t think asterisk can start events based on registrations or deregistrations. remember also that you will often not get a deregistration, if the user unplugs the phone it will just expire.

the way to do this would be to make some kind of app that listens on the manager interface or cli and makes .call files when registrations happen…