Calculate the Call Duration ( BillSec)
Hi All, The following lua script for calculate the call duration. But the issue here , the duration is calculating from the outbound initiate time. How to get the call answer time? session:preAnswer(); -- sleep a second session:sleep(1000); -- digits = session:playAndGetDigits(10, 20, 3, 5000, "#", "enter-dest.wav", "invalid-digits.wav", "\\d+|\\*"); -- Initiate an outbound call outSession = freeswitch.Session("sofia/gateway/voipms/"..digits,session) starttime = os.time(); freeswitch.consoleLog("info", "Start Time"..starttime.." \n"); freeswitch.consoleLog("info", "Before Bridge the Call \n"); freeswitch.bridge(session, outSession); freeswitch.consoleLog("info", "After Bridge the Call \n"); endtime = os.time(); freeswitch.consoleLog("info", "End Time"..endtime.." \n"); billsec = os.difftime(endtime,starttime); freeswitch.consoleLog("info", "Blling Sec"..billsec.." \n"); -- hangup session:hangup(); Thanks Lloyd
On Thu, Mar 18, 2010 at 7:38 AM, Aloysius Lloyd <lloyd.aloysius@gmail.com>wrote:
Hi All,
The following lua script for calculate the call duration. But the issue here , the duration is calculating from the outbound initiate time.
How to get the call answer time?
If you're trying to do billing in-line you might as well stop right now and read the CDRs page on the wiki. Trying to calculate this from inside the session is silly. -MC
Thank you for the suggestion. Yes I went to the direction then Stop. How to handle Hangup actions for every call? For Example : I do not want to calculate the duration for all the calls or execute actions for all the calls. I need calculate for particular calls only.I tested the following ,* it execute for every calls hangup*. How to control or How to execute in some conditions. cdr_csv.conf.xml <param name="default-template" value="lua"/> <template name="lua">${lua(onhangup.lua)}</template> On Thu, Mar 18, 2010 at 11:16 AM, Michael Collins <msc@freeswitch.org>wrote:
On Thu, Mar 18, 2010 at 7:38 AM, Aloysius Lloyd <lloyd.aloysius@gmail.com>wrote:
Hi All,
The following lua script for calculate the call duration. But the issue here , the duration is calculating from the outbound initiate time.
How to get the call answer time?
If you're trying to do billing in-line you might as well stop right now and read the CDRs page on the wiki. Trying to calculate this from inside the session is silly. -MC
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
<action application="set" data="process_cdr=false"/> On Thursday 18 March 2010, Aloysius Lloyd wrote:
Thank you for the suggestion. Yes I went to the direction then Stop. How to handle Hangup actions for every call?
For Example : I do not want to calculate the duration for all the calls or execute actions for all the calls. I need calculate for particular calls only.I tested the following ,* it execute for every calls hangup*. How to control or How to execute in some conditions.
cdr_csv.conf.xml
<param name="default-template" value="lua"/>
<template name="lua">${lua(onhangup.lua)}</template>
On Thu, Mar 18, 2010 at 11:16 AM, Michael Collins <msc@freeswitch.org>wrote:
On Thu, Mar 18, 2010 at 7:38 AM, Aloysius Lloyd <lloyd.aloysius@gmail.com>wrote:
Hi All,
The following lua script for calculate the call duration. But the issue here , the duration is calculating from the outbound initiate time.
How to get the call answer time?
If you're trying to do billing in-line you might as well stop right now and read the CDRs page on the wiki. Trying to calculate this from inside the session is silly. -MC
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Thu, Mar 18, 2010 at 8:32 AM, Aloysius Lloyd <lloyd.aloysius@gmail.com>wrote:
Thank you for the suggestion. Yes I went to the direction then Stop. How to handle Hangup actions for every call?
For Example : I do not want to calculate the duration for all the calls or execute actions for all the calls. I need calculate for particular calls only.I tested the following ,* it execute for every calls hangup*. How to control or How to execute in some conditions.
Is there a problem with running it on every call? The overhead of a Lua script is minimal compared to the actual call. I'm just curious what you gain from selectively running the script. -MC
for example in a 10000 calls only want to run 100 times. Do you think it is a best practice run the Lua script for 9900 time for no reason. Lloyd On Thu, Mar 18, 2010 at 11:49 AM, Michael Collins <msc@freeswitch.org>wrote:
On Thu, Mar 18, 2010 at 8:32 AM, Aloysius Lloyd <lloyd.aloysius@gmail.com>wrote:
Thank you for the suggestion. Yes I went to the direction then Stop. How to handle Hangup actions for every call?
For Example : I do not want to calculate the duration for all the calls or execute actions for all the calls. I need calculate for particular calls only.I tested the following ,* it execute for every calls hangup*. How to control or How to execute in some conditions.
Is there a problem with running it on every call? The overhead of a Lua script is minimal compared to the actual call. I'm just curious what you gain from selectively running the script. -MC
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Thu, Mar 18, 2010 at 9:05 AM, Aloysius Lloyd <lloyd.aloysius@gmail.com>wrote:
for example in a 10000 calls only want to run 100 times. Do you think it is a best practice run the Lua script for 9900 time for no reason.
Do you need to skip processing the CDR altogether for those other 9900 calls? -MC
No.Need CDR for all calls. I am thinking in the following way. Is this possible? Application A - Need CDR values and cdr_csv.conf.xml use *onhangupA.lua* Application B - Need CDR values and cdr_csv.conf.xml use *onhangupB.lua* Application C - Need CDR values only. Thanks Lloyd On Thu, Mar 18, 2010 at 12:11 PM, Michael Collins <msc@freeswitch.org>wrote:
On Thu, Mar 18, 2010 at 9:05 AM, Aloysius Lloyd <lloyd.aloysius@gmail.com>wrote:
for example in a 10000 calls only want to run 100 times. Do you think it is a best practice run the Lua script for 9900 time for no reason.
Do you need to skip processing the CDR altogether for those other 9900 calls? -MC
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Thu, Mar 18, 2010 at 9:22 AM, Aloysius Lloyd <lloyd.aloysius@gmail.com>wrote:
No.Need CDR for all calls.
I am thinking in the following way. Is this possible?
Application A - Need CDR values and cdr_csv.conf.xml use *onhangupA.lua*
Application B - Need CDR values and cdr_csv.conf.xml use *onhangupB.lua*
Application C - Need CDR values only.
What you really need to be using is mod_xml_cdr and posting your CDRs to a separate server and do all this stuff outside of the FS server. Using mod_xml_cdr will definitely scale more easily than trying to play around with crazy logic in the dialplan and CSV CDRs. http://wiki.freeswitch.org/wiki/Mod_xml_cdr It's a paradigm shift from CSV CDRs but when you realize just how powerful it is you will never be satisfied with plain CSV CDRs any more. -MC
participants (3)
-
Aloysius Lloyd
-
Michael Collins
-
Sergey Okhapkin