database monitor的用途:可以用于监控数据库,采集数据库内的数据。本文使用此功能查询zabbix数据库,用于统计网络设备主机的触发器告警数量(用于绘制网络流量拓扑图的主机设备告警)。
在zabbix server机器上安装依赖包
[root@j ~]# yum -y install unixODBC mysql-connector-odbc
[root@jkweb ~]# vim /etc/odbcinst.ini
[MySQL5]
Description = MySQL5
Driver = /usr/lib64/libmyodbc5.so
[root@jkweb ~]# vim /etc/odbc.ini
[mysql3306]
Driver = MySQL5
DATABASE = zabbix
PWD = pwdaaaaaaa
SERVER = 10.0.0.18
PORT = 3306
UID = zabbix
创建模板
创建监控项目
将模板关联至网络设备
通过最新数据查看采集到的告警数量。这里不再截图。
通过网络流量拓扑中展示告警异常
下载安装包(一般高版本会兼容低版本,所以直接下载最新版本) https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
[root@j ~]# rpm -ivh oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:oracle-instantclient19.8-basic-19################################# [100%]
[root@j ~]# rpm -ivh oracle-instantclient19.8-odbc-19.8.0.0.0-1.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:oracle-instantclient19.8-odbc-19.################################# [100%]
[root@jkweb ~]#
[root@jkweb ~]# rpm -ivh oracle-instantclient19.8-sqlplus-19.8.0.0.0-1.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:oracle-instantclient19.8-sqlplus-################################# [100%]
[root@jkweb ~]# vim /etc/odbcinst.ini
#增加以下内容
[OracleDriver]
Description = ODBC for Oracle
Driver = /usr/lib/oracle/19.8/client64/lib/libsqora.so.19.1
[root@jkweb ~]# mkdir -p /usr/lib/oracle/19.8/client64/network/admin
[root@jkweb ~]# vim /usr/lib/oracle/19.8/client64/network/admin/tnsnames.ora
oaoracle=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.160)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = eco)
)
)
[root@j ~]# vim /etc/odbc.ini
[oaoracle]
Description = oaOracle
Driver = OracleDriver
ServerName = 192.168.1.160:1521/eco #oracle数据库实例名
UserID = zabbix #账号
Password = zabbix #密码
#测试登陆
[root@j ~]# isql -v oaoracle
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> quit
[root@j ~]# sqlplus zabbix/zabbix@oaoracle
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jul 27 14:31:28 2020
Version 19.8.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit;
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
zabbix监控项创建与mysql类同,这里省略创建过程。