2

Running Asterisk 13 on Fedora 21 Server. SELinux = Permissive.

I have configured asterisk to write CDRs to MySQL. I get all the normal fields written to the CDR.

I also have this in the dial plan (extensions.conf):

exten => h,n,Set(CDR(cause_code)=${HANGUPCAUSE})
exten => h,n,Set(CDR(cause_name)= ${ODBC_GET_CAUSE(${HANGUPCAUSE})})
exten => h,n,Set(TrNumber=${ODBC_GET_DIALED_NUMBER(${CDR(lastdata)})})
exten => h,n(writeTranslate),SET(CDR(TranslatedNumber)=${TrNumber})

Note the custom fields cause_code, cause_name, and TranslatedNumber/

The fields cause_code, cause_name, and TranslatedNumber exist in the cdr table.

When the code runs I get this:

-- Executing [h@context-out:5] Set("SIP/xx.xxx.xx.xx-00000004", "CDR(cause_code)=16") in new stack
-- Executing [h@context-out:6] Set("SIP/xx.xxx.xx.xx-00000004", "CDR(cause_name)= normal call clearing") in new stack
-- Executing [h@context-out:7] Set("SIP/xx.xxx.xx.xx-00000004", "TrNumber=15555552233") in new stack
-- Executing [h@context-out:9] Set("SIP/xx.xxx.xx.xx-00000004", "CDR(translatedNumber)=15555552233") in new stack

This is in verbose mode. Note that the code Setting the CDR runs without error and with data to be posted to the CDR.

cdr_adaptive_odbc.conf looks like this:

 [adaptive-connection]
 connection=asterisk
 table=cdr
 alias start => calldate
 usegmtime=yes

That is all I should need. The cdr_adaptive_odbc module has been reloaded as has been the dial plan.

YET, these fields are shown as NULL in the cdr table. Suggestions?

SchroedingersCat
  • 487
  • 8
  • 21
  • Maybe this will help you: http://stackoverflow.com/questions/10499261/saving-data-into-custom-cdr-field – Alvaro Flaño Larrondo Jun 25 '15 at 21:48
  • Check same in dialplan(not in h-exten). At moment of h-exten cdr already go. – arheops Jun 25 '15 at 22:11
  • In Asterisk 13 (8+ I think) using cdr_adaptive_odbc eliminates the need to create the alias. – SchroedingersCat Jun 25 '15 at 23:37
  • As to the CDR already having been written by the time you get to the h section -- that may be the case, but this code worked in Asterisk 11. If one can no longer write the CDR in the h section then I'll have to do it with some sort of add-on SQL Function. – SchroedingersCat Jun 25 '15 at 23:39
  • I not remmber exactly. Need test and see. Also cdr_odbc, cdr_adaptive_odbc and cdr_mysql work very different with this fields. – arheops Jun 26 '15 at 05:09

1 Answers1

-1

You have to add aliases for adding custom fields in CDRs

[aliases]
cause_code = cause_code
cause_name = cause_name
TranslatedNumber = TranslatedNumber

I have tried on asterisk 11 and following is the full guide:

http://blog.ones-app.com/add-custom-fields-in-asterisks-mysql-cdrs/

Azhar Nawaz
  • 91
  • 12