cdr.txt 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. Call data records can be stored in many different databases or even CSV text.
  2. MSSQL: Asterisk can currently store CDRs into an MSSQL database in
  3. two different ways: cdr_odbc.c or cdr_tds.c
  4. Call Data Records can be stored using unixODBC (which requires
  5. the FreeTDS package) [cdr_odbc.c] or directly by using just the
  6. FreeTDS package [cdr_tds.c] The following provide some
  7. examples known to get asterisk working with mssql.
  8. NOTE: Only choose one db connector.
  9. ODBC [cdr_odbc.c]:
  10. Compile, configure, and install the latest unixODBC package:
  11. tar -zxvf unixODBC-2.2.9.tar.gz &&
  12. cd unixODBC-2.2.9 &&
  13. ./configure --sysconfdir=/etc --prefix=/usr --disable-gui &&
  14. make &&
  15. make install
  16. Compile, configure, and install the latest FreeTDS package:
  17. tar -zxvf freetds-0.62.4.tar.gz &&
  18. cd freetds-0.62.4 &&
  19. ./configure --prefix=/usr --with-tdsver=7.0 \
  20. --with-unixodbc=/usr/lib &&
  21. make &&
  22. make install
  23. Compile, or recompile, asterisk so that it will now add support
  24. for cdr_odbc.c
  25. make clean &&
  26. make update &&
  27. make &&
  28. make install
  29. Setup odbc configuration files. These are working examples
  30. from my system. You will need to modify for your setup.
  31. You are not required to store usernames or passwords here.
  32. /etc/odbcinst.ini
  33. [FreeTDS]
  34. Description = FreeTDS ODBC driver for MSSQL
  35. Driver = /usr/lib/libtdsodbc.so
  36. Setup = /usr/lib/libtdsS.so
  37. FileUsage = 1
  38. /etc/odbc.ini
  39. [MSSQL-asterisk]
  40. description = Asterisk ODBC for MSSQL
  41. driver = FreeTDS
  42. server = 192.168.1.25
  43. port = 1433
  44. database = voipdb
  45. tds_version = 7.0
  46. language = us_english
  47. Only install one database connector. Do not confuse asterisk
  48. by using both ODBC (cdr_odbc.c) and FreeTDS (cdr_tds.c).
  49. This command will erase the contents of cdr_tds.conf
  50. [ -f /etc/asterisk/cdr_tds.conf ] > /etc/asterisk/cdr_tds.conf
  51. NOTE: unixODBC requires the freeTDS package, but asterisk does
  52. not call freeTDS directly.
  53. Setup cdr_odbc configuration files. These are working samples
  54. from my system. You will need to modify for your setup. Define
  55. your usernames and passwords here, secure file as well.
  56. /etc/asterisk/cdr_odbc.conf
  57. [global]
  58. dsn=MSSQL-asterisk
  59. username=voipdbuser
  60. password=voipdbpass
  61. loguniqueid=yes
  62. And finally, create the 'cdr' table in your mssql database.
  63. CREATE TABLE cdr (
  64. [calldate] [datetime] NOT NULL ,
  65. [clid] [varchar] (80) NOT NULL ,
  66. [src] [varchar] (80) NOT NULL ,
  67. [dst] [varchar] (80) NOT NULL ,
  68. [dcontext] [varchar] (80) NOT NULL ,
  69. [channel] [varchar] (80) NOT NULL ,
  70. [dstchannel] [varchar] (80) NOT NULL ,
  71. [lastapp] [varchar] (80) NOT NULL ,
  72. [lastdata] [varchar] (80) NOT NULL ,
  73. [duration] [int] NOT NULL ,
  74. [billsec] [int] NOT NULL ,
  75. [disposition] [int] NOT NULL ,
  76. [amaflags] [int] NOT NULL ,
  77. [accountcode] [varchar] (20) NOT NULL ,
  78. [uniqueid] [varchar] (32) NOT NULL ,
  79. [userfield] [varchar] (255) NOT NULL
  80. )
  81. Start asterisk in verbose mode, you should see that asterisk
  82. logs a connection to the database and will now record every
  83. call to the database when it's complete.
  84. TDS [cdr_tds.c]:
  85. Compile, configure, and install the latest FreeTDS package:
  86. tar -zxvf freetds-0.62.4.tar.gz &&
  87. cd freetds-0.62.4 &&
  88. ./configure --prefix=/usr --with-tdsver=7.0
  89. make &&
  90. make install
  91. Compile, or recompile, asterisk so that it will now add support
  92. for cdr_tds.c (Currently only asterisk CVS supports cdr_tds.c)
  93. make clean &&
  94. make update &&
  95. make &&
  96. make install
  97. Only install one database connector. Do not confuse asterisk
  98. by using both ODBC (cdr_odbc.c) and FreeTDS (cdr_tds.c).
  99. This command will erase the contents of cdr_odbc.conf
  100. [ -f /etc/asterisk/cdr_odbc.conf ] > /etc/asterisk/cdr_odbc.conf
  101. Setup cdr_tds configuration files. These are working samples
  102. from my system. You will need to modify for your setup. Define
  103. your usernames and passwords here, secure file as well.
  104. /etc/asterisk/cdr_tds.conf
  105. [global]
  106. hostname=192.168.1.25
  107. port=1433
  108. dbname=voipdb
  109. user=voipdbuser
  110. password=voipdpass
  111. charset=BIG5
  112. And finally, create the 'cdr' table in your mssql database.
  113. CREATE TABLE cdr (
  114. [accountcode] [varchar] (20) NULL ,
  115. [src] [varchar] (80) NULL ,
  116. [dst] [varchar] (80) NULL ,
  117. [dcontext] [varchar] (80) NULL ,
  118. [clid] [varchar] (80) NULL ,
  119. [channel] [varchar] (80) NULL ,
  120. [dstchannel] [varchar] (80) NULL ,
  121. [lastapp] [varchar] (80) NULL ,
  122. [lastdata] [varchar] (80) NULL ,
  123. [start] [datetime] NULL ,
  124. [answer] [datetime] NULL ,
  125. [end] [datetime] NULL ,
  126. [duration] [int] NULL ,
  127. [billsec] [int] NULL ,
  128. [disposition] [varchar] (20) NULL ,
  129. [amaflags] [varchar] (16) NULL ,
  130. [uniqueid] [varchar] (32) NULL
  131. )
  132. Start asterisk in verbose mode, you should see that asterisk
  133. logs a connection to the database and will now record every
  134. call to the database when it's complete.
  135. MYSQL:
  136. PGSQL:
  137. SQLLITE:
  138. -------------------------------------------------------------------------------
  139. 08/02/2004 : Duane Cox <dcox@illicom.net> - added mssql information