Asterisk app_dbodbc
app_dbodbc
This is original Brian's re-implementation of the Asterisk database using unixODBC.This allows for easy creation of dialplan modifiers that link into a GUI with a back-end database.
Download Brian's Version (patched to work with 1.0RC1 and above)
- http://www.asterisk-support.de/mirror/odbc/app_dbodbc.c.orig (rename it to app_dbodbc.c)
Download modified version to work with Asterisk 1.0RC1 and above. This version is also extended by Rob Fugina (ODBCLookupCIDName, ODBCLookupBlacklist) and Jukka Laaksola (database recconnect function).
or
Download modified version to work with asterisk cvs-head. This version is modified by Gregory Nietsky. Also a patch for realtime.
Install
rpm -ivh unixODBC*rpmrpm -ivh MyODBC*rpm
cp app_dbodbc.c /usr/src/asterisk/apps/
vi /usr/src/asterisk/apps/Makefile +28
add in the end of line: app_dbodbc.so
vi /usr/src/asterisk/apps/Makefile +110
app_dbodbc.so: app_dbodbc.o
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
cd /usr/src/asterisk
make
make install
Configure
This assumes using MySQL database on RedHat - will vary for other DBs & slightly for other OS's.Configure MySQL:
- Add a database called 'asterisk'
- Create a user with full read/write access to this database
- Add a table within this database called 'astdb'
- Add 3 fields to the structure of this table: 'astfamily', 'astkey' & 'astvalue'
vi /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc.so
Setup = /usr/lib/libodbcmyS.so
FileUsage = 1
vi /etc/odbc.ini
[MySQL-asterisk]
Description = MySQL Asterisk database
Trace = Off
TraceFile = stderr
Driver = MySQL
SERVER = localhost
USER =
PASSWORD =
PORT = 3306
DATABASE = asterisk
Test ODBC:
isql -v MySQL-asterisk myusername mypassword
vi /etc/asterisk/odbc.conf
[global]
dsn=MySQL-asterisk
username=myusername
password=mypassword
Usage
- ODBCget(varname=family/key):
- ODBCput(family/key=value):
- ODBCdel(family/key):
- ODBCdeltree(family[/keytree]):
and if you use the extented version:
- ODBCLookupCIDName:
- ODBCLookupBlacklist:
See also
- Asterisk database
- Asterisk configuration from database
- Asterisk GUI
- unixODBC
- Asterisk cdr odbc - has some general info on configuring unixODBC
- Asterisk | FAQ | Tips & Tricks
Comments
333Values get cut to 50 chars on odbcget
SQLBindCol(ODBC_stmt, 1, SQL_C_CHAR, &tmp, 50, &ODBC_err);
SQLBindCol(ODBC_stmt, 1, SQL_C_CHAR, &tmp, 256, &ODBC_err);
--
Jens
333Gregorys module stops Asterisk load
app_dbodbc.soSep 13 13:49:47 WARNING31772: loader.c:325 __load_resource: /usr/lib/asterisk/modules/app_dbodbc.so: undefined symbol: ast_direct_realtime
Sep 13 13:49:47 WARNING31772: loader.c:554 load_modules: Loading module app_dbodbc.so failed!
Must I apply the realtime patch found on his website to allow the ODBC module to run?
333load module problem
ast_load --> ast_config_load
ast_destroy --> ast_config_destroy
recompile and re-install.
333Re: odbc compilation problems
333Re: odbc compilation problems
333Re: odbc compilation problems
333odbc compilation problems
packages installed:
- rpm -qa | grep ODBC
MyODBC-2.50.39-11unixODBC-2.2.3-6
unixODBC-devel-2.2.3-6
result of compilation:
gcc -pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -g -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE -O6 -march=i686 -DASTERISK_VERSION=\"CVS-HEAD-10/25/04-00:58:46\" -DASTERISK_VERSION_NUM=999999 -DINSTALL_PREFIX=\"\" -DASTETCDIR=\"/etc/asterisk\" -DASTLIBDIR=\"/usr/lib/asterisk\" -DASTVARLIBDIR=\"/var/lib/asterisk\" -DASTVARRUNDIR=\"/var/run\" -DASTSPOOLDIR=\"/var/spool/asterisk\" -DASTLOGDIR=\"/var/log/asterisk\" -DASTCONFPATH=\"/etc/asterisk/asterisk.conf\" -DASTMODDIR=\"/usr/lib/asterisk/modules\" -DASTAGIDIR=\"/var/lib/asterisk/agi-bin\" -DBUSYDETECT_MARTIN -fPIC -c -o app_dbodbc.o app_dbodbc.c
app_dbodbc.c: In function `odbcget_exec':
app_dbodbc.c:271: structure has no member named `callerid'
make1: *** app_dbodbc.o Error 1
make1: Leaving directory `/root/asterisk/apps'
make: *** subdirs Error 1
for x in res channels pbx apps codecs formats agi cdr astman stdtime; do make -C $x depend || exit 1 ; done
make1: Entering directory `/root/asterisk/res'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/res'
make1: Entering directory `/root/asterisk/channels'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/channels'
make1: Entering directory `/root/asterisk/pbx'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/pbx'
make1: Entering directory `/root/asterisk/apps'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/apps'
make1: Entering directory `/root/asterisk/codecs'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/codecs'
make1: Entering directory `/root/asterisk/formats'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/formats'
make1: Entering directory `/root/asterisk/agi'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/agi'
make1: Entering directory `/root/asterisk/cdr'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/cdr'
make1: Entering directory `/root/asterisk/astman'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/astman'
make1: Entering directory `/root/asterisk/stdtime'
make1: Nothing to be done for `depend'.
make1: Leaving directory `/root/asterisk/stdtime'
cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
make -C editline libedit.a
make1: Entering directory `/root/asterisk/editline'
make1: `libedit.a' is up to date.
make1: Leaving directory `/root/asterisk/editline'
make1: Entering directory `/root/asterisk/db1-ast'
make1: `libdb1.a' is up to date.
make1: Leaving directory `/root/asterisk/db1-ast'
make1: Entering directory `/root/asterisk/stdtime'
make1: `libtime.a' is up to date.
make1: Leaving directory `/root/asterisk/stdtime'
if -d CVS && ! -f .version ; then echo CVS-HEAD-10/25/04-00:58:46 > .version; fi
for x in res channels pbx apps codecs formats agi cdr astman stdtime; do make -C $x || exit 1 ; done
make1: Entering directory `/root/asterisk/res'
make1: Nothing to be done for `all'.
make1: Leaving directory `/root/asterisk/res'
make1: Entering directory `/root/asterisk/channels'
make1: Nothing to be done for `all'.
make1: Leaving directory `/root/asterisk/channels'
make1: Entering directory `/root/asterisk/pbx'
make1: Nothing to be done for `all'.
make1: Leaving directory `/root/asterisk/pbx'
make1: Entering directory `/root/asterisk/apps'
gcc -pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -g -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE -O6 -march=i686 -DASTERISK_VERSION=\"CVS-HEAD-10/25/04-00:58:46\" -DASTERISK_VERSION_NUM=999999 -DINSTALL_PREFIX=\"\" -DASTETCDIR=\"/etc/asterisk\" -DASTLIBDIR=\"/usr/lib/asterisk\" -DASTVARLIBDIR=\"/var/lib/asterisk\" -DASTVARRUNDIR=\"/var/run\" -DASTSPOOLDIR=\"/var/spool/asterisk\" -DASTLOGDIR=\"/var/log/asterisk\" -DASTCONFPATH=\"/etc/asterisk/asterisk.conf\" -DASTMODDIR=\"/usr/lib/asterisk/modules\" -DASTAGIDIR=\"/var/lib/asterisk/agi-bin\" -DBUSYDETECT_MARTIN -fPIC -c -o app_dbodbc.o app_dbodbc.c
app_dbodbc.c: In function `odbcget_exec':
app_dbodbc.c:271: structure has no member named `callerid'
make1: *** app_dbodbc.o Error 1
make1: Leaving directory `/root/asterisk/apps'
make: *** subdirs Error 1
some advices?
(:mrgreen:)
333No data
app_dbodbc.so] => (Database access functions for Asterisk extension logic)
== Parsing '/etc/asterisk/odbc.conf': Found
> app_dbodbc: dsn is AsteriskProduction
> app_dbodbc: username is asterisk
> app_dbodbc: password is secret
> app_dbodbc: Connected to AsteriskProduction
== Registered application 'ODBCget'
== Registered application 'ODBCput'
== Registered application 'ODBCdel'
== Registered application 'ODBCdeltree'
But no data is being put in the table.
Does something need to be done to tell * to save via odbc instead of to the local db?
333Field specs
333Compile Problems
static ast_mutex_t odbc_lock = AST_MUTEX_INITIALIZER;
to
AST_MUTEX_DEFINE_STATIC(odbc_lock);
before it would let me compile it because of a change in the way lock.h does something. Seems to be working now! (:biggrin:)