FreePBX | Register | Issues | Wiki | Portal | Support

Modifying extconfig.conf


#1

Hello,

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.

Thanks,
Fraser


(Lorne Gaetz) #2

File a feature request to have FreePBX #include a custom .conf file for user edits, assuming that file supports includes.
https://issues.freepbx.org/


#3

Thanks Lorne - I’ve created this now - https://issues.freepbx.org/browse/FREEPBX-18039

Is there any workaround that I can do in the meantime to prevent this file being modified?

What is Big Module Object? Do I need it and can I disable it?

Fraser.


(Lorne Gaetz) #4

The only thing I can think of is to make the file immutable which may have unintended consequences.


(Dave Burgess) #5

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.


#6

Hi Dave,

I am trying to log queue_log to mysql so I need to add the following lines:

[settings]
queue_log => mysql,asteriskcdrdr

I do not know of any other file locations of where this can be added - do you?

I’m aware that the same queue information is stored in /var/log/asterisk/queue_log but I require it in MySQL.

Thanks,
Fraser


(Dave Burgess) #7

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.


#8

Hi Dave,

Can you please elaborate?

Thanks,
Fraser.


(Dave Burgess) #9

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.


#10

Thank you @cynjut for taking the time to explain.

I tried the following in extensions_custom.conf

[settings]+
queue_log => mysql,asteriskcdrdr

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?

Thanks,
Fraser.


#11

I tried the following in extensions_custom.conf

[settings]+
queue_log => mysql,asteriskcdrdr

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 :frowning:

Fraser.


#12

If I do this, FreePBX fails to reload.

Any other ideas?


#13

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


(Rob Thomas) #14

There is a BMO Realtime class - that apparently I wrote a few years ago!

If it works like it says it does, this should do the trick

<?php
include '/etc/freepbx.conf';
FreePBX::Realtime()->enableQueueLog();

Then just run that file and then ‘fwconsole reload’ and it should be present in the file. No promises :sunglasses:


#15

Hi Rob,

I think this is what I’m after - Thank you!

But I’m a little unsure how to enable it - Can you explain please?

Thanks.
Fraser


(Rob Thomas) #16

Put that into a file, and run php filename


#17

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!

;extconfig.conf
#include extconfig_custom.conf

;extconfig_custom.conf
[settings]
queue_log => mysql,asteriskcdrdb

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 :slight_smile: ) to monitor extconfig.conf and alert me if it gets modified. Thank you to @cynjut for helping also.

Fraser.


(Rob Thomas) #18

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;

queue_log_to_file=yes

(system) closed #19

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.