System information
of ways in which this might be used, such as for managing users or allowing the sharing
of dynamic information within a clustered set of Asterisk machines.
What func_odbc allows you to do is define SQL queries to which you assign function
names. In effect, you are creating custom functions that obtain their results by executing
queries against a database. The func_odbc.conf file is where you specify the relationships
between the function names you create and the SQL statements you wish them to
perform. By referring to the named functions in the dialplan, you can retrieve and
update values in the database.
While using an external script to interact with a database (from which
a flat file is created that Asterisk will read) has advantages (if the database
goes down, your system will continue to function and the script will
simply not update any files until connectivity to the database is re-
stored), it also has disadvantages. A major disadvantage is that any
changes you make to a user will not be available until you run the update
script. This is probably not a big issue on small systems, but on large
systems waiting for changes to take effect can cause issues, such as
pausing a live call while a large file is loaded and parsed.
You can relieve some of this by utilizing a replicated database system.
Asterisk 1.6.0 and newer provide the ability to fail over to another da-
tabase system. This way, you can cluster the database backend utilizing
a master-master relationship (for PostgreSQL, pgcluster or Postgres-
R;
*
for MySQL it’s native
†
), or a master-slave (for PostgreSQL, Slony-I,
for MySQL it’s native) replication system.
In order to get you into the right frame of mind for what follows, we want you to picture
a Dagwood sandwich.
‡
Can you relay the total experience of such a thing by showing someone a picture of a
tomato, or by waving a slice of cheese about? Not hardly. That is the conundrum we
faced when trying to give a useful example of why func_odbc is so powerful. So, we
decided to build the whole sandwich for you. It’s quite a mouthful, but after a few bites
of this, peanut butter and jelly is never going to be the same.
For our example, we decided to implement something we think could have some prac-
tical uses. Picture a small company with a sales force of five people who have to share
two desks. This is not as cruel as it seems, because these folks spend most of their time
on the road, and they are each only in the office for at most one day each week.
* pgcluster appears to be a dead project, and Postgres-R appears to be in its infancy, so there may
currently be no good solution for master-master replication using PostgreSQL.
† There are several tutorials on the Web describing how to set up replication with MySQL.
‡ And if you don’t know what a Dagwood is, that’s what Wikipedia is for. I am not that old.
Getting Funky with func_odbc: Hot-Desking | 355