170
Cài trên server
1 – installing unixodbc on zabbix server
yum -y install unixODBC unixODBC-devel
2- installing instant client packages
<https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html>
# rpm -ivh oracle-instantclient12.1-basic-12.2.0.1.0-1.x86_64.rpm
# rpm -ivh oracle-instantclient12.1-odbc-12.2.0.1.0-1.x86_64.rpm
3 – environment variables on zabbix server
Edit or add new file /etc/sysconfig/zabbix-server # for server /etc/sysconfig/zabbix-proxy # for proxy
export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib:/usr/lib64
export TNS_ADMIN=/etc/oracle
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib/oracle/12.1/client64/lib
export ORACLE_HOME
export LD_LIBRARY_PATH
export TNS_ADMIN
export PATH
4 – Restart Zabbix server or Zabbix proxy.
service zabbix-server restart
service zabbix-proxy restart
vim /etc/odbcinst.ini
[OracleODBC-12.1]
Description = Oracle ODBC driver for Oracle 12c
Driver = /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1
FileUsage = 1
Driver Logging = 7
vim /etc/odbc.ini
[orcl]
Driver = OracleODBC-12.1
ServerName = orcl
FileUsage = 1
Driver Logging = 7
UserID = zabbix_mon
Password = zabbix
DatabaseCharacterSet=AL16UTF16
NLS_NUMERIC_CHARACTERS= ','
vi /etc/oracle/tnsnames.ora
ORCL =
( DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(Host = 10.1.1.223)
(Port = 1521)
)
)
(CONNECT_DATA = (SID = orcl)
)
)
Check lại kết nối
isql -v orcl
SQL> select banner from v$version where rownum=1;
odbcinst -q -s
odbcinst -j
Install plugin
ldd /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1
chmod -R 775 /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1
yum -y install libnsl.so.1*64*
Cài đặt marco trong config host zabbix
Set the username and password in host macros ({$ORACLE.USER} and {$ORACLE.PASSWORD}).
Set the {$ORACLE.DSN} in host macros.
Trên máy db client
Create an Oracle DB user for monitoring:
CREATE USER zabbix_mon IDENTIFIED BY zabbix;
-- Grant access to the zabbix_mon user.
GRANT CONNECT, CREATE SESSION TO zabbix_mon;
GRANT SELECT ON v_$instance TO zabbix_mon;
GRANT SELECT ON v_$database TO zabbix_mon;
GRANT SELECT ON v_$sysmetric TO zabbix_mon;
GRANT SELECT ON v_$system_parameter TO zabbix_mon;
GRANT SELECT ON v_$session TO zabbix_mon;
GRANT SELECT ON v_$recovery_file_dest TO zabbix_mon;
GRANT SELECT ON v_$active_session_history TO zabbix_mon;
GRANT SELECT ON v_$osstat TO zabbix_mon;
GRANT SELECT ON v_$restore_point TO zabbix_mon;
GRANT SELECT ON v_$process TO zabbix_mon;
GRANT SELECT ON v_$datafile TO zabbix_mon;
GRANT SELECT ON v_$pgastat TO zabbix_mon;
GRANT SELECT ON v_$sgastat TO zabbix_mon;
GRANT SELECT ON v_$log TO zabbix_mon;
GRANT SELECT ON v_$archive_dest TO zabbix_mon;
GRANT SELECT ON v_$asm_diskgroup TO zabbix_mon;
GRANT SELECT ON sys.dba_data_files TO zabbix_mon;
GRANT SELECT ON DBA_TABLESPACES TO zabbix_mon;
GRANT SELECT ON DBA_TABLESPACE_USAGE_METRICS TO zabbix_mon;
GRANT SELECT ON DBA_USERS TO zabbix_mon;
grant dba to zabbix_mon;