Zabbix comes with an Oracle Database monitoring template out-of-the-box, so it should not be too complicated to integrate one server. Nevertheless, I faced a few issues while trying to setup one and I will detail these steps below.

Agent Installation

Firstly, we need to install Zabbix Agent 2 on the Oracle VM. The official web site is guiding us to the installation steps matching our Zabbix version, OS type and version:

Steps are easy to follow:

  1. Install Zabbix software repository
  2. Trigger yum command
  3. Start and enable zabbix-agent2 service

Next, we must modify /etc/zabbix/zabbix_agent2.conf configuration file to allow server to gather data from agent. This is a simple line modification:

Server=<Zabbix_server>

Agent can run in active mode (ie. pushing to server) or passive (ie. reply to server queries). I am using the second option.

Finally, restart zabbix agent service to ensure configuration changes are in place.

Add Host in Zabbix Server

To add host in Zabbix server, we must go to Hosts and click “Create host”:

I selected two templates:

As per template documentation, I need to add a minimal of 3 Macros:

  • {$ORACLE.SERVICE}
  • {$ORACLE.USER}
  • {$ORACLE.PASSWORD}

This is done in the Macros tab of the host creation wizard. It is recommended to create a dedicated monitoring user with read-only permissions. Be careful when updating Macros values on an existing host as they will be in alphabetical order and not as you added them.

I was optimistic and hoped this was enough to make it work, but it was not as per the following message in /var/log/zabbix/zabbix_agent2.log:

2023/06/09 11:07:35.451851 [Oracle] Connection failed: ORA-00000: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help.

Obviously, I am missing some environment variables for service to be able to run sqlplus. As per /usr/lib/systemd/system/zabbix-agent2.service, /etc/sysconfig/zabbix-agent2 stores environment variables definitions. So, I am creating sysconfig file with this content:

ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1/
LD_LIBRARY_PATH=$ORACLE_HOME/lib

After service restart, no more errors in agent log and I can see database problems on host which means it can run checks:

This screenshot is an evidence of one great feature of Zabbix: Low-level discovery (LLD).

In this example, I did not statically declared any tablespace to monitor. Zabbix automatically created them with LLD as per template definitions.

Oracle by Zabbix agent 2 contains 5 discovery rules which will create items, triggers and graphs based on what is really in database:

It is possible to exclude tablespaces from discovery with a macro {$ORACLE.TABLESPACE.NAME.NOT_MATCHES}.

There are many more macros available for the Oracle template customization as described in the documentation.