Recently, I’ve had a number of issues with multiple servers, and decided to set up monitoring to help keep track of problems. I chose Zabbix based on the recommendation of Tom Lawrence, as being in the MSP business his recommendations are generally good to follow unless you have a very specific reason not to.
In this post, I’ll explain how to set up Zabbix, while trying to avoid duplicating too much from existing documentation as posts. As it is, Zabbix provides decent if sometimes confusing documentation. Digital Ocean also has a lot of good tutorials, as long as you know enough to not blindly follow along all the time – they sometimes make recommendations that are strange.
First, you will need a server to run a Zabbix server and web interface on that you can access. Every other machine being monitored will connect to this one. It does not necessarily need to be internet accessible, unless you have machines across multiple networks, in which case it will need to be.
I’m running mine on an Oracle Always-free VM, as luckily Zabbix requires few resources. Go to the Zabbix downloads page and select the version you want along with the necessary configuration options. Connect to your instance and follow the instructions to download the Zabbix package that installs the apt repository:
wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb dpkg -i zabbix-release_5.0-1+focal_all.deb apt update
In my case, I chose version 5, as version 5.2 had some strange bugs related to active-only agents. My OS is Ubuntu 20.04, and I already have Apache installed, so that is what I selected. I also used the PostgreSQL database, as I found MySQL consumed too much RAM for the small VM I have running.
Next, fix the dpkg exclude configuration (see my post here) and then install the required packages:
apt install zabbix-server-pgsql zabbix-frontend-php php7.4-pgsql zabbix-apache-conf zabbix-agentpostgresql
Create your database and chose a password for the zabbix database user:
sudo -u postgres createuser --pwprompt zabbix sudo -u postgres createdb -O zabbix zabbix
Import the required schema into the newly created database:
zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix
Modify /etc/zabbix/zabbix_server.conf with the database password you just picked:
Modify the apache config /etc/zabbix/apache.conf with the correct timezone – I guess the developers are in Riga? It’s a nice city, and one of the few I’ve been to in Europe.
# php_value date.timezone America/Montreal
Get the service going and allow it to start at boot. This is unusual, as for the most part services always start at boot.
systemctl restart zabbix-server zabbix-agent apache2
systemctl enable zabbix-server zabbix-agent apache2
At this point, I assume you already have a working webserver with HTTPS. If you don’t, set it up now – you do not want to use Zabbix over HTTP over the internet! If your server is working correctly, Zabbix will be accessible at https://yourserver/zabbix
Next, follow the guides here and here to get the web interface part up and running. Most default values are fine, but keep in mind you will need the database password you created earlier. You will also definitely want to change the password for the default admin account to something reasonable and not the default value.
In the next post, I’ll go over how to add hosts and get Zabbix to monitor Nvidia GPUs.