Asterisk- call duration in seconds, save to DB

General discussions about AsteriskNOW.

Moderators: Moderator, Support

Asterisk- call duration in seconds, save to DB

Postby Arcangelo » Wed Mar 07, 2012 6:20 pm

Hi everyone

I'm quite new to Asterisk and now trying to solve one problem.
I need to be able to save to DB a call duration in seconds for every caller id.
The best if that could be done using macro.

Also when using macro, it will be able to check call duration in seconds then check in DB how long the call duration for this caller_id has been saved, add them together and save in DB.

I will be appreciated If someone could give me an advice how to reach this target

Kind regards
Posts: 4
Joined: Thu Oct 06, 2011 9:56 am

Re: Asterisk- call duration in seconds, save to DB

Postby lardconcepts » Thu Nov 19, 2015 5:47 am

Couple of ways you could do it:

All in one line:
Code: Select all
exten => h,1,Set(DB(LastCalledDay/${CALLERID(num)})="${CDR(start)}) - ${CALLERID(num)} - Duration: ${CDR(duration)}")

Or more relationally:
Code: Select all
exten => h,1,Set(DB(LastCalled/${CALLERID(num)})=${CDR(start)})
same => n,Set(DB(Duration/${CALLERID(num)})=${CDR(duration)})

Or if you prefer to a log file:
Code: Select all
exten => h,1,Set(FILE(call_log.txt,,,al)=(${CDR(start)}) - ${CALLERID(num)} - Duration: ${CDR(duration)})

Let me know if that works!
Posts: 35
Joined: Tue Nov 11, 2014 2:13 pm

Return to AsteriskNOW General

Who is online

Users browsing this forum: No registered users and 1 guest