Zabbix - mata-elang-stable/MataElang-Platform GitHub Wiki
We use Zabbix as a monitoring system for Mata Elang.
Item | Value |
---|---|
Zabbix server | 172.16.2.110 |
Zabbix agent | (Installed on all sensors and servers) |
Zabbix user / password | Admin (default password is zabbix) |
MySQL root user / password | root (password will be set below) |
MySQL zabbix user / password | zabbix (password will be set below) |
ā Ubuntu 20.04 LTS installed and updated with the following command.
sudo apt update && sudo apt -y upgrade
ā Time Zone and NTP already set.
ā Docker 20.10 or later installed with the following command.
sudo apt -y install docker.io
ā Docker Compose 2.13 or later installed with the following command.
sudo curl -L "https://github.com/docker/compose/releases/download/v2.13.0/docker-compose-$(uname -s)-$(uname -m)"\
-o /usr/bin/docker-compose && sudo chmod +x /usr/bin/docker-compose
git clone https://github.com/mata-elang-stable/zabbix-asset.git ~/zabbix
.MYSQL_ROOT_PASSWORD
to change the MySQL root password before initial setup.
nano ~/zabbix/env_vars/.MYSQL_ROOT_PASSWORD
.MYSQL_PASSWORD
to change the MySQL zabbix password before initial setup.
nano ~/zabbix/env_vars/.MYSQL_PASSWORD
sudo docker-compose -f ~/zabbix/docker-compose.yaml up -d
ā Confirm the containers are running.
sudo docker-compose -f ~/zabbix/docker-compose.yaml ps -a
Result
NAME COMMAND SERVICE STATUS PORTS
zabbix-db_data_mysql-1 "sh" db_data_mysql exited (0)
zabbix-mysql-server-1 "docker-entrypoint.sā¦" mysql-server running
zabbix-zabbix-server-1 "/usr/bin/tini -- /uā¦" zabbix-server running 0.0.0.0:10051->10051/tcp, :::10051->10051/tcp
zabbix-zabbix-web-nginx-mysql-1 "docker-entrypoint.sh" zabbix-web-nginx-mysql running (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcp, 0.0.0.0:443->8443/tcp, :::443->8443/tcp
wget -P ~/zabbix https://repo.zabbix.com/zabbix/6.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.2-4%2Bubuntu20.04_all.deb
sudo dpkg -i ~/zabbix/zabbix-release_6.2-4+ubuntu20.04_all.deb
sudo apt update && sudo apt -y install zabbix-agent
zabbix_agentd.conf
to configure the agent.
sudo nano /etc/zabbix/zabbix_agentd.conf
Configuration
š Set the IP address of the Zabbix servers to ZABBIX_SERVER_IP_OR_NAME
.
ā The additional value 172.16.238.0/24
, which was set on docker-compose.yaml
, is required when the Zabbix server and agent run on the same host.
š Set a hostname you like for the Zabbix agent to HOSTNAME_OF_AGENT
. It's recommended to name differently for each agent to identify easily.
### Line 117: Set the IP or DNS names of the Zabbix server
#Server=127.0.0.1
Server=<ZABBIX_SERVER_IP_OR_NAME (e.g. 172.16.2.110)>,172.16.238.0/24
### Line 182: Set the hostname of the Zabbix agent.
#Hostname=Zabbix server
Hostname=<HOSTNAME_OF_AGENT (e.g. zabbix)>
sudo systemctl enable zabbix-agent
sudo systemctl restart zabbix-agent
ā Confirm the agent service is active.
systemctl status zabbix-agent
Click here to see the result.
ā zabbix-agent.service - Zabbix Agent
Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-01-01 00:17:15 WIB; 39s ago
- URL:
http://<ZABBIX_SERVER_IP_OR_NAME (e.g. 172.16.2.110)>/
š The followings are what you should do for monitoring servers.
- Change Admin password.
- Change the time zone of the Admin user.
- Change the interface (IP address) of the host named "Zabbix server" from 127.0.0.1 to the actual address.
- Create hosts in configuration menu, as many as you need to monitor. (name, template, group, interface type, and IP address)
- Configure notifications. (media types, users, and actions)
How to change Admin password and time zone.
How to create a host.
Item | Value |
---|---|
Host name | Monitored hostname |
Templates | [Select] -> Templates/Operating systems -> Linux by Zabbix agent
|
Groups | [Select] -> Linux servers
|
Interfaces | [Add] -> Agent -> IP address of Monitored host |
- And then save your configuration.
- Wait until Zabbix Server identifies your monitored host.
- If your configuration is correct, the availability sign will turn green.
How to add an email notification.
Email
.
- Configure
Email
settings. - Test the settings.
Admin
.
- Attach [Media (Email)] to
Admin
. - Set an email address to [Send to].
- Attach
Admin (Zabbix Administrator)
to [Send to users].
Click to view screen image
Click to show commands
ā Show service status
sudo docker-compose -f ~/zabbix/docker-compose.yaml ps -a
Result
NAME COMMAND SERVICE STATUS PORTS
zabbix-db_data_mysql-1 "sh" db_data_mysql exited (0)
zabbix-mysql-server-1 "docker-entrypoint.sā¦" mysql-server running
zabbix-zabbix-server-1 "/usr/bin/tini -- /uā¦" zabbix-server running 0.0.0.0:10051->10051/tcp, :::10051->10051/tcp
zabbix-zabbix-web-nginx-mysql-1 "docker-entrypoint.sh" zabbix-web-nginx-mysql running (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcp, 0.0.0.0:443->8443/tcp, :::443->8443/tcp
ā Start services
sudo docker-compose -f ~/zabbix/docker-compose.yaml up -d
ā Stop services (and remove containers)
sudo docker-compose -f ~/zabbix/docker-compose.yaml down
ā Stop services (and keep containers)
sudo docker-compose -f ~/zabbix/docker-compose.yaml stop
ā Restart services
sudo docker-compose -f ~/zabbix/docker-compose.yaml restart
ā Show agent status
systemctl status zabbix-agent
Result
ā zabbix-agent.service - Zabbix Agent
Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-01-01 00:17:15 WIB; 39s ago
ā Start agent
sudo systemctl start zabbix-agent
ā Stop agent
sudo systemctl stop zabbix-agent
ā Restart agent
sudo systemctl restart zabbix-agent
ā Login to MySQL
sudo docker-compose -f ~/zabbix/docker-compose.yaml exec mysql-server mysql -u zabbix -p
sudo docker-compose -f ~/zabbix/docker-compose.yaml exec mysql-server mysql -u root -p
ā Clean up the Zabbix server installation including MySQL database.
sudo docker ps -a
sudo docker images -a
sudo docker network ls
sudo docker volume ls
sudo docker system prune -a
sudo docker volume prune
sudo rm -rf ~/zabbix/zbx_env
ā Show environment variables
sudo docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' zabbix-zabbix-server-1
sudo docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' zabbix-zabbix-web-nginx-mysql-1
sudo docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' zabbix-mysql-server-1
ā Show Zabbix Server log
sudo docker-compose -f ~/zabbix/docker-compose.yaml logs zabbix-server
sudo docker-compose -f ~/zabbix/docker-compose.yaml logs zabbix-web-nginx-mysql
sudo docker-compose -f ~/zabbix/docker-compose.yaml logs mysql-server
ā Show Zabbix Agent log
cat /var/log/zabbix/zabbix_agentd.log
ā Show Zabbix Server version
sudo docker-compose -f ~/zabbix/docker-compose.yaml exec zabbix-server zabbix_server -V
ā Show nginx version
sudo docker-compose -f ~/zabbix/docker-compose.yaml exec zabbix-web-nginx-mysql nginx -v
ā Show MySQL version
sudo docker-compose -f ~/zabbix/docker-compose.yaml exec mysql-server mysql --version
ā Show Zabbix Agent version
zabbix_agentd --version
ā Show Docker version
sudo docker version
ā Show Docker Compose version
docker-compose version
ā Show OS version
cat /etc/os-release