Server monitoring: Server monitoring is a big concern at work stations. Server Monitoring is the process of monitoring a server’s system resources like CPU Usage, Memory Consumption, I/O, Network, Disk Usage, Process and etc.
Zabbix is an open-source monitoring tool supports on Unix, BSD, Windows, MacOS platforms. Zabbix architecture is master and agent. so Master sits on one server, agents sits on all remote servers needs to monitor through zabbix.
In this article we are going to Install zabbix4.x and configure to monitor the EC2 instance
Zabbix4.x Installation :
Zabbix repository:
- wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3+bionic_all.deb
- dpkg -i zabbix-release_4.0–3+bionic_all.deb
- apt update
Install Zabbix server and UI:
- apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
After Installation we will go with the mysql_secure Installation for authentication
2. mysql_secure_installation
It will prompt as shown below:
Enter current password for root (enter for none): press enter
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
— Dropping test database…
… Success!
— Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
Now login to mysql shell using below command
mysql -uroot -p
Now we are creating a schema for the zabbix, create a user and grant all privileges on the zabbix schema using below commands
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by ‘password’;
mysql> grant all privileges on zabbix.* to zabbix@localhost;
Zabbix server host import initial schema and data. It will prompt for user password
cd /usr/share/doc/zabbix-server-mysql/
gunzip create.sql.gz
mysql -uroot -p zabbix < create.sql
Configure the DB details in zabbix_server.conf file located at /etc/zabbix/zabbix_server.conf
DBPassword=password
Note: If you created different username, password and schema, updated those in zabbix_server.conf file with respective
Configure PHP for zabbix UI
vim /etc/zabbix/apache.conf
php_value date.timezone Asia/kolkata
Now start zabbix server
systemctl restart zabbix-server zabbix-agent apache2
systemctl enable zabbix-server zabbix-agent apache2
Open browser and access IP/zabbix
keep on going with next step, Update mysql user and password
Default username: Admin and default password: zabbix
Agent also Installed here, so to configure the agent we will update in the /etc/zabbix/zabbix_agentd.conf file
server: zabbix server IP
HostName: give some name (This name we willl update in UI also)
Zabbix Agent Installation on other EC2 Instance:
Add Zabbix repo:
dpkg -i zabbix-release_4.0–2+bionic_all.deb
apt-update
apt-get install zabbix-agent
Note: Kindly whitelist the zabbix server IP on agent security group, and agent IP on zabbix server security groups
update the zabbix_agentd.conf file located at /etc/zabbix/zabbix_agentd.conf
server: zabbix server Internal IP
HostName: ec2agent
restart the zabbix-agent service
configure Agent server on Zabbix UI
configurations → Hosts → create host
update:
Hostname: updated the name as per zabbix_agentd.conf file
visible name: you can mention any name
groups:
IP: agent internal IP
Now go to templates
here we can add our customised templates as well predefined templates. For testing purpose I am adding ICMP, http service templates
Note: enable icmp traffic on security groups
Test case1:
- We have added http and https monitoring templates to the agent nodes, but we did not installed apache2 on the server, so zabbix should show an alert now
Test case2:
- Now we have Installed apache2, so now zabbix server should show that http service has resolved
References: