1
votes

I want to log every call that gets through my Asterisk box on a mysql database. From what I've read, Asterisk doesn't provide anything like that out of the box (or some service for me to query, as the AMI lets you query the current status, not previous calls).

At first, all I want to store is

  • Device where the call comes from
  • Original caller id
  • Call start time
  • Final caller id (may be modified in the dialplan)
  • Dialed number
  • Call end time

I think I know how to store everything, but the problem I'm having is knowing the device that received the call... is there a variable that holds this information?

There are 2 things that I thought of to get this:

  • Set a context per device... this also has two options
    • I could have a catch-all extension that creates the entry in the mysql database and dials a local channel to the context where I have the logic. What's really bad about this solution is that it would always wait a few seconds before processing the call b/c it doesn't know when it has finished
    • I could have all the logic on every context... so on the dial out logic, I pass the device name to the function that dials out and stores the info. The obvious drawback is that I'd have as many contexts as devices I own, which will become unmanageable pretty quickly

Is there something I'm missing? Another option I thought of was setting text caller id at sip.conf (b/c I want to preserve the number)... but this would override the text caller id, which it isn't important to me right now, but it may be at some point...

Thanks!

1

1 Answers

0
votes

Yes it does provide all of this out of the box. Look at the "cdr_odbc" module. Personally I use the cdr_manager module to get all the call details and then that gives me opportunity to apply application code to massage/transform the CDR fields I'm interested in per my business logic.