Lesstion 2 - Zabbix Agent 2 on CentOS 7 server used to monitor Mongodb Replica Set

02/03/2023 - 1 phút

Follow  on Google News

Step 1: Install Zabbix Agent 2

  • Install Zabbix repository
yum update -y
 rpm -Uvh https://repo.zabbix.com/zabbix/6.2/rhel/7/x86_64/zabbix-release-6.2-3.el7.noarch.rpm
yum clean all
  • Install Zabbix Agent2
yum install zabbix-agent2 zabbix-agent2-plugin-* -y
  • Start Zabbix Agent2 process
systemctl restart zabbix-agent2
systemctl enable zabbix-agent2

Step 2: Configure Zabbix Agent 2 to point to Zabbix Server

As in the Zabbix server installation at address 10.19.2.1

Use the following command to open the Zabbix configuration file:

nano /etc/zabbix/zabbix_agent2.conf

Find and change the configuration:

ListenIP=0.0.0.0
Server=10.19.2.1
Hostname=Zabbix Mongodb

Save and restart the service:

systemctl restart zabbix-agent2

Step 2: Log in to Zabbix and add to hosts: http://10.19.2.1/zabbix/zabbix.php?action=host.view

Select as shown in the image

Step 3: Configure the MongoDB node by Zabbix agent 2 template

  1. Create a MongoDB user for monitoring

When the agent has been deployed and configured, you need to ensure that you have a MongoDB user that we can use for monitoring purposes. Below you can find a brief example of how you can create a MongoDB user:

Access mongodb using the command:

mongosh

Switch to the MongoDB admin database:

use admin

Create a user with the ‘userAdMinanyDatabase‘ role:

db.createUser(
... {
..... user: "zabbix_mon",
..... pwd: "zabbix_mon",
..... roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
..... }
... )

The username for the newly created user is ‘zabbix_mon' The password is also ‘zabbix_mon'

  1. Configure Macros as shown in the image below
  • {$MONGODB.PASSWORD} – MongoDB user name. In our example, we will set this to zabbix_mon
  • {$MONGODB.USER} – MongoDB password. In our example, we will set this value to zabbix_mon
  • {$MONGODB.CONNSTRING} – MongoDB connection string. Specify the MongoDB address and port where Zabbix Agent 2 will connect and perform data collection

You can refer to 2 more articles: