login | register
Sat 05 of Jul, 2008 [03:39 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Samuel, Thu 03 of Jul, 2008 [13:41 UTC]: ok thank you
  • Mats Karlsson, Thu 03 of Jul, 2008 [13:37 UTC]: Nice Samuel, will look forward to rad it.
  • bwl_fernstudent, Thu 03 of Jul, 2008 [09:08 UTC]: Your blog shows some usefull code
  • Samuel, Thu 03 of Jul, 2008 [08:04 UTC]: I'll translate it, for sure
  • Mats Karlsson, Wed 02 of Jul, 2008 [20:46 UTC]: LOL, in french! Translate it to English and I will read it.
  • Samuel, Wed 02 of Jul, 2008 [08:07 UTC]: Hello, i wrote a blog about Asterisk, speaking about installation,programming and more http://sambranche.blogspot.com/
  • Nick Barnes, Tue 01 of Jul, 2008 [17:46 UTC]: Steve - Asterisk doesn't 'fit into linux' - it's an application which runs on top of Linux.
  • Steve, Mon 30 of Jun, 2008 [18:07 UTC]: anyone know where I can find a block diagram of how asterisk fits into linux. my f'ing bosses want me to draw something up.. ugh.
  • akbar, Fri 27 of Jun, 2008 [10:37 UTC]: marley_boyz@yahoo.com how to configure call forward, call back, call pick up using TDM and asterisk 1.2.13... please help me.. thx...
  • Matthew Williams, Tue 24 of Jun, 2008 [22:37 UTC]: We are looking for Tier II VoIP Support Technicians in St Louis. Send resumes to mwilliams AT voxitas DOT com.
Server Stats
  • Execution time: 0.43s
  • Memory usage: 2.63MB
  • Database queries: 33
  • GZIP: Disabled
  • Server load: 0.44

Asterisk RealTime Static

Asterisk RealTime Static

NOTE: You can only store a static config OR a RealTime config. You cannot, for example, store sip.conf and use sipfriends via RealTime.

NOTE: If you store sip.conf in the RealTime database, you need to rename/remove the text file otherwise the text file will superceed RealTime.

Extconfig.conf Setup

Add the following line, swapping your own personal values if you wish:


sip.conf => mysql,asterisk,ast_config


You can change mysql to odbc if you want to use odbc.
You can change asterisk to be the name of your database.
You can change ast_config to be the name of the table we will create below.

NOTE: You can bind multiple filenames to the same table, but any tables using RealTime static need to use the format below, not the format shown on the respective non-static RealTime page for that file. The files will be filtered by the `filename` field.

Database Table

NOTE: You can use any table name you wish, just make sure the table name matches what you have the family name bound to.

#
# Table structure for table `ast_config`
#

CREATE TABLE `ast_config` (
 `id` int(11) NOT NULL auto_increment,
 `cat_metric` int(11) NOT NULL default '0',
 `var_metric` int(11) NOT NULL default '0',
 `commented` int(11) NOT NULL default '0',
 `filename` varchar(128) NOT NULL default '',
 `category` varchar(128) NOT NULL default 'default',
 `var_name` varchar(128) NOT NULL default '',
 `var_val` varchar(128) NOT NULL default '',
 PRIMARY KEY  (`id`),
 KEY `filename_comment` (`filename`,`commented`)
) TYPE=MyISAM;



NOTE: The index created on the columns 'filename' and 'commented' is because RealTime does its SELECT query using those 2 columns everytime. That column id must also be unique.

The easiest way to get existing *.conf files into the database is by using bwk's perl script.

http://www.krisk.org/asterisk/ast2sql.pl

It actually doesn't remove inline comments, and Asterisk can be confused by them. Please remove them before you use the script.


Examples

To enable realtime static on your extensions file...let's say it looked like this:
[general]
static=yes

[globals]
CONSOLE=Console/dsp ; Console interface for demo

[default]
exten=_.,1,SetVar(extension=${EXTEN})
exten=_.,2,Macro(dial_agi_ver.1.0.0,${EXTEN},${channel})
exten=h,1,Goto(done,${extension},1)
and let's say you're using the table as defined above with an odbc defined as asterisk in your res_odbc.conf, you could use these insert statments to
INSERT INTO `ast_config` (`cat_metric` , `var_metric` , `filename` , `category` , `var_name` , `var_val` ) VALUES ('0','0','extensions.conf', 'general', 'static', 'yes');
INSERT INTO `ast_config` (`cat_metric` , `var_metric` , `filename` , `category` , `var_name` , `var_val` ) VALUES ('1','0','extensions.conf', 'globals', 'Console/dsp', 'yes');
INSERT INTO `ast_config` (`cat_metric` , `var_metric` , `filename` , `category` , `var_name` , `var_val` ) VALUES ('2','0','extensions.conf', 'default', 'exten', '_.,1,SetVar(extension=${EXTEN})');
INSERT INTO `ast_config` (`cat_metric` , `var_metric` , `filename` , `category` , `var_name` , `var_val` ) VALUES ('2','1','extensions.conf', 'default', 'exten', '_.,2,Macro(dial_agi_ver.1.0.0,${EXTEN},${channel})');
INSERT INTO `ast_config` (`cat_metric` , `var_metric` , `filename` , `category` , `var_name` , `var_val` ) VALUES ('2','2','extensions.conf', 'default', 'exten', 'h,1,Goto(done,${extension},1)');
and add this line to your extconfig.conf:
extensions.conf => odbc,asterisk,ast_config


Note: The table structure for realtime static[sic] is much different than the structure for other realtime tables. You must use the structure above for ALL config files using static. Commented records (where commented != 0) are ignored (or should be, honestly I haven't checked). Someone please who knows what the metric stuff is for please update this example. Thanks - Flobi.

Testing


Throw some data into the above table and issue an 'asterisk reload'. This should get the *.conf info you bound out from database. The /var/log/asterisk/debug should give info on any problems.

Cheers,
Matthew



See Also

Created by utdrmac, Last modification by Emanuele Deserti on Mon 27 of Nov, 2006 [16:49 UTC]

Comments Filter

Multiple tables

by Emanuele Deserti on Monday 27 of November, 2006 [17:02:55 UTC]
You can also use different tables for each configuration file:

File: extconfig.conf

extensions.conf => mysql,databasename,extensions_conf
iax.conf => mysql,databasename,iax_conf
sip.conf => mysql,databasename,sip_conf
voicemail.conf => mysql,databasename,voicemail_conf

And then use the same SQL to create multiple tables:

CREATE TABLE `sip_conf` (
`id` int(11) NOT NULL auto_increment,
`cat_metric` int(11) NOT NULL default '0',
`var_metric` int(11) NOT NULL default '0',
`commented` int(11) NOT NULL default '0',
`filename` varchar(128) NOT NULL default 'sip.conf', 
`category` varchar(128) NOT NULL default 'default',
`var_name` varchar(128) NOT NULL default '',
`var_val` varchar(128) NOT NULL default '',
PRIMARY KEY  (`id`),
KEY `filename_comment` (`filename`,`commented`)
) TYPE=MyISAM;

CREATE TABLE `iax_conf` (
`id` int(11) NOT NULL auto_increment, 
`cat_metric` int(11) NOT NULL default '0', 
`var_metric` int(11) NOT NULL default '0', 
`commented` int(11) NOT NULL default '0', 
`filename` varchar(128) NOT NULL default 'iax.conf', 
`category` varchar(128) NOT NULL default 'default', 
`var_name` varchar(128) NOT NULL default '', 
`var_val` varchar(128) NOT NULL default '', 
PRIMARY KEY  (`id`), 
KEY `filename_comment` (`filename`,`commented`) 
) TYPE=MyISAM;

...and similar for extensions.conf and voicemail.conf

Re: Explanation of metric

by waba on Saturday 22 of July, 2006 [12:54:56 UTC]
I've had a look at the * source code and behaviour on this topic. My conclusions (all this is per-filename, the rows are independent if their filename differs):

- If you are ever going to use var_metric, then do set cat_metric to something different per category. It's like what Jens explained, but the numbers don't have to follow any order (eg, 42, 1 and 999 are all fine)

- You can use var_metric to force the ordering of variables within a category (useful for example with sip.conf allow/disallow). In this case, variables with a lower metric will be evaluated first. So to get "disallow=all" then "allow=alaw", you can give 0 to disallow and 1 to allow.

- If you have some sets of variables for the same category, but with different cat_metric, then the set with the highest metric will entirely overwrite the other ones ("joe|secret|42" cat_metric=0, "joe|type|friend" cat_metric=1 -> there is no joe|secret).

Explanation of metric

by Jens on Thursday 06 of April, 2006 [00:11:55 UTC]
By looking at the source @ http://www.krisk.org/asterisk/ast2sql.pl it is clear that metric can be explained as follows:

cat_metric: each [category] in a config will have its own value, 0 for the first, 1 for the second and so on
var_metric: each variable inside each [category] will have its own value same a cat_metric.

in the example below:
CONSOLE in [globals] will have cat_metric=1 and var_metric=0

[general]
static=yes

[globals]
CONSOLE=Console/dsp ; Console interface for demo

[default]
exten=_.,1,SetVar(extension=${EXTEN})
exten=_.,2,Macro(dial_agi_ver.1.0.0,${EXTEN},${channel})
exten=h,1,Goto(done,${extension},1)

Static and realtime + the metrics

by Paul Sherwood on Monday 06 of February, 2006 [13:21:52 UTC]
Hi I am experimenting loading zapata.conf from realtime/MySQL.

I have had some luck, infact it has worked, I too could do with knowing what the metric stuff is, the comment out does work by the way.

The problem I am having is with the groups, they atill come under the channels section, but they do not as such have their own section, I am figuring that by adding a metric one can associate the various groups? This is quite hard to explain without a sample. But if the first group had a metric of 1 then all the relevant options (context, channel, callerid)in that group should share the same metric, and then group 2 will have a metric of 2 and so on and on??? This is 100% guess work.

I did get this working, then broke it again without making proper config notes/backup.....

Any help would be much appreciated, now have a very nice config. Multiple servers centrally configured. Works a treat excepting zapata.conf, will soon be post a blow by blow how to from the install to the config. Have spent much time figuring all this out and tuning it..... Too many install guides make assumptions that this or that is done and working, they are not that helpful.....

You can definately use static and realtime with the switch statement.






Re: I believe you can use a static and realtime config

by rob314 on Friday 13 of May, 2005 [16:44:34 UTC]
Can you document how you have the static configs for extensions.conf setup? Table structure and an example of the data would be really helpful.

I am running into the same problem where I have multiple contexts that I combine into one. In the past I would just build a context and then issue "include" statements to pull them all together. I can still do that in extensions.conf by building individual contexts with the "switch => Realtime/...." and then building my larger contexts with includes in the flat file but that kinda defeats the purpose of me using RealTime.

My goal is to be able to build my larger contexts using includes in my DB so that I can form my front end around a DB entirely — which I would obviously make available here when I have it completed.

Any input would be greatly appreciated!

bad link

by gmillerd on Wednesday 27 of April, 2005 [10:03:54 UTC]
Anyone have a source for this 'http://asterisk.bkw.org/load.txt'?
Edit

I believe you can use a static and realtime config

by Anonymous on Monday 13 of December, 2004 [02:57:49 UTC]
I store extensions.conf in the static config (since you have to contexts to put the switch => statements in), and also use it for realtime extensions with no problems.

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2008 VOIP-Info.org LLC

Powered by bitweaver