Provision Amazon Linux 2 EC2 with static IP and ports 22, 80, 443 and 10051 open in the security group.
sudo yum update -y
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 git
sudo amazon-linux-extras install docker
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -a -G docker ec2-user
docker infoIf you run into issues with the user ec2-user running docker info then you will need to reboot. This is a peculiarlarity with Amazon Linux 2.
sudo rebootReference https://docs.docker.com/compose/install/ to get the latest version of docker-compose.
At the time of writing this document the current version of docker-compose was 1.25.5
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --versionNote: If the command docker-compose fails after installation, check your path. You can also create a symbolic link to /usr/bin or any other directory in your path.
For example:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-composeUse the git clone command to pull down a copy of the official Zabbix Docker GitHub repository.
git clone https://github.com/zabbix/zabbix-docker.gitIf you already have a copy of the repository and want to make sure that you have the latest code, then use the git fetch command.
git fetch https://github.com/zabbix/zabbix-docker.gitTo bring up Zabbix with docker compose use the following command.
docker-compose -f .//home/ec2-user/zabbix-docker/docker-compose_v3_ubuntu_mysql_local.yaml up -dWe will bring up the Ubuntu version of the Zabbix docker containers. Why? The development and usage of Zabbix on Ubuntu is a larger population and therefore any problems will be noticed and most likely fixed or worked around than with the alpine version of the product. That said, the alpine containers work faster with less resource requirements but for our needs that is not a requirement.
This command will create a lot of output as it creates the resources required. Once you get a command prompt. Check the status of the newly created docker containers by using the docker ps command.
docker ps Check to see if all containers with health check are reporting as healthy by rechecking with the docker ps command.
You should see (health: starting) in the output on some of the containers. Eventually, you will see (healthy). Once all the containers are reporting healthy, we can proceed to the next step.
Notice that a directory zbx_env was created. This is where all persistent data from the containers are stored. Feel free to browse the directory structure and look at the files created for the application and database.
Go to browser and enter your the IP address of the host machine for the docker containers. You now have fully functional Zabbix. To log in the default credentials are Admin (capital A) for the user id and zabbix (all lower case) for the password if this is the first install.
Otherwise use the user id and password combination you used in the previous version of zabbix since this will have been saved in the zbx_env directory.
Also to note: If you are upgrading the containers from another version, do not panic if you see a broken page layout. After changing major versions, for example, from 3.0 to 3.4 or 4.0, you need to clean the browser cache after the first login (Ctrl+F5 in Google Chrome).
Using the docker ps command with a filter of name to find the container name for the zabbix-docker_zabbix-agent_1
docker ps --filter "name=zabbix-docker_zabbix-agent_1"results in output like this:
$ docker ps --filter "name=zabbix-docker_zabbix-agent_1"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7e56fe106bff zabbix-agent:ubuntu-local "/sbin/tini -- /usr/…" 20 hours ago Up 20 hours zabbix-docker_zabbix-agent_1
$Alternatively, you can can use the docker ps command with the filter of ancestor to find the container.
docker ps --filter "ancestor=zabbix-agent:ubuntu-local"results in output like this:
$ docker ps --filter "ancestor=zabbix-agent:ubuntu-local"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7e56fe106bff zabbix-agent:ubuntu-local "/sbin/tini -- /usr/…" 20 hours ago Up 20 hours zabbix-docker_zabbix-agent_1
$For our example the container ID is 7e56fe106bff
We now need to get the IP address of the docker container that hosts the agent to provide to the Zabbix application so that it can do self-reporting.
The docker inspect command produces a lot of information, so we will couple the command with the grep command to find what we need. In this case, we need to find the IP address that is tagged with the label "IPAdress" in the JSON output from the docker inspect command.
docker inspect 7e56fe106bff | grep IPAddressThe command will give us output like what we see below:
$ docker inspect 7e56fe106bff | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "",
"IPAddress": "172.16.239.6",
$The IP address we need is 172.16.239.6
You IP address will probably be different.
Go back to your web browser and in the Zabbix application you need to navigate to Configuration ==> Hosts and then click on "Zabbix Server" entry in the list towards the bottom of the page.
Select Groups and input the value found in IPAddress. In this case it would be 172.16.239.6
Click Update.
Now that we made a change to the actual application configuration we need to update the internal configuration cache of the application.
Simply running zabbix server -R config_cache_reload will not work, because we would be running it locally on the host. We do not have a Zabbix server running locally on the host. We have Zabbix running inside a container on the host server so we need to connect to the container and run the zabbix server -R config_cache_reload command there.
Again, we go back to the console on the host and use the docker ps command.
We can use the docker ps --filter "ancestor=zabbix-server-mysql:ubuntu-local" command:
$ docker ps --filter "ancestor=zabbix-server-mysql:ubuntu-local"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
85c555bb56e4 zabbix-server-mysql:ubuntu-local "/sbin/tini -- /usr/…" 20 hours ago Up 20 hours 0.0.0.0:10051->10051/tcp zabbix-docker_zabbix-server_1
$or we can use the docker ps --filter "name=zabbix-docker_zabbix-server_1" command:
$ docker ps --filter "name=zabbix-docker_zabbix-server_1"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
85c555bb56e4 zabbix-server-mysql:ubuntu-local "/sbin/tini -- /usr/…" 20 hours ago Up 20 hours 0.0.0.0:10051->10051/tcp zabbix-docker_zabbix-server_1
$Both commands give us the container ID 85c555bb56e4 (yours most likely will be different)
We now need to attach to execute the following command to reload the application cache on the container.
docker exec -it 85c555bb56e4 zabbix_server -R config_cache_reloadYou should see an acknowledgement that the command was successfully sent to the container.
$ docker exec -it 85c555bb56e4 zabbix_server -R config_cache_reload
zabbix_server [201]: command sent successfully
$Go back to Zabbix application web console. You can use the following short cut to get to the page directly: http://<<<your_application_host_server_ip_address>>/hosts.php . Refresh the web page, and you will see that the screen is now reporting all green icons for the Zabbix Server.
If you return to the main monitoring dashboard you will see that the problem has disappeared too.
Installation of Zabbix is complete and you may now proceed to installing agents on the target servers for monitoring.
Note: When installing the Zabbix agent, use the same version as your Zabbix server.
Before starting, navigate your web browser to https://www.zabbix.com/download_agents to find the URL for your Zabbix release.
Log onto the target Windows server and open up a PowerShell command prompt window as an administrator. You must have administrative privileges to install the agent.
Navigate to a temp directory or create a temporary directory to download the agent installation package.
Execute the following command (with the proper URL version) in the PowerShell command window to download the agent .msi package.
Invoke-WebRequest -Uri "https://www.zabbix.com/downloads/4.4.5/zabbix_agent-4.4.5-windows-amd64-openssl.msi" -OutFile "zabbix_agent-4.4.5-windows-amd64-openssl.msi"Execute the following command to start the installation process
./zabbix_agent-4.4.5-windows-amd64-openssl.msiRefer to the following web site, https://www.zabbix.com/documentation/current/manual/installation/install_from_packages/win_msi , for the documentation for installing the agent on a Windows machine.
For the Zabbix Server IP/DNS entry in the installation dialog, put the IP address of the host server and not the IP address of the container that we used before!
Leave the Agent listen port at 10050
For the Server or Proxy for active checks entry put the IP address of the host server and not the IP address of the container that we used before!
Check the boxes for Remote Command and Add agent location to the path
Leave the box unchecked for Enable PSK (unless you are utilizing discovery rules.)
Click next and then click install and then click Finish.
Note**: When installing the Zabbix agent, use the same version as your Zabbix server.
Before starting, navigate your web browser to https://www.zabbix.com/download_agents to find the URL for your Zabbix release. This page also provides URLs for tar.gz files for operating systems that do not support rpm based installations.
Execute the following command to download and install the Zabbix Agent
sudo rpm -ivh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-agent-4.4.7-1.el7.x86_64.rpm
We need to configure the agent configuration by editing the zabbix_agentd.conf file.
sudo vim /etc/zabbix/zabbix_agentd.conf
Change the following lines in the configuration file:
NOTE: Depending upon the version the line numbers may change.
Line number: 98
Server=your_zabbix_server_ip
Line number: 139
ServerActive=Your_Zabbix_server_ip
Line number: 150
Hostname=hostname_of_the_server_the_agent_is_being_installed_on
Save the changes to the file.
Enable the agent to start automatically on boot. Start the agent. Check the status of the agent to see if it is running properly.
sudo systemctl enable zabbix-agent
sudo systemctl start zabbix-agent
sudo systemctl status zabbix-agentTo add a target server to be monitored to Zabbix, refer to the following web page: https://www.zabbix.com/documentation/current/manual/quickstart/host