Blog

Zabbix Infrastructure Monitoring

Having changed a bunch of my homelab infrastructure from VMWare over to Proxmox, and depriciating my old VPN and moving over to a ZTNA solution with Twingate, I needed to put some monitoring in place. I’m a big fan of PRTG, its free up to 100 probes, but it runs on Windows. Normally this isn’t a problem for me, but one of the VM’s I needed to monitor that was giving me issues was running on Windows, and the bigger issue is it was the network connection that would randomly die on it.

Seeing as I had Debian VM’s in place already for the backup ZTNA connectors, I figured this was a good a time as any to try out another solution that is also affordable as in free, and would run on my very stable Linux VM’s. Enter Zabbix stage right! This post outlines the installation steps I went through, and a couple of the problems I ran into as well as the few things I still need to address.

The basics of my Proxmox VM that I have this running in is nothing over the top. CPU is set to host, 1 socket and 1 core. 4 Gig of ram with all of it allocated and ballooning turned off. The drive is just a basic 32Gig, set to SSD emulation and discard on. This is more than enough room for my needs and a virtio network adapter.

I won’t bother going over the Debian setup, as Linux distro’s tools vary a little bit from distro to distro, but the extreme basics are I’ve got SSH, and SUDO setup so I can easily log into the VM without having to go through the Proxmox console.

Before I got into the main Zabbix install I made sure that I was all up to date on the system with apt update. From the Zabbix site you can set what distro, web server and DB you want to use, it will then outline the install steps required. My steps below are for Debian 12, Zabbix 6.4, Nginx, and MySQL.

Zabbix server install options.

The MySQL install options before I got into the Zabbix install are as follows. This needs to be installed first, on my very first install of Zabbix I didn’t do this, thinking that it was part of the installation steps and it wasn’t and had to back track a little bit to get things going. So make sure you’ve got it installed and running before hand.

Install MySQL


    sudo apt update
    sudo apt install gnupg
    cd /tmp
    wget https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb
    sudo dpkg -i mysql-apt-config*
    sudo apt update
    sudo apt install mysql-server


Verify mysql is running.
    sudo systemctl status mysql


I don’t beleive you need to, but if MySQL doesn’t fire backup on a reboot you’ll need to do sudo systemctl enable mysql


Time to install Zabbix!


Install the repo
     cd /tmp
     sudo wget https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
     sudo dpkg -i zabbix-release_6.4-1+debian12_all.deb
     sudo apt update


Install server, frontend and agent
    sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent


Create your initial DB (example password used in the localhost identified by field)
    sudo mysql -u root -p
    password
    mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
    mysql> create user zabbix@localhost identified by ‘test1234’;
    mysql> grant all privileges on zabbix.* to zabbix@localhost;
    mysql> set global log_bin_trust_function_creators = 1;
    mysql> quit;


On Zabbix server host import initial schema and data. You will be prompted to enter your newly created password.
    sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql –default-character-set=utf8mb4 -u zabbix -p zabbix

Be patient, this can take a couple mins, and if you jump the gun cancelling out the process (like I did thinking it had hung) you’ll need to delete the database and user you’ve already created to be able to rerun the schema import without error.


Disable log_bin_trust_function_creators option after importing database schema.
    sudo mysql -uroot -p
    password
    mysql> set global log_bin_trust_function_creators = 0;
    mysql> quit;

Configure the database for Zabbix server
    Edit file /etc/zabbix/zabbix_server.conf
    DBPassword=test1234

Configure PHP for Zabbix frontend
    Edit file /etc/zabbix/nginx.conf uncomment and set ‘listen’ and ‘server_name’ directives.
    listen 8080;
    server_name zabbix-test;

Start Zabbix server and agent processes
    Start Zabbix server and agent processes and make it start at system boot.
    sudo systemctl enable zabbix-server zabbix-agent nginx php8.2-fpm
    sudo systemctl restart zabbix-server zabbix-agent nginx php8.2-fpm

Open Zabbix UI web page
The URL for Zabbix UI when using Nginx depends on the configuration changes you should have made. Which in my case is http://192.168.185.130:8080


Zabbix should now be installed and up and running, if you have any errors or something doesn’t seem right you can check in /var/log/zabbix and you’ll have both the zabbix_server.log and zabbix_agent.log that should point you in the right direction. Journalctl can also help you out. If everything is up and running you should now be presented with the follow screen in your browser.


Zabbix Install Screen


 


Check your pre-requisites and make sure no issues.


 


Fill out the password you set for your Zabbix DB.


 


Set the server name, change up your theme if you desire.


 


Click next step.


 


Installation complete!


 


Default user name is Admin, default password is zabbix, make sure you change that sooner rather than later!


Once you’ve have logged in you should now have a screen that looks similar to the one before. If everything is up and running as it should, you can start adding in some agents through out your network. I’ll outline some of the basics as well, but won’t be covering everything, Zabbix is pretty big and I’m still learning it myself. Currently I have my setup monitoring my servers for uptime, and load, notifying if they go down, but I haven’t setup anything beyond that as of it.


On the list of things I still need to sort or figure out, is the Active agents, I noticed with the default addressing it gives the agent I have an error in the log, and if I select a Active Zabbix agent over the Zabbix agent when creating hosts it currently doesn’t work. As well I want to get some Grafana graphs going over the basic graphs that Zabbix presents out of the box. That being said the defaults are more than enough data to keep me happy at the moment and show me what’s going on. This is an area I feel PRTG does a lot nicer right out of the gate, but once again, the server install is windows only and you are limited to the 100 sensors which depending how many servers and devices you want to monitor you can out grow pretty quick.


Zabbix Dashboard.


The following is the process I went through for installing an agent on Windows and getting the host setup in the Zabbix frontend for monitoring. Install is very straight forward you’ll just need to pass it the server IP (the IP you are connecting to on your frontend) and the rest is just defaults. The agent should auto populate the host name for you which is your machine name.


Agent install.


Once your agent is installed go to the menu in the front end of Zabbix on the left, Data Collection and Hosts and click on Create Host on the top right, so you can begin the process of adding a host.


Adding hosts for monitoring.


You’ll want to set your Host name, and select the Windows by Zabbix Agent template to get up and running quickly. You can later set items on their own if you prefer, but this will get you a lot of items fast, after you can filter out and delete what you don’t need. I make sure that Enabled isn’t checked off as well, mostly so I can go and disable the Services discovery item as I generally don’t need them. 


You need to add a host groups, Hypervisor is one of the defaults that already exists you can make your own, and change it later if you don’t have anything setup, and you’ll need to add an interface and pass it the IP of the host you wish to monitor. I have left DNS off in the past and there were no issues. Click Add on the bottom to add the host.


Host config.


Click on Discovery for your agent before you enable it.


Agent added but currently disabled.


Once into Discovery, I disabled the services so I don’t have hundreds of services I don’t want to monitor. What you do here is up to you and your needs. I also found that if I leave Discovery items enabled after I have deleted out items I didn’t want, it would re-add the deleted items. So post discovery disable the item in Discovery, I don’t know if there is a better option to have it no keep adding them at this time.


Discovery options.


Setting up alerts is pretty easy, just go to Alerts and Media types on the left menu bar.


Emailer Setup.


I just use Email (HTML) click on that to get it setup.


Email (HTML)


I just use my gmail with an application password. Nice and easy.


Gmail Setup.


Enable the emailer and click on test on the right, and if there are no issues you should have a success message and an email in your inbox.


Email test screen.


Successful email test!


Test email in Gmail.


Now under Monitoring you should see your newly added host as well as your Zabbix server host. Now you can start configuring dashboards as you need. Adjust triggers so you get notified of issues and do further tuning. You might want to do some tuning of the MySQL data base, but that is outside the scope of this post. I have seen it mentioned though in a couple other pages I read through when getting things up and running, but for now I’m defaults.


Monitoring tab.


 


Graphs available to the host.


 


Host options when clicking on the name.


 


Dashboard defaults page.


As you can see you get a lot of items to monitor right out of the gate using the templates and this is excluding the services. That’s it and all there really is to it. Now it’s just a matter of tuning, and adding hosts, and you’ll have a nice little reporting and monitoring system for your infrastructure. Zabbix is pretty indepth, and this is only just scratching the surface. There are literaly books written on it, hopefully this helps someone run through at least a linux setup quick and easy. Now to customize further!


Host Items.

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Proxmox Notifications and You!Create Asset Directory Tree