Currently I’m testing different solutions for monitoring (mostly) Oracle databases. One solution in the shortlist is Zabbix.
Zabbix is open-source and currently has a quite active community helping out.
On Zabbix website there is a nice quick download and setup instructions:
I’ll use a Oracle Linux 9 VM under Windows WSL2 for installing Zabbix. For the exercise, I’ll configure it with PostgreSQL. The database installation step is missing. So, here are all the steps I’ve done.
1. Install Zabbix
Disable using Zabbix packages provided by Oracle-epel, by adding “excludepkgs=zabbix*” to /etc/yum.repos.d/oracle-epel-ol9.repo :
# cat /etc/yum.repos.d/oracle-epel-ol9.repo
[ol9_developer_EPEL]
name=Oracle Linux $releasever EPEL Packages for Development ($basearch)
baseurl=https://yum$ociregion.$ocidomain/repo/OracleLinux/OL9/developer/EPEL/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
excludepkgs=zabbix*
Add Zabbix repository
# rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
# dnf clean all
Install Zabbix server, frontend and agent
# dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
2. Install PostgreSQL
At the time of writing, the latest version was PostgreSQL 16. Again, to make sure I get the packages from the best source, I install posture repo
# dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
And install the latest version
# dnf install postgresql16 postgresql16-server
Then we initialize and start the postgreSQL server (I do not enable the service, as this is only a test)
# /usr/pgsql-16/bin/postgresql-16-setup initdb
Initializing database ... OK
# systemctl start postgresql-16
# ss -antpl | grep 5432
LISTEN 0 200 127.0.0.1:5432 0.0.0.0:* users:(("postgres",pid=23637,fd=7))
3. Create and configure Zabbix repository DB
Create a user called zabbix and then a database also called zabbix, having the created user as owner
# sudo -u postgres createuser --pwprompt zabbix
# sudo -u postgres createdb -O zabbix zabbix
Fill up the repository DB with the initial schema and data. It will make a long output
# zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix
Put the Password you setup for zabbix user above in the configuration file
# read -s -p "Zabbix password:" DBPWD
# sed -i -E "s/^# DBPassword=/DBPassword=$DBPWD/" /etc/zabbix/zabbix_server.conf
4. Configure the nix webserver
Set the port and hostname in configuration file
# sed -i -E 's/^#.*listen/listen/' /etc/nginx/conf.d/zabbix.conf
# sed -i -E "s/^#server_name.*/server_name $(hostname -f);/" /etc/nginx/conf.d/zabbix.conf
# grep -E 'listen|server_name' /etc/nginx/conf.d/zabbix.conf
On WSL2 you need to find your computer IP address and then you can access the Zabbix:
# hostname -I
172.31.152.146
5. Finish configuration
Then you can continue with Zabbix configuration on the web browser
As Zabbix per default uses the Public schema from PostgreSQL, on the screen below, leave the field “Database Schema” empty.
On the next screen it asks for the Server name, and you can give the result of $(hostname) command.
And you can login to Zabbix. The default user is Admin, and password zabbix:
6. Install Zabbix Agent2
On the server with Oracle database, download and install Zabbix Agent2
# rpm -Uvh https://repo.zabbix.com/zabbix/6.4/rhel/9/x86_64/zabbix-release-6.4-1.el9.noarch.rpm
# dnf clean all
# dnf install zabbix-agent2
Update the Agent configuration file. After some fight, these were the sittings I changed in the monitored server /etc/zabbix/zabbix_agent2.conf file:
Server=0.0.0.0/0 # Accept connections from any Zabbix Server
ListenPort=12051 # Port where Agent listen for Server requests - default Port did not work
ServerActive=127.0.1.2 # IP Address of the Zabbix Server
Hostname=Anjo-X13 # Hostname of the monitored server
And restart the Agent
# systemctl restart zabbix-agent2
Create Oracle user
On the database to be monitored, create a database user:
export z_crd="zabbix_pwd"
$ sqlplus -S -L / as sysdba <<EOF
SET PAGES 0 HEAD OFF ECHO OFF FEED OFF
WHENEVER SQLERROR EXIT SQL.SQLCODE
CREATE USER c##zabbix_mon IDENTIFIED BY "${z_crd}";
ALTER USER c##zabbix_mon SET CONTAINER_DATA=ALL CONTAINER=CURRENT;
GRANT CONNECT, CREATE SESSION TO c##zabbix_mon;
GRANT SELECT_CATALOG_ROLE to c##zabbix_mon;
GRANT SELECT ON v_\$instance TO c##zabbix_mon;
GRANT SELECT ON v_\$database TO c##zabbix_mon;
GRANT SELECT ON v_\$sysmetric TO c##zabbix_mon;
GRANT SELECT ON v_\$system_parameter TO c##zabbix_mon;
GRANT SELECT ON v_\$session TO c##zabbix_mon;
GRANT SELECT ON v_\$recovery_file_dest TO c##zabbix_mon;
GRANT SELECT ON v_\$active_session_history TO c##zabbix_mon;
GRANT SELECT ON v_\$osstat TO c##zabbix_mon;
GRANT SELECT ON v_\$restore_point TO c##zabbix_mon;
GRANT SELECT ON v_\$process TO c##zabbix_mon;
GRANT SELECT ON v_\$datafile TO c##zabbix_mon;
GRANT SELECT ON v_\$pgastat TO c##zabbix_mon;
GRANT SELECT ON v_\$sgastat TO c##zabbix_mon;
GRANT SELECT ON v_\$log TO c##zabbix_mon;
GRANT SELECT ON v_\$archive_dest TO c##zabbix_mon;
GRANT SELECT ON v_\$asm_diskgroup TO c##zabbix_mon;
GRANT SELECT ON sys.dba_data_files TO c##zabbix_mon;
GRANT SELECT ON DBA_TABLESPACES TO c##zabbix_mon;
GRANT SELECT ON DBA_TABLESPACE_USAGE_METRICS TO c##zabbix_mon;
GRANT SELECT ON DBA_USERS TO c##zabbix_mon;
EOF
7. Add host to Zabbix server
On Zabbix web interface go to “Monitoring” – “Hosts” and click “Create Host” on the top right.
This is the configuration that worked with me. The IP address is the one from Anjo-X13, the monitored server.
On the “Macros” tab I had to add the following three parameters and respective values
After this, I restarted the agent and started to get information.
Zabbix seems quite complete solution, even if the wording used is not very clear. I did not manage to make the “Named Sessions” to work, which would allow to configure the database credentials directly on the Agent configuration file.
Two monitoring “Items” I disabled:
- oracle.redolog.info – it expects minimum 5 redolog groups, which I do not have on my test DBs
- oracle.tbs_used_pct – which checks the percentage of allocated space used for each tablespace, not looking at the autoextend (there is oracle.tbs_used_from_max_pct for that).
When looking for a lighter alternative to Enterprise Manager, which also monitors other RDBMS, Zabbix is something to consider.