As a designer, I don't often build a production network environment in my work, and I often create a demo environment to check ideas, so I haven't done much server monitoring until now.
However, when I started using k8s
and GitLab CE
, the server configuration became complicated, and when a problem occurred, the server became too heavy and I could not log in to the server with ssh etc. in the first place. I had a problem, so I decided to install a monitoring tool.
Zabbix + docker-compose
Due to the above background, I was not very familiar with monitoring tools, but my senior at the company taught me the tools Zabbix
and MUNIN
. It seemed easier to use MUNIN
, but I thought that Zabbix
would be better when it comes to monitoring clusters of k8s
, so I decided to use Zabbix
this time.
Fortunately, the configuration of docker-compose
was officially uploaded, so I built it based on it, but it was very easy to build. This is also thanks to the wisdom of our predecessors!
Basically all servers are composed of ʻubuntu 20.04`. There is no problem with any number of clients to be monitored.
--Zabbix server x 1 --Monitored client x n
Basically, we will proceed according to the official website.
Docker
https://docs.docker.com/engine/install/ubuntu/
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
docker-compose
https://docs.docker.com/compose/install/
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
If it is left as it is, root authority is required to execute it, so make it possible for the current user to execute it.
sudo groupadd docker
sudo usermod -aG docker $(id -u -n)
After this, ** log in again for the settings to take effect. ** **
Zabbix Server
First, start the server. It was easy to start using docker-compose
.
clone
The official docker-compose
set is clone
.
git clone https://github.com/zabbix/zabbix-docker.git
cd zabbix-docker
Copy any configuration file as docker-compose.yaml
. I used docker-compose_v3_alpine_pgsql_latest.yaml
here.
cp docker-compose_v3_alpine_pgsql_latest.yaml docker-compose.yaml
By default, the time zone is not Japan, so change it.
nano .env_web
…
PHP_TZ=Asia/Tokyo
…
iptables
Open the ports required for communication.
sudo iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 10051 -j ACCEPT
Now that the settings are complete, start up.
docker-compose up -d
Log in. By default, the username is ʻAdmin(uppercase A) and the password is
zabbix`.
Go to Settings> Host> Zabbix server
.
By default, the interface part contains 127.0.0.1
, but remove it and enter zabbix-agent
in place of the DNS name. Also, set the connection method to DNS
.
I forgot to take a capture and took it later, so the number of hosts is already 2, but this completes the basic server settings!
Zabbix Agent
Next, set the client to be monitored and display it on the server.
It is provided by ʻapt`, so install it obediently.
sudo apt-get install zabbix-agent
Set up the agent.
sudo nano /etc/zabbix/zabbix_agentd.conf
There are various setting items, but the essential one is
Server=<IP address of Zabbix Server>
ServerActive=<IP address of Zabbix Server>
Hostname=<Arbitrary host name>
was. ** The host name set here is arbitrary, but you will need it later when setting it on the server side. ** **
Reboot for the settings to take effect.
sudo service zabbix-agent restart
iptables
Also open the communication port here.
sudo iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 10050 -j ACCEPT
Manual setting on multiple terminals is a pain, so I ran it with the following command.
SERVER_IP=<Server IP>
HOSTNAME=<hostname>
sudo sed -i -e "s/127.0.0.1/$SERVER_IP/g" -e "s/Hostname=Zabbix server/Hostname=$HOSTNAME/g" /etc/zabbix/zabbix_agentd.conf
sudo service zabbix-agent restart
sudo iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 10050 -j ACCEPT
Log in to the server and go to Settings> Hosts> Create Host
.
Is a required item. Use the host name you set earlier.
Go to the Templates tab and select any one. This time we will use Template OS Linux by Zabbix agent
.
After setting up to this point, press "Add" to complete the setting!
The introduction of the monitoring tool seemed difficult, but it was surprisingly easy to introduce. It's great that you could start Zabbix Server
with docker-compose
.
This time, I just introduced it and I can't follow the detailed usage, but it is a popular tool with many introductory articles, so I will study it from now on.
This article was created with full reference to the following articles.
[Procedure to start Zabbix 5.0 with Docker Compose](https://qiita.com/zembutsu/items/d98099bf68399c56c236#docker-%E3%81%A8-docker-compose-%E3%82%92%E3%82% BB% E3% 83% 83% E3% 83% 88% E3% 82% A2% E3% 83% 83% E3% 83% 97) [Install and monitor Zabbix-agent on your Ubuntu](https://chee-s.net/%E6%99%AE%E6%AE%B5%E4%BD%BF%E3%81% 84% E3% 81% AEubuntu% E3% 81% ABzabbix-agent% E3% 82% 92% E3% 82% A4% E3% 83% B3% E3% 82% B9% E3% 83% 88% E3% 83% BC% E3% 83% AB% E3% 81% 97% E3% 81% A6% E7% 9B% A3% E8% A6% 96% E3% 81% 99% E3% 82% 8B)