How would one write to /etc/asterisk/extconfig.conf ?
;--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. ;
;--------------------------------------------------------------------------------;
; For information on adding additional paramaters to this file, please visit the ;
; FreePBX.org wiki page, or ask on IRC. This file was created by the new FreePBX ;
; BMO - Big Module Object. Any similarity in naming with BMO from Adventure Time ;
; is totally deliberate. ;
;--------------------------------------------------------------------------------;
I need to add a couple of lines of code for Realtime monitor. When I add the code and do
core reload
then everything works great.
Then I do:
fwconsole reload
and, as expected, the file is overwritten.
Usually, modifications to config files is done in _custom.conf files however there is no extconfig_custom.conf file.
One quick question. Why does this information need to be in extconfig.conf? Are you absolutely certain it canât be stored anywhere else, or that it canât be included in another config file that has extensibility already built in.
No offense, but the entire change discussion is predicated on your assumption that this code canât go anywhere else. It might be that you can simply include it in another file and have it work.
BMO is the data hiding model the entire system is based on. You do need it and you canât disable it. Itâs also a big deal when implementing it - I developed a FreePBX extension that didnât use it and upgrading to BMO was such a radical and far-reaching change, that I would have to start over to change to it.
I donât yet, but now that we know what you are asking, there might be some other places it can be added. For example, many of the settings for the system allow for the use of the construct âsettingsâ where the â(+)â extends the functionality of the settings stanza.
Let us look a little bit and see if anyone can find an override or custom file where this could go.
While I donât know for sure the settings in extconfig.conf can be extended this way, most of the rest of the âentries in square bracketsâ (like contexts) can be âadded toâ using the â+â syntax. So, for example, if I wanted to extend the functionality of a FreePBX managed and standard stanza (even though this example is completely made up) called âDaveDataâ, in the immutable (FreePBX written) file, the context â[DaveData]â would appear. If I want to âextendâ that context, I could add in (pretty much any) file that gets loaded later a custom context called âDaveDataâ. This tells the system that I want to add whatever is listed below (in this contextual reference) to the existing context called âDaveDataâ.
This technique is often used to extend the functionality of things like PJ-SIP or the special contexts added as part of the support for âChan-SCCP-Bâ channel driver. This way, the systemâs standard contexts arenât overridden, itâs more like they are overloaded (in the C++/object oriented meaning) to extend the context to include functionality that the standard stanza doesnât normally include.
Note that this extensibility is available for many parts of the system, but I donât know if extconfig.conf is one such system part. One attempt recently to do this for PJ-SIP failed because the context name was reused several times for different things and the system wasnât sure which of these duplicates needed amended. My suggestion would be to add it to one of the *_custom.conf files that the system already supports and see if it works. If it does, youâre golden: if it doesnât, you know one solution that doesnât work and are no worse off than you are right now.
But unfortunately, my queue_log still doesnât update after fwconsole reload
I may need to look at watching /var/log/asterisk/queue_log with tail -f -n 1 and inserting this to SQL by the means of a script, unless you have any other ideas?
So I had a look online and it seems the correct syntax is
[content] (+)
I tried putting this in res_mysql.conf but then asterisk wouldnât load. I tried above and below my SQL settings. If I put the code in extensions_custom.conf then Asterisk does start, but it seems the code is ignored so Iâm no further forward
One option might be to use incron to rewrite the file after anytime FreePBX reverts it. You may need to add an âatserisk reloadâ after that fact also
Thank you @xrobau - Iâve done that. php filename completes with no error. I then ran fwconsole reload. Also completes with no error.
cat /etc/asterisk/extconfig.conf looks like this:
;--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. ;
;--------------------------------------------------------------------------------;
; For information on adding additional paramaters to this file, please visit the ;
; FreePBX.org wiki page, or ask on IRC. This file was created by the new FreePBX ;
; BMO - Big Module Object. Any similarity in naming with BMO from Adventure Time ;
; is totally deliberate. ;
;--------------------------------------------------------------------------------;
I added ;test to the extconfig.conf and issued fwconsole reload again. I check extconfig.conf and my comment was still there! So I now added:
[settings]
queue_log => mysql,asteriskcdrdb
Ran fwconsole reload again and checked extconfig.conf to ensure my code is still there and the whole file has been overwritten!
Strange how the commented line survived the reload so I repeated a few times and it seems that the file remains in tack during a reload with comments.
Further testing shows that the file gets overwritten when it contains the following line
queue_log => mysql,asteriskcdrdb
I was however able to add an #include which survived the fwconsole reload so Iâve put my config in extconfig_custom.conf and it seems to work ok now. I can see my queue_log databases updating again so Iâm delighted!
Thank you to @lgaetz for pointing me in the direction about the #includes approach. Iâll just need to keep an eye on extconfig.conf to ensure it doesnât get overwritten. Iâll look into incron as mentioned earlier by @dicko (thank you ) to monitor extconfig.conf and alert me if it gets modified. Thank you to @cynjut for helping also.
As I remembered writing about this, and wanting to enable it myself, I realised Iâd forgotten the important bit - the ACTUAL correct command is:
php -r "
include '/etc/freepbx.conf';
FreePBX::Realtime()->enableQueueLog();
FreePBX::Realtime()->write();"
Which does enable it:
# cat /etc/asterisk/extconfig.conf
;--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. ;
;--------------------------------------------------------------------------------;
; For information on adding additional paramaters to this file, please visit the ;
; FreePBX.org wiki page, or ask on IRC. This file was created by the new FreePBX ;
; BMO - Big Module Object. Any similarity in naming with BMO from Adventure Time ;
; is totally deliberate. ;
;--------------------------------------------------------------------------------;
#include extconfig_custom.conf
[settings]
queue_log=odbc,asteriskcdrdb,queuelog
#
Also, if you want to log to file AND to database, you need to add this line to /etc/asterisk/logger_general_custom.conf;