login | register
Thu 04 of Dec, 2008 [02:03 UTC]

voip-info.org

Discuss [3] History

Asterisk func cdr

Created by: murf,Last modification on Fri 27 of Jul, 2007 [12:50 UTC] by baji

Synopsis:

 CDR(<name>)

Description:

 CDR(<name>[|options])
 
name may be one of the following:
  • accountcode: The channel's account code.
  • amaflags: DOCUMENTATION, BILL, IGNORE etc
  • answer: Time the call was answered.
  • billsec: Duration of the call once it was answered.
  • channel: Channel name
  • clid: Caller ID
  • dcontext: Destination context
  • disposition: ANSWERED, NO ANSWER, BUSY
  • dst: Destination
  • dstchannel: Destination channel
  • duration: Duration of the call.
  • end: Time the call ended.
  • lastapp: Last app executed
  • lastdata: Last app's arguments
  • src: Source
  • start: Time the call started.
  • uniqueid: The channel's unique id.
  • userfield: The channel's user specified field.
  • any custom value that you wish to store.

options may be:
  • r: Causes the function to search the entire stack of CDRs on the channel for the requested value.
  • u: Retrieves the raw, unprocessed value.

All of the pre-defined CDR variables are read-only with the exception of the following:
  • Asterisk 1.4
    • accountcode
    • amaflags
    • userfield
  • Asterisk 1.2
    • accountcode
    • userfield
As noted above, you can add your own custom values to the CDR record. See the Example below for details.

Notes

  • This function may be both read from and written to. However, most of the pre-defined values are read-only as described above.
  • *CLI> core show function CDR

Return value

Returns the resulting string.

Example

; Get the value of the duration CDR field and store it in a variable
exten => s,1,Set(foo=${CDR(duration)})

; Update our accountcode field and then save some random music facts too
exten => s,1,Set(CDR(accountcode)=8675309)
exten => s,2,Set(CDR(MyFavoriteBand)=Foo Fighters)
exten => s,3,Set(CDR(MyFavoriteSong)=Hero)

See also



Comments

Comments Filter
222

333

by baji, Friday 27 of July, 2007 [13:14:21 UTC]
; ----------- using asterisk version 1.4.8 ----------------------
;
; Example script to retrieve formatted and unformatted values using CDR
;
 exten => s,1,Set(TIMEOUT(absolute)=15)
;
; ------------------------------------------
;
; This returns Caller ID Name & Number, eg. "John Doe" <3305551212>
;
 exten => s,n,Set(v_clid=${CDR(clid)})
;
 exten => s,n,NoOp(${v_clid})
;
; ------------------------------------------
;
; This returns Caller ID Number Only, eg. <3305551212>
;
 exten => s,n,Set(v_src=${CDR(src)})
;
 exten => s,n,NoOp(${v_src})
;
; ------------------------------------------
;
; Call start time in different formats
;
 exten => s,n,Set(v_start=${CDR(start)})
 exten => s,n,Set(r_start=${CDR(start|r)})
 exten => s,n,Set(u_start=${CDR(start|u)})
;
 exten => s,n,NoOp(${v_start})
 exten => s,n,NoOp(${r_start})
 exten => s,n,NoOp(${u_start})
;
; ------------------------------------------
;
; Status of call, eg BUSY, ANSWERED
;
 exten => s,n,Set(v_disposition=${CDR(disposition)})
 exten => s,n,Set(r_disposition=${CDR(disposition|r)})
 exten => s,n,Set(u_disposition=${CDR(disposition|u)})
;
 exten => s,n,NoOp(${v_disposition})
 exten => s,n,NoOp(${r_disposition})
 exten => s,n,NoOp(${u_disposition})
;
; ------------------------------------------
;
 exten => s,n,Hangup()
;
; Call timeout, broken connection, say goodbye and hangup
;
;
 exten => T,1,Playback(im-sorry)
 exten => T,n,Playback(vm-goodbye)
 exten => T,n,Hangup()
;
; -----------------------------------------------------------------------

222

3333 examples using CDR()

by baji, Friday 13 of July, 2007 [12:19:47 UTC]
;
; -------- (examples from use in asterisk version 1.4.7) -------------
;
; Initialize two vars
;
  exten => s,1,Set(Var_1=foo)
  exten => s,n,Set(Var_2=bar)
;
; Remember "userfield" is not a token that you can replace with an identifier of your choice
; it is a constant.
;
  exten => s,n,Set(CDR(userfield)=bling blong blang)
;
; Stores "bling blong blang" in untagged field at the end of the CDR in
; /var/log/asterisk/cdr-csv/Master.csv
; Not a very useful form
;
  exten => s,n,Set(CDR(userfield)=${Var_1}_${Var_2})
;
; Stores "foo_bar" in the same field at the end of the CDR
;
  exten => s,n,Set(CDR(userfield)=At ${CDR(start)} From callerID ${CDR(clid)} eat your ${CDR()} )
;
At 2007-07-12 22
56:44 From callerID guest eat your foo_bar
;
; ---------------------------------------------
222

333All fields except userfield and account code are read only!

by creeble, Wednesday 05 of April, 2006 [19:05:32 UTC]
Turns out you can't use Set(CDR(<name>)=value) for anything but userfield and accountcode.
These fields are read-only.

Also (mr picky!), "astapp" above of course should be 'lastapp'.