Friday 14 September 2018

Zabbix monitoring Oracle database using orabbix - working example Oracle 12c

Orabbix


Orabix use jdbc connection to database so it not require installation of additional packages on database server.

Unzip downloaded Orabbix 1.2.3 file to /opt/orabbix (on zabbix server)

Copy file /opt/orabbix/init.d/orabbix to /etc/init.d/orabbix

Grant execute permissions to the following files:

 /etc/init.d/orabbix
 /opt/orabbix/run.sh


Create zabbix user on oracle database

CREATE USER ZABBIX
IDENTIFIED BY <REPLACE WITH PASSWORD>
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;
GRANT ALTER SESSION TO ZABBIX;
GRANT CREATE SESSION TO ZABBIX;
GRANT CONNECT TO ZABBIX;
ALTER USER ZABBIX DEFAULT ROLE ALL;
GRANT SELECT ON V_$INSTANCE TO ZABBIX;
GRANT SELECT ON DBA_USERS TO ZABBIX;
GRANT SELECT ON V_$LOG_HISTORY TO ZABBIX;
GRANT SELECT ON V_$PARAMETER TO ZABBIX;
GRANT SELECT ON SYS.DBA_AUDIT_SESSION TO ZABBIX;
GRANT SELECT ON V_$LOCK TO ZABBIX;
GRANT SELECT ON DBA_REGISTRY TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON V_$SYSSTAT TO ZABBIX;
GRANT SELECT ON V_$PARAMETER TO ZABBIX;
GRANT SELECT ON V_$LATCH TO ZABBIX;
GRANT SELECT ON V_$PGASTAT TO ZABBIX;
GRANT SELECT ON V_$SGASTAT TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON V_$PROCESS TO ZABBIX;
GRANT SELECT ON DBA_DATA_FILES TO ZABBIX;
GRANT SELECT ON DBA_TEMP_FILES TO ZABBIX;
GRANT SELECT ON DBA_FREE_SPACE TO ZABBIX;
GRANT SELECT ON V_$SYSTEM_EVENT TO ZABBIX;


 exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description => 'resolve acl', principal =>'ZABBIX', is_grant => true, privilege => 'resolve');
 exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*');
 commit;


To verify connect to database as user zabbix and run sql

sqlplus zabbix/<REPLACE WITH PASSWORD>@database_service
select utl_inaddr.get_host_name('127.0.0.1') from dual;

(on RHEL6)
chkconfig -add orabbix



(on Debian) change line in file
/etc/init.d/orabbix 
from 
. /etc/rc.d/init.d/functions
to
. /lib/lsb/init-functions
 

Download from Oracle latest ojdbc6 driver and copy it to location /opt/orabbix/lib (overwrite existig file)


Example config.props (my db is rr01dev, zabbix server ip 192.168.41.194,
#comma separed list of Zabbix servers
ZabbixServerList=ZabbixServer1

ZabbixServer1.Address=192.168.41.194
ZabbixServer1.Port=10051

#pidFile
OrabbixDaemon.PidFile=./logs/orabbix.pid
#frequency of item's refresh
OrabbixDaemon.Sleep=300
#MaxThreadNumber should be >= than the number of your databases
OrabbixDaemon.MaxThreadNumber=100

#put here your databases in a comma separated list
DatabaseList=rr01dev

#Configuration of Connection pool
#if not specified Orabbis is going to use default values (hardcoded)
#Maximum number of active connection inside pool
DatabaseList.MaxActive=10
#The maximum number of milliseconds that the pool will wait
#(when there are no available connections) for a connection to be returned
#before throwing an exception, or <= 0 to wait indefinitely.
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1

#define here your connection string for each database
rr01dev.Url=jdbc:oracle:thin:@sc-test-001:1524/rr01dev
rr01dev.User=zabbix
rr01dev.Password=*****
#Those values are optionals if not specified Orabbix is going to use the general values
rr01dev.MaxActive=10
rr01dev.MaxWait=100
rr01dev.MaxIdle=1
rr01dev.QueryListFile=./conf/query.props



Database name must be the same as host in zabbix

Run script
/opt/orabbix/run.sh

And check for errors file
/opt/orabbix/logs/orabbix.log

When you have error with connection check if ListenPort=10051 is uncomented
/etc/zabbix/zabbix_server.conf
ListenPort=10051


Import templates from /opt/orabbix/templates to zabbix using gui

And create host

Apply template
Go to graph find your host and check if orabbix working properly

Tested on zabbix 3.4






4 comments:

  1. select utl_inaddr.get_host_name('127.0.0.1') from dual;???

    ReplyDelete
    Replies
    1. It check if you can get your hostname using zabbix user. For mapping in zabbix.

      Delete
  2. Hello,
    Is there a way to make this work along zabbix on docker ?

    ReplyDelete
  3. Plase can you tell me if this method is valid for monitoring +ASM?

    ReplyDelete