Skip to content

Instantly share code, notes, and snippets.

@umayrh
Last active May 9, 2024 09:03
Show Gist options
  • Select an option

  • Save umayrh/c6b9321d594ea96d0557519e6ca3867b to your computer and use it in GitHub Desktop.

Select an option

Save umayrh/c6b9321d594ea96d0557519e6ca3867b to your computer and use it in GitHub Desktop.
Zabbix installation

Setting up Zabbix service

This guide on based on Zabbix's own instructions.

Set up Postgres server and client

Install Postgres server

$ sudo apt install postgresql

Install the Postgres client (psql)

$ sudo apt install postgresql-client
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libwpe-1.0-1 libwpebackend-fdo-1.0-1
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  postgresql-client
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 69.4 kB of archives.
After this operation, 74.8 kB of additional disk space will be used.
Get:1 https://apt.postgresql.org/pub/repos/apt jammy-pgdg/main amd64 postgresql-client all 16+259.pgdg22.04+1 [69.4 kB]
Fetched 69.4 kB in 1s (57.1 kB/s)            
Selecting previously unselected package postgresql-client.
(Reading database ... 237637 files and directories currently installed.)
Preparing to unpack .../postgresql-client_16+259.pgdg22.04+1_all.deb ...
Unpacking postgresql-client (16+259.pgdg22.04+1) ...
Setting up postgresql-client (16+259.pgdg22.04+1) ...

Restart service

$ sudo systemctl restart postgresql.service

Test if the Postgress client (psql) can connect to the local server

$ sudo -u postgres psql test_db_name
psql (16.2 (Ubuntu 16.2-1.pgdg22.04+1))
Type "help" for help.

test_db_name=# ALTER USER postgres with encrypted password 'postgres_password';
ALTER ROLE
test_db_name=# \q

Allow the OS to manage the Postgres server

$ systemctl enable postgresql.service
Synchronizing state of postgresql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable postgresql

Install Zabbix service

Download Zabbix server package

$ wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
--2024-05-07 21:11:18--  https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
Resolving repo.zabbix.com (repo.zabbix.com)... 
178.128.6.101, 2604:a880:2:d0::2062:d001
Connecting to repo.zabbix.com (repo.zabbix.com)|178.128.6.101|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3744 (3.7K) [application/octet-stream]
Saving to: ‘zabbix-release_6.4-1+ubuntu22.04_all.deb’

zabbix-release_6.4-1+ubuntu2 100%[===========================================>]   3.66K  --.-KB/s    in 0s      

2024-05-07 21:11:19 (1.11 GB/s) - ‘zabbix-release_6.4-1+ubuntu22.04_all.deb’ saved [3744/3744]

Install package

$ dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb
dpkg: error: requested operation requires superuser privilege
$ sudo dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb
Selecting previously unselected package zabbix-release.
(Reading database ... 234606 files and directories currently installed.)
Preparing to unpack zabbix-release_6.4-1+ubuntu22.04_all.deb ...
Unpacking zabbix-release (1:6.4-1+ubuntu22.04) ...
Setting up zabbix-release (1:6.4-1+ubuntu22.04) ...

Update the installed package

$ sudo apt update
Hit:1 http://pk.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://pk.archive.ubuntu.com/ubuntu jammy-updates InRelease                                               
Hit:3 http://pk.archive.ubuntu.com/ubuntu jammy-backports InRelease                                             
Hit:4 https://dl.google.com/linux/chrome/deb stable InRelease                                                   
Hit:5 http://security.ubuntu.com/ubuntu jammy-security InRelease                                                
Hit:6 https://storage.googleapis.com/bazel-apt stable InRelease                                                 
Hit:7 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease                                    
Hit:8 https://apt.postgresql.org/pub/repos/apt jammy-pgdg InRelease                                             
Hit:9 https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu jammy InRelease                                   
Get:10 https://dl.packager.io/srv/deb/pghero/pghero/master/ubuntu 22.04 InRelease [1,851 B]                     
Get:12 https://repo.zabbix.com/zabbix/6.4/ubuntu jammy InRelease [2,874 B]                   
Get:13 https://repo.zabbix.com/zabbix/6.4/ubuntu jammy/main Sources [15.3 kB]
Get:14 https://repo.zabbix.com/zabbix/6.4/ubuntu jammy/main all Packages [9,042 B]
Get:15 https://repo.zabbix.com/zabbix/6.4/ubuntu jammy/main amd64 Packages [43.5 kB]
Hit:11 https://packagecloud.io/github/git-lfs/ubuntu jammy InRelease              
Fetched 72.6 kB in 3s (22.9 kB/s)                         
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

Install Zabbix server, frontend, agent

Install Zabbix server, frontend, and agent packages

$ sudo apt install zabbix-server-pgsql zabbix-frontend-php php8.1-pgsql zabbix-apache-conf zabbix-sql-scripts zabbix-agent
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libwpe-1.0-1 libwpebackend-fdo-1.0-1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils fonts-dejavu fonts-dejavu-extra fping libapache2-mod-php
  libapache2-mod-php8.1 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libevent-core-2.1-7
  libevent-pthreads-2.1-7 libmodbus5 libodbc2 libonig5 libopenipmi0 php-bcmath php-common php-gd php-ldap
  php-mbstring php-xml php8.1-bcmath php8.1-cli php8.1-common php8.1-gd php8.1-ldap php8.1-mbstring
  php8.1-opcache php8.1-readline php8.1-xml snmpd
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear odbc-postgresql tdsodbc snmptrapd
  zabbix-nginx-conf
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils fonts-dejavu fonts-dejavu-extra fping libapache2-mod-php
  libapache2-mod-php8.1 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libevent-core-2.1-7
  libevent-pthreads-2.1-7 libmodbus5 libodbc2 libonig5 libopenipmi0 php-bcmath php-common php-gd php-ldap
  php-mbstring php-xml php8.1-bcmath php8.1-cli php8.1-common php8.1-gd php8.1-ldap php8.1-mbstring
  php8.1-opcache php8.1-pgsql php8.1-readline php8.1-xml snmpd zabbix-agent zabbix-apache-conf
  zabbix-frontend-php zabbix-server-pgsql zabbix-sql-scripts
0 upgraded, 41 newly installed, 0 to remove and 3 not upgraded.
Need to get 27.9 MB of archives.
After this operation, 98.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Create initial database

Create a Postgres user and role for Zabbix

$ sudo -u postgres createuser --pwprompt zabbix
Enter password for new role: 
Enter it again: 

Create a Postgres database for Zabbix

$ sudo -u postgres createdb -O zabbix zabbix 

Run scripts to set up Postgres schema

$ zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix 
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE INDEX
...

Validate if schemas exist

 psql --user zabbix zabbix --password --host 127.0.0.1
Password: 
psql (16.2 (Ubuntu 16.2-1.pgdg22.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
Type "help" for help.

zabbix=> \d
zabbix=> \q

References:

Configure the database for Zabbix server

Edit file /etc/zabbix/zabbix_server.conf to set the database password

$ sudo nano /etc/zabbix/zabbix_server.conf

Start Zabbix server and agent processes

Start the processes

$ systemctl restart zabbix-server zabbix-agent apache2

Allow these services to be managed by the OS

$ systemctl enable zabbix-server zabbix-agent apache2 
Synchronizing state of zabbix-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-server
Synchronizing state of zabbix-agent.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-agent
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /lib/systemd/system/zabbix-server.service.

Open Zabbix UI web page

Navigate to

http://127.0.0.1/zabbix

Note that the default admin user, once the setup is complete, is "Admin".

@umayrh
Copy link
Author

umayrh commented May 7, 2024

Screenshot from 2024-05-07 21-48-00

Screenshot from 2024-05-07 21-56-22

Screenshot from 2024-05-07 21-56-45

@umayrh
Copy link
Author

umayrh commented May 7, 2024

Screenshot from 2024-05-07 22-31-59

Screenshot from 2024-05-08 20-56-44

On Mac OS:

$ brew install zabbix
$ nano /usr/local/etc/zabbix/zabbix_agentd.conf
$ sudo /etc/sudoers
$ chown zabbix:zabbix /usr/local/var/log/zabbix/
$ sudo -u zabbix /usr/local/sbin/zabbix_agentd
$ ps aux | grep zabbix
$ less  /usr/local/var/log/zabbix/zabbix_agentd.log 
...
$ kill -TERM `cat  /usr/local/var/log/zabbix/zabbix_agentd.pid`

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment