Monitoring extensions on multiple servers
Hello all!
This is a combination question / tutorial for how to monitor extensions on multiple servers (since the way we have it set up is almost certainly not ideal). My colleague and I set out today to try to get FOP2 to be able to monitor extensions on other FreePBX servers. Referring to the documentation at http://www.fop2.com/documentation-confi ... ngMultiple showed that it should be as simple as adding additional parameters in /usr/local/fop2/fop2.cfg, specifically:
for each other server you want to monitor. However, it's not quite that easy. While that does connect you to the AMI of the other server (assuming you use remote_mgr as the manager_user; we couldn't get it to work with admin), it doesn't make any buttons for you to monitor. The script /usr/local/fop2/autoconfig-buttons-freepbx.sh won't make the buttons either, even if you define buttons in /usr/local/fop2/buttons_custom.cfg (which gets run at the end of /usr/local/fop2/autoconfig-buttons-freepbx.sh if it exists)... or rather, it will (maybe, still not sure on that), but you can't see it because it's not part of any groups, and since users see what they see on FOP2 based on what groups they're allowed to view, it will never show up for anyone. So you need to make it part of a group, which gets done in /usr/local/fop2/autoconfig-users-freepbx.sh.
Basically, you can see what happens when you run /usr/local/fop2/autoconfig-users-freepbx.sh (or /usr/local/fop2/autoconfig-buttons-freepbx.sh for that matter); it just generates a bunch of text from God knows where (it's all detailed in the script itself but there was no way I could read it all). Presumably, when you restart FOP2 with
So yours might look like:
where 1235 is your extention and 2001 is an extension on a remote server. So what this does is it makes the remote extension 2001 part of the allLocalAndRemote group (along with all those other extensions including yours) and then the next line specifically defines you as a user with the ability to view the allLocalAndRemote group. Now of course /usr/local/fop2/buttons_custom.cfg has to have your button(s) defined like so:
So that's how we got it done, and while we know that cannot possibly be the right way to do it, we couldn't find a better way (yet). If anyone knows of a better way, please please let us know here.
This is a combination question / tutorial for how to monitor extensions on multiple servers (since the way we have it set up is almost certainly not ideal). My colleague and I set out today to try to get FOP2 to be able to monitor extensions on other FreePBX servers. Referring to the documentation at http://www.fop2.com/documentation-confi ... ngMultiple showed that it should be as simple as adding additional parameters in /usr/local/fop2/fop2.cfg, specifically:
manager_host =
manager_port =
manager_user =
manager_secret =
for each other server you want to monitor. However, it's not quite that easy. While that does connect you to the AMI of the other server (assuming you use remote_mgr as the manager_user; we couldn't get it to work with admin), it doesn't make any buttons for you to monitor. The script /usr/local/fop2/autoconfig-buttons-freepbx.sh won't make the buttons either, even if you define buttons in /usr/local/fop2/buttons_custom.cfg (which gets run at the end of /usr/local/fop2/autoconfig-buttons-freepbx.sh if it exists)... or rather, it will (maybe, still not sure on that), but you can't see it because it's not part of any groups, and since users see what they see on FOP2 based on what groups they're allowed to view, it will never show up for anyone. So you need to make it part of a group, which gets done in /usr/local/fop2/autoconfig-users-freepbx.sh.
Basically, you can see what happens when you run /usr/local/fop2/autoconfig-users-freepbx.sh (or /usr/local/fop2/autoconfig-buttons-freepbx.sh for that matter); it just generates a bunch of text from God knows where (it's all detailed in the script itself but there was no way I could read it all). Presumably, when you restart FOP2 with
service fop2 restart
it runs /usr/local/fop2/fop2.cfg, which in turn runs /usr/local/fop2/autoconfig-users-freepbx.sh, which in turn runs /usr/local/fop2/autobuttons.cfg, which all that does is run /usr/local/fop2/autoconfig-buttons-freepbx.sh, which basically generates a ton of specially formatted text and sends it off somewhere, somehow. So at this point all we knew was that, based on the text output of /usr/local/fop2/autoconfig-users-freepbx.sh, groups were probably defined there. So in our case, what we did was defined a group manually at the end of that script and then manually defined a user at the end of that script that belonged to that group. Basically, in /usr/local/fop2/autoconfig-users-freepbx.sh:
[original_script]
Lots of scripting
[/original_script]
group=allLocalAndRemote:[Put all the extensions you'd like to monitor here, both local and remote, in the format of SIP/1234]
user=[extension]:[password]:[FOP2permissions]:allLocalAndRemote
So yours might look like:
[original_script]
Lots of scripting
[/original_script]
group=allLocalAndRemote:SIP/1234, SIP1235, SIP/1236, SIP/2001
user=1235:5321:all:allLocalAndRemote
where 1235 is your extention and 2001 is an extension on a remote server. So what this does is it makes the remote extension 2001 part of the allLocalAndRemote group (along with all those other extensions including yours) and then the next line specifically defines you as a user with the ability to view the allLocalAndRemote group. Now of course /usr/local/fop2/buttons_custom.cfg has to have your button(s) defined like so:
[SIP/2001]
type=extension
extension=2001
context=from-internal
label=remote-extension-name
privacy=none
server=ip-of-remote-server
and some of those fields are probably just wrong, like maybe context=from-internal, but it works well enough that the button actually shows up for whoever you defined as a user at the end of /usr/local/fop2/autoconfig-users-freepbx.sh (in the example, it was 1235).So that's how we got it done, and while we know that cannot possibly be the right way to do it, we couldn't find a better way (yet). If anyone knows of a better way, please please let us know here.
Comments
I have suggested in several posts how to do it, but we cannot provide a set of ready made scripts as it depends on several factors outside of FOP2 itself. Basically we suggest to do:
* add the extra servers in fop2.cfg via manager_ entries.
* passwordless ssh connection between the central fop2 server and remove asterisk servers
* copy fop2admin to all remote asterisk servers
* copy autoconfig-buttons-freepbx.sh and autoconfig-users-freepbx.sh to remote asterisks servers
* modify remote autoconfig scripts to exclude listing of park and dahdi trunks, and to add server=192.168.x.x
* modify central autoconfig scripts to execute remote scripts via ssh (with some other modifications to update some of the default fop2 groups)
The above can be made much easier by configuring buttons and permissions manually, just add the additional manager entries and config buttons by hand, similar to your solution.
Doing the former requires a fairly amount of work. Autoconfig scripts in fop 2.27 beta have some lines commented for this specific purpose, but you must uncomment them while commenting the original lines, and also modify some sql queries to add the server line, etc.
simply add
manager_host=remote ip
manager_port=5038
manager_user=admin
manager_secret=remote secret
under the other manger_ entries?
I've 3 extensions to get monitored remotely, I guess it would be the easiest way to add them manually, but where and how?
is it necessary to grant passwordless root ssh login to the remote asterisk, or may I use another user for it?
There is one caveat, as this buttons won't be part of any groups, you won't be able to use group filtering. So in order to see them you will have to edit any FOP2 user you have and uncheck all groups (that means it won't have any group filtering, and buttons defined in the above file will be shown).