Cannot set userfield

In my asterisk dial plan I call:



AGI Script Executing Application: (Set(CDR(userfield)=0.014)) Options: () May 22 14:30:57 WARNING[31710]: res_agi.c:1101 handle_exec: Could not find application (Set(CDR(userfield)=0.014))

I also tried:



    -- AGI Script Executing Application: (SetCDRUserfield) Options: ((0.014))[/code]

But in the associated CDR record this value never appears.

I also tried from the dialplan and saw this in the console:
[code]    -- Executing Set("SIP/david-work-006f0140", "CDR(userfield)=8675309") in new stack

I use cdr_odbc to send the data into the database. In the database the column is called ‘userfield’. I use the database mysql for tracking my CDR. (Since I am not sending bills to anyone, this is within the terms of use).

According to the message when I log into asterisk, I have 1.2:

Running a version from debian:

Package: asterisk

Reverse Depends: 
  destar,asterisk 1.2.13
  asterisk-sounds-main,asterisk 0.4.0-5
  asterisk-sounds-main,asterisk 0.1.12-3
  asterisk-oh323,asterisk 1.2
  asterisk-h323,asterisk 1:1.0.2-2
  asterisk-doc,asterisk 0.1.12-3
  asterisk-doc,asterisk 0.1.12-3
  asterisk-dev,asterisk 0.1.12-3
  asterisk-dev,asterisk 0.1.12-3
  asterisk-config,asterisk 1:1.0.2-2
  asterisk-classic,asterisk 1:1.2.13~dfsg-2
  asterisk-bristuff,asterisk 1:1.2.13~dfsg-2
1:1.2.13~dfsg-2 - asterisk-classic (18 1:1.2.13~dfsg-2) asterisk-bristuff (2 1:1.2.13~dfsg-2) adduser (2 3.63) gnomemeeting (0 (null)) ekiga (0 (null)) ohphone (0 (null)) kphone (0 (null)) asterisk-doc (0 (null)) asterisk-dev (0 (null)) asterisk-rate-engine (0 (null)) asterisk-oh323 (1 0.6.6pre3-3) 
1:1.2.13~dfsg-2 - 
Reverse Provides: 

Why is my 0.014 number not being added with the CDR record?


David Lublink

I know I am in the write part of the dialplan because if I put:


on the next (or previous) line, it’ll affect the results in the database.


When reloading, I see some warnings and notices, but none seem to be related to my issue:

May 22 14:51:17 NOTICE[32270]: cdr.c:1192 do_reload: CDR simple logging enabled.
May 22 14:51:17 NOTICE[32270]: dnsmgr.c:338 do_reload: Managed DNS entries will be refreshed every 300 seconds.
May 22 14:51:17 NOTICE[32270]: indications.c:505 ast_unregister_indication_country: Removed default indication country 'us'
May 22 14:51:17 WARNING[32270]: pbx_ael.c:1172 ast_ael_compile: Unable to open '/etc/asterisk/extensions.ael': No such file or directory
May 22 14:51:17 WARNING[32270]: pbx.c:3761 ast_merge_contexts_and_delete: Requested contexts didn't get merged
May 22 14:51:17 WARNING[32270]: chan_zap.c:11045 setup_zap: Ignoring switchtype
May 22 14:51:17 WARNING[32270]: chan_zap.c:11045 setup_zap: Ignoring signalling
May 22 14:51:17 WARNING[32270]: chan_zap.c:11045 setup_zap: Ignoring rxwink

Set(CDR(userfield)=0.014) gives
(Set(CDR(userfield)=0.014)) Options: ()
with warning: Could not find application (Set(CDR(userfield)=0.014))
no spaces in AGI

SetCDRUserfield (“0.014”) gives
(SetCDRUserfield) Options: ((0.014))
probably with warning Could not find application (SetCDRUserfield)

Did You try
Set CDR(Userfield)=0.014 ?
(1 space after Set)

Notice - nothing wrong happen
pbx_ael.c:1172 ast_ael_compile: Unable to open ‘/etc/asterisk/extensions.ael’: No such file or directory - this should be obvious
setup_zap: Ignoring switchtype - i always have this warning when reloadig zapata.conf, but it still works

[May 23 12:40:53 WARNING[22065]: pbx.c:6061 pbx_builtin_setvar: Ignoring entry 'CDR(userfield)' with no = (and not last 'options' entry)

I found a note on voip-wiki saying that there is a change that needs to be made before compiling to activate this option, perhaps it isn’t enabled on the debian package?


I did not manage to get the user field set, so I did the following work around.

Currently my CDR records are stored in a SQL database. (mysql).

  1. Setup the cdr_odbc to send the records into the cdr table
  2. Activated the uniqueid field in cdr_odbc ( loguniqueid=yes )
  3. Wrote an AGI script that gets the uniqueid
  4. Prepares a statement to insert the trunk id, cost per minute and increment.
  5. Insert it into the SQL database using php/SQL interface

I calculate the amount the user owes me like this:

As you can see my second table,cdr_billing, also contains the uniqueid field where I join the two tables using the ‘using’ command. (might be mysql specific).

After that I calculate the number of increments the user used (number of increments rounded up to the nearest increment using DIV (integer division) and if/modulus.

I than multiply that by the cost per increment ( which is the cost multiplied by increment divided by 60 since the cost is per minute).

I than take the sum of the query and round it to the nearest cent (2 decimals).

Now I have the amount the user owes me. (but I don’t send a bill with this information, or I might have to pay MySQL. I am currently using this for personal use. But I like to know what it is costing me)

David Lublink

did You consider using add-ons to Asterisk and store CDR in mysql configurable by cdr_mysql.conf ?
i did try this once and using userfield=1 option in config makes set(CDR(userfield)=var) doable.
(i’m using cdr to postgresql)