Load balanced monitoring
Introduction
The op5 Monitor backend can easily be used as a load balanced monitoring solution. The load balanced model looks like this.

The load balanced solution
•have two or more peers sharing the same task (the hosts to monitor)
•allows configuration at any of the peers
•make sure that all new config is distributed to the peers
•uses the peers to dived the load automatically
•keep tracks of when one peer go down, the other(s) take over the job.
Before we start
There are a few things you need to take care of before you can start setting up an load balanced monitoring. You need to make sure
•you have at least two op5 Monitor servers of the same architecture and op5 Monitor version up and running.
•op5 Monitor >=5.2 is installed and running on both machines.
•opened up the following TCP ports for communication between the servers
•15551, op5 Monitor backend communication port
•22, ssh (for the configuration sync).
•both included servers are to be found in DNS or the host file (/etc/hosts).
The configuration
Setting up the load balanced solution
This load balanced configuration will have two so called peers:
•peer01
•peer02
During the setup we will use the command:
mon
The mon command is used to make life a bit easier when it comes to setting up a load balanced solution. To get more detailed information about the command mon just execute like this:
mon --help
To setup a load balanced monitoring solution
1 Log in to one of the systems over ssh, as root.
2 Add the second peer to the configuration with the following command:
mon node add peer02 type=peer
3 Create and add ssh keys to and from the second peer by
as root user:
mon sshkey push --all
mon sshkey fetch --all
4 Add peer01 as a peer at peer02
mon node ctrl peer02 -- mon node add peer01 type=peer
5 Make the first initial configuration sync
mon oconf push
6 Restart and push the logs from peer01 to peer02:
mon node ctrl --self -- mon restart; sleep 3; mon oconf push
Adding a new peer
In this instruction we will have the following hosts:
•peer01
•peer02
•peer03 (This is the new one.)
To add a new peer
1 Login to the peer01 as root user over ssh.
2 Add the new peer to the configuration on peer01
mon node add peer03 type=peer
3 Get all ssh keys in place
mon sshkey push --all
mon sshkey fetch --all
4 Add the peers to one and each other
mon node ctrl peer02 -- mon node add peer03 type=peer
mon node ctrl peer03 -- mon node add peer02 type=peer
mon node ctrl peer03 -- mon node add peer01 type=peer
5 Manually push the op5 Monitor objects configuration to the new peer.
mon oconf push
6 Restart monitor on peer01 and send the configuration to all peers again.
mon node ctrl --self -- mon restart ; sleep 3 ; mon oconf push
Removing a peer
In this instruction we will remove a peer called:
peer02
The peer will be removed from all other peers configurations.
To remove a peer
1 Log in to peer01 as root over ssh.
2 Remove all peer configuration from peer02
mon node ctrl peer02 -- mon node remove peer01
mon node ctrl peer02 -- mon node remove peer03
3 Restart monitor on peer02
mon node ctrl peer02 -- mon restart
4 Remove peer02 from the rest of the peers, in this case peer03
mon node ctrl --type=peer -- mon node remove peer02
5 Restart the rest of the peers, in this case only peer03
mon node ctrl --type=peer -- mon restart
6 Remove peer02 from the host you are working from.
mon node remove peer02
7 Restart monitor on the host you are working from.
mon node ctrl -- mon restart
File synchronization
To synchronize files between servers add a sync paragraph in the file /opt/monitor/op5/merlin/merlin.conf
In the example below we will synchronize the htpasswd.users file from “peer01” to the peer “peer02”
peer peer02 {
address = <ip>
port = <port>
sync {
/opt/monitor/etc/htpasswd.users /opt/monitor/etc/htpasswd.users
}
}
Note that this is done per peer.
Folder synchronization
To synchronize folders to peers add a sync paragraph in the file /opt/monitor/op5/merlin/merlin.conf
In the example below we will synchronize the /opt/plugins/custom folder to the poller “peer02”
peer peer02 {
address = <ip>
port = <port>
sync {
/opt/plugins/custom/
}
}
Note that this is done per peer
More information
For more information and a more complex example please take a look at the howto in the git repository of the opensource project of Merlin: