In the following I’ll describe how to setup asterisk to log via ODBC to a remote Microsoft SQL server — I needed this for a client. I’m using a Debian server, file location may differ for your brand of linux distribution.
The following packages exist for debian, the ones needed are marked with “NEEDED”
A good introduction to the Free TDS implementation of ODBC is the userguide of FreeTDS
Debian FreeTDS packages
FreeTDS Needs either unixodbc or iodbc, both are ODBC implementations for Linux/Unix. Asterisk is built against unixodbc.
iodbc packages:
unixodbc packages:
common packages for debian:
Asterisk depends on unixodbc which should be already installed, so we install the following packages (ignoring any warnings about already-installed packages):
apt-get install unixodbc sqsh tdsodbc
Other Software using ODBC
Python seems to have its own access module for MS-SQL:
python-pymssql – Python database access for MS SQL server and Sybase
Configuraton for Asterisk Logging
[global] # TDS protocol version ; tds version = 4.2 # Whether to write a TDSDUMP file for diagnostic purposes # (setting this to /tmp is insecure on a multi-user system) ; dump file = /tmp/freetds.log ; debug flags = 0xffff # Command and connection timeouts ; timeout = 10 ; connect timeout = 10 # If you get out-of-memory errors, it may mean that your client # is trying to allocate a huge buffer for a TEXT field. # Try setting ‘text size’ to a more reasonable limit text size = 64512 [logserver] host = 172.23.23.4 port = 1433 tds version = 8.0
[FreeTDS] Description = FreeTDS ODBC driver for MSSQL Driver = /usr/lib/odbc/libtdsodbc.so Setup = /usr/lib/odbc/libtdsS.so
[ODBC Data Sources] logserver = MSSQL Log-Server for Asterisk [logserver] description = MSSQL Log-Server for Asterisk driver = /usr/lib/odbc/libtdsodbc.so servername = logserver language = us_english trace = no tracefile = /root/mssql.trace
[global] dsn=logserver username=asterisk password=VERYSECRET loguniqueid=yes dispositionstring=yes table=cdr ;”cdr” is default table name usegmtime=no ; set to “yes” to log in GMT
isql
# isql logserver asterisk “VERYSECRET” -v +—————————————+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +—————————————+ SQL> select * from cdr; [output of current cdr table]