hw
2018-Dec-05 14:31 UTC
[asterisk-users] how to use a database (was: figuring out what happened to a call)
On 12/05/2018 01:19 PM, Antony Stone wrote:> On Wednesday 05 December 2018 at 13:04:57, hw wrote: > >> On 12/04/2018 07:07 PM, Antony Stone wrote: >>> On Tuesday 04 December 2018 at 16:11:39, hw wrote: >>>> On 12/01/2018 05:30 PM, Marcelo Terres wrote: >>>>> Queue_log >>>> >>>> Thanks! >>>> >>>> That's not really it; however, how do I make it so that asterisk writes >>>> this information right away into a mariadb database instead of into a >>>> file so that I could actually use it? >>> >>> Send your queue_log entries to odbc? >> >> odbc? Seriously? > > Yes, it's the preferred method of talking to databases from Asterisk.After reading some documentation, anything else but odbc appears to be more or less deprecated :/> If you want to use the MySQL-specific driver / connector, you can still use > that for some things, but Voicemail in a database can only be done via ODBC, > for example. > >>> It's a setting in extconfig.conf. >> >> Does mysql not work? It's mentioned there, too. > > By all means try it - if it's mentioned, it'll probably work, but ODBC is the > more generic and better-supported way of using databases with Asterisk.Since it really seems to be the most reasonable choice, I've set up an odbc connection and used alembic to create tables in a database for asterisk. Now how is this managable? Is there a tool that reads the files I have and enters the configuration into the database? And when changes are to be made, editing configuration files is tremendously easier than going through the tables in the database and try to make the changes there. For now, can I make it so that only the queue_log is written into the database? I don't see a table for that. How dynamic are changes made in the database? For example, if I want to have an extension 'foobar' and want to ring different devices depending on some factors (like time of day, for example), can I modify the entry in the database for the device to ring from 'bar' to 'baz', and baz will ring instead of bar from thereon? That seems to be what this is intended for; in any case, it's what I'm going to need, which is why I went to all these lengths to connect to a database. Is it possible to use configuration from both the database and the files at the same time? That would save me converting all the entries in the files for now.
Antony Stone
2018-Dec-05 16:00 UTC
[asterisk-users] how to use a database (was: figuring out what happened to a call)
On Wednesday 05 December 2018 at 15:31:38, hw wrote:> On 12/05/2018 01:19 PM, Antony Stone wrote: > > On Wednesday 05 December 2018 at 13:04:57, hw wrote: > >> On 12/04/2018 07:07 PM, Antony Stone wrote: > >>> On Tuesday 04 December 2018 at 16:11:39, hw wrote: > >>>> On 12/01/2018 05:30 PM, Marcelo Terres wrote: > >>>>> Queue_log > >>>> > >>>> Thanks! > >>>> > >>>> That's not really it; however, how do I make it so that asterisk > >>>> writes this information right away into a mariadb database instead of > >>>> into a file so that I could actually use it? > >>> > >>> Send your queue_log entries to odbc? > >> > >> odbc? Seriously? > > > > Yes, it's the preferred method of talking to databases from Asterisk. > > After reading some documentation, anything else but odbc appears to be > more or less deprecated :/Indeed.> > If you want to use the MySQL-specific driver / connector, you can still > > use that for some things, but Voicemail in a database can only be done > > via ODBC, for example. > > > >>> It's a setting in extconfig.conf. > >> > >> Does mysql not work? It's mentioned there, too. > > > > By all means try it - if it's mentioned, it'll probably work, but ODBC is > > the more generic and better-supported way of using databases with > > Asterisk. > > Since it really seems to be the most reasonable choice, I've set up an > odbc connection and used alembic to create tables in a database for > asterisk. > > Now how is this managable? Is there a tool that reads the files I have > and enters the configuration into the database?Not that I know of.> And when changes are to be made, editing configuration files is tremendously > easier than going through the tables in the database and try to make the > changes there.Okay, so carry on using config files if you want to. I was only answering your question about getting Asterisk Queue logs *out* into a database table; I wasn't recommending anything about reading config file *from* a database (although this is indeed possible if you want to).> For now, can I make it so that only the queue_log is written into the > database?Yes.> I don't see a table for that.You need to create that for yourself. Asterisk can write to database tables, but doesn't help you set them up, for reasons I can't comment on.> How dynamic are changes made in the database?If by "dynamic" you mean "quickly used" then the answer is "immediately".> For example, if I want to have an extension 'foobar' and want to ring > different devices depending on some factors (like time of day, for example), > can I modify the entry in the database for the device to ring from 'bar' to > 'baz', and baz will ring instead of bar from thereon?Yes.> That seems to be what this is intended for; in any case, it's what I'm going > to need, which is why I went to all these lengths to connect to a database.Okay, sounds good, then.> Is it possible to use configuration from both the database and the files > at the same time?Yes.> That would save me converting all the entries in the files for now.Yes. Antony. -- What do you get when you cross a joke with a rhetorical question? Please reply to the list; please *don't* CC me.
On 12/05/2018 05:00 PM, Antony Stone wrote:> On Wednesday 05 December 2018 at 15:31:38, hw wrote: >> I don't see a table for that. > > You need to create that for yourself. > > Asterisk can write to database tables, but doesn't help you set them up, for > reasons I can't comment on.How do I know what the schema needs to be? Does anybody have a scheme for the queue_log table (and maybe others)? Do I get to see the queries that are being used to write this data, or do I need to form them myself and enter them into some configuration file?>> How dynamic are changes made in the database? > > If by "dynamic" you mean "quickly used" then the answer is "immediately".There's a note in some configuration file saying that dynamic extensions are deprecated and suggesting to use func_odbc instead. This func_odbc seems to be the most awkward way anyone could think of for this, though.>> For example, if I want to have an extension 'foobar' and want to ring >> different devices depending on some factors (like time of day, for example), >> can I modify the entry in the database for the device to ring from 'bar' to >> 'baz', and baz will ring instead of bar from thereon? > > Yes.And IIUC the extension would use something like 'Dial(SIP/ODBC_PICK_USER(...))' after defining a query for my ..._PICK_USER function in func_odbc.conf to return what to dial depending on the argument(s) supplied? How do I make asterisk reload func_odbc.conf? Or is that not needed?>> Is it possible to use configuration from both the database and the files >> at the same time? > > Yes.So far, that seems to work fine :)