当前位置:网站首页>Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
2022-07-02 07:04:00 【Virtuous time】
Zabbix The official solution gives the use zabbix-agent2、ODBC monitor Oracle database , But the supported version is 12.2 And above , Through the analysis of zabbix-agent2 The source code of is Oracle The plug-in part makes use of Oralce 12.2 A new built-in function json_table、json_object, use sql Query out 12.2 The following versions do not integrate this function , Therefore, the official solution can only monitor the higher version , monitor 12.2 The following versions can be used orabbix.
Basic components -Zabbix Server installation
MySQL8.0 install
use yum Source installation , Refer to official documentation
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
among ,8.0 Increased security mechanism , In the configuration zabbix In order to avoid errors in front-end configuration , You need to add a parameter allowing local login to the configuration file
vi /etc/my.cnf
default_authentication_plugin=mysql_native_password
# Restart the database
systemctl restart mysqld.service
Zabbix install
Because limited by Linux Operating system version :CentOS7, Can only be installed Zabbix 5.0 Version of the , Refer to the official documentation for installation steps :
https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=apache
When executing the following command
# yum install zabbix-server-mysql zabbix-agent
hold zabbix-agent Change to zabbix-agent2 as follows :
# yum install zabbix-server-mysql zabbix-agent2
because zabbix-agent2 Not only does it include zabbix-agent The original function also integrates the database monitoring plug-in .
Also pay attention to , After creating the database monitoring user , You need parameters mysql_native_password Change the password :
ALTER USER 'zabbix'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Oracle Monitoring instructions for each version
in the light of Oracle Different versions of the database , Use two agent: Official zabbix-agent2 And third-party orabbix.
Official zabbix-agent2 Of Oralce The data collection plug-in uses 12C A new built-in function json_table、json_object, This function starts from 12.1 Version has just begun to integrate , Put... Directly sql The detected data is encapsulated into json Format sent to zabbix-server The server .
12.1 The following versions do not integrate this function , So it led to zabbix Official solutions can only monitor higher versions (12.1 And above ) Of , monitor 12.1 The following versions can be used orabbix.
Configuration /usr/lib/systemd/system/zabbix-agent2.service
12.1 And above
utilize zabbix-agent2 monitor Oracle High version database
To configure zabbix-agent2
adopt ps -ef | grep zabbix_agent2 To determine the configuration file used
[[email protected] ~]# ps -ef | grep zabbix_agent2
zabbix 2166 1 0 Oct28 ? 01:46:47 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf
root 19423 19352 0 16:06 pts/0 00:00:00 grep --color=auto zabbix_agent2
[[email protected] ~]#
modify /etc/zabbix/zabbix_agent2.conf
sed -i 's/Server=127.0.0.1/Server=【 Change to zabbix server actual IP】/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/ServerActive=127.0.0.1/ServerActive=【 Change to zabbix server actual IP】/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/Hostname=Zabbix server/Hostname=【 Change to zabbix agent2 The location of the machine hostname】/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^# Plugins.Oracle.CallTimeout.*/Plugins.Oracle.CallTimeout=10/' /etc/zabbix/zabbix_agent2.conf
sed -i 's/^# Plugins.Oracle.ConnectTimeout.*/Plugins.Oracle.ConnectTimeout=1/' /etc/zabbix/zabbix_agent2.conf
sed -i 's/^# Plugins.Oracle.KeepAlive=300.*/Plugins.Oracle.KeepAlive=300/' /etc/zabbix/zabbix_agent2.conf
Check the parameter settings
grep -Ev '^#|^$' /etc/zabbix/zabbix_agent2.conf
To configure Oracle client
stay root User down operation
Download the latest version of the client , Reference documents :
https://docs.oracle.com/en/database/oracle/oracle-database/21/lacli/install-instant-client-using-zip.html#GUID-D3DCB4FB-D3CA-4C25-BE48-3A1FB5A22E84
To configure LD_LIBRARY_PATH You need to write the configuration directly to the configuration file
echo "LD_LIBRARY_PATH=/apps/oracle/instantclient:\$LD_LIBRARY_PATH" > /etc/sysconfig/zabbix-agent2
Not systemd The system of
stay /etc/init.d/zabbix-agent2 Of documents ### END INIT INFO Add environment variables below this line
# export ORACLE_HOME=/apps/oracle
export LD_LIBRARY_PATH=/apps/oracle/instantclient:$LD_LIBRARY_PATH
# export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
# export TNS_ADMIN=/apps/oracle/instantclient/network/admin
restart zabbix-agent2
systemctl daemon-reload
source /etc/profile
systemctl restart zabbix-agent2.service
ps -ef|grep zabbix
Create database dedicated users
alter session set container=orapdb1;-- Switch to PDB
CREATE USER zabbix_mon IDENTIFIED BY zabbix_mon;
GRANT CONNECT, CREATE SESSION TO zabbix_mon;
GRANT SELECT ON DBA_TABLESPACE_USAGE_METRICS TO zabbix_mon;
GRANT SELECT ON DBA_TABLESPACES TO zabbix_mon;
GRANT SELECT ON DBA_USERS TO zabbix_mon;
GRANT SELECT ON SYS.DBA_DATA_FILES TO zabbix_mon;
GRANT SELECT ON V_$ACTIVE_SESSION_HISTORY TO zabbix_mon;
GRANT SELECT ON V_$ARCHIVE_DEST TO zabbix_mon;
GRANT SELECT ON V_$ASM_DISKGROUP TO zabbix_mon;
GRANT SELECT ON V_$DATABASE TO zabbix_mon;
GRANT SELECT ON V_$DATAFILE TO zabbix_mon;
GRANT SELECT ON V_$INSTANCE TO zabbix_mon;
GRANT SELECT ON V_$LOG TO zabbix_mon;
GRANT SELECT ON V_$OSSTAT TO zabbix_mon;
GRANT SELECT ON V_$PGASTAT TO zabbix_mon;
GRANT SELECT ON V_$PROCESS TO zabbix_mon;
GRANT SELECT ON V_$RECOVERY_FILE_DEST TO zabbix_mon;
GRANT SELECT ON V_$RESTORE_POINT TO zabbix_mon;
GRANT SELECT ON V_$SESSION TO zabbix_mon;
GRANT SELECT ON V_$SGASTAT TO zabbix_mon;
GRANT SELECT ON V_$SYSMETRIC TO zabbix_mon;
GRANT SELECT ON V_$SYSTEM_PARAMETER TO zabbix_mon;
To configure zabbix Templates
zabbix5.0 Already brought Oracle Monitoring module , Select when adding hosts Template DB Oracle by Zabbix Agent 2 This template is ok .
Then configure the values of the following four macros
Then it's over, as shown in the figure below :
12.1 And the following database monitoring
use orabbix monitor ,orabbix The structure is as shown in the figure
[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Q8x2AaYD-1637231332263)(http://www.smartmarmot.com/wiki/images/1/1f/Orabbix_architecture.png)]
For the installation procedure, please refer to :http://www.smartmarmot.com/wiki/index.php?title=Orabbix
The existing version of the official website is incompatible zabbix 5.0 , There is an old brother who developed the second time and put it down github On , hold orabbix-1.2.4w.jar Replace the official existing jar The bag is ready to use .
https://github.com/wanghy8166/orabbix/blob/master/orabbix-1.2.4w.jar
Configure table space auto discovery rules
When we add table spaces , hope zabbix It can automatically identify the tablespace we add , Without having to go to orabbix Of sql Add a paragraph to the query template sql, Then go again. zabbix Add monitoring items to , Configure advanced . But there's a problem with this place , Is to automatically discover rules orabbix It didn't come true , We need to use zabbix-agent Go to secondary configuration to realize zabbix serve Server to send json data , Steps are as follows :
- adopt sqlplus spool Output tablespace file , In the form of text (mornitor_tbs.sh).
- To write shell Process the text file into json Format (oracle_discovery.sh)
- To configure zabbix-agent client , Add customized auto discovery rules (oracle_check.sh)
Three scripts are as follows :
mornitor_tbs.sh
# This script needs to be put into crontab Call in */10 * * * * /home/orasit/orabbix/monitor_tbs.sh > /home/orasit/orabbix/monitor_tbs.log
#!/bin/bash
source /home/orasit/.bash_profile
sqlplus -s apps/apps > /tmp/tablespace.log<<\EOF
set linesize 140 pagesize 10000
col "Status" for a10
col "Name" for a25
col "Type" for a10
col "Extent" for a15
SELECT d.status "Status",
d.tablespace_name "Name",
d.contents "Type",
d.extent_management "Extent",
ROUND(NVL(a.bytes, 0)) "Size (M)",
ROUND(NVL(a.bytes - NVL(f.bytes, 0), 0)) "Used (M)",
round(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0), 2) "Used %"
FROM sys.dba_tablespaces d,
(SELECT tablespace_name, SUM(DECODE(autoextensible, 'YES', maxbytes, 'NO', bytes))/1024/1024 bytes
FROM dba_data_files
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes)/1024/1024 bytes
FROM dba_free_space
GROUP BY tablespace_name) f
WHERE d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = f.tablespace_name(+)
--AND d.tablespace_name NOT IN ('SYSAUX', 'SYSTEM')
AND NOT (d.extent_management LIKE 'LOCAL' AND d.contents LIKE 'TEMPORARY')
UNION ALL
SELECT d.status "Status",
d.tablespace_name "Name",
d.contents "Type",
d.extent_management "Extent",
ROUND(NVL(a.bytes, 0)) "Size (M)",
ROUND(NVL(t.bytes, 0)) "Used (M)",
round(NVL(t.bytes / a.bytes * 100, 0), 2) "Used %"
FROM sys.dba_tablespaces d,
(SELECT tablespace_name, SUM(bytes)/1024/1024 bytes
FROM dba_temp_files
GROUP BY tablespace_name) a,
(SELECT tablespace_name, SUM(bytes_cached)/1024/1024 bytes
FROM v$temp_extent_pool
GROUP BY tablespace_name) t
WHERE d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = t.tablespace_name(+)
AND d.extent_management LIKE 'LOCAL'
AND d.contents LIKE 'TEMPORARY'
ORDER BY 7;
EOF
sed -i '$d' /tmp/tablespace.log
sed -i '$d' /tmp/tablespace.log
sed -i 's/,//g' /tmp/tablespace.log
Put these two scripts into zabbix-agent Configuration file for (/etc/zabbix/zabbix_agentd.conf) use
# stay /etc/zabbix/zabbix_agentd.conf Finally add
# Automatic table space discovery and alarm
UserParameter=ora.tbs.discovery,/etc/zabbix/zabbix_agentd.d/oracle_discovery.sh
UserParameter=tablespace[*],/etc/zabbix/zabbix_agentd.d/oracle_check.sh $1 $2
oracle_discovery.sh
#!/bin/bash
TABLESPACE=`cat /tmp/tablespace.log |awk '{print$2}'|awk 'NR>3{print}'`
COUNT=`echo "$TABLESPACE" |wc -l`
INDEX=0
echo '{"data":['
echo "$TABLESPACE" | while read LINE; do
echo -n '{"{#TABLESPACE}":"'$LINE'"}'
INDEX=`expr $INDEX + 1`
if [ $INDEX -lt $COUNT ]; then
echo ','
fi
done
echo ']}'
oracle_check.sh
#!/bin/bash
EQ_DATA="$2"
ZBX_REQ_DATA_TAB="$1"
SOURCE_DATA=/tmp/tablespace.log
case $2 in
maxmb) grep -Ew "$ZBX_REQ_DATA_TAB" $SOURCE_DATA |awk '{print $5}';;
used) grep -Ew "$ZBX_REQ_DATA_TAB" $SOURCE_DATA |awk '{print $6}';;
autopercent) grep -Ew "$ZBX_REQ_DATA_TAB" $SOURCE_DATA |awk '{print $7}';;
*) echo $ERROR_WRONG_PARAM; exit 1;;
esac
exit 0
To configure zabbix Auto discovery rules 、 Monitoring item 、 The alarm
Configure autodiscover rules
To configure 3 Monitoring items , Click on the monitor item prototype at the auto discovery rule :
Table space {#TABLESPACE} Usage rate
tablespace[{#TABLESPACE},autopercent]
Table space {#TABLESPACE} The maximum capacity /M
tablespace[{#TABLESPACE},maxmb]
Table space {#TABLESPACE} Already used /M
tablespace[{#TABLESPACE},used]
Configure trigger alarm
TableSpace {#TABLESPACE} alarm
{Template_Oracle-orabbix:tablespace[{#TABLESPACE},autopercent].last()}>95
Configure graphics
Configure graphic aggregation effect :
To configure EBS For monitoring, please refer to the following SQL:
https://github.com/ikzelf/zbxdb/blob/master/etc/zbxdb_checks/oracle/ebs.cfg
https://github.com/ikzelf/zbxdb/blob/master/etc/zbxdb_checks/oracle/primary.11.cfg
Other references :
https://oracle-base.com/articles/misc/an-introduction-to-json-support-in-the-oracle-database#json-support-in-12c
https://seeyon.ren/blog/index.php/archives/223/
https://blog.51cto.com/u_5646435/3170513
https://blog.cactifans.com/2020/05/19/Zabbix5.0%E7%89%88%E6%9C%ACAgent2%E5%AE%89%E8%A3%85/
https://bbs.huaweicloud.com/blogs/249319
https://blog.csdn.net/qq_22894935/article/details/115544995
https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/oracle_agent2?at=release/5.4
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/oracle/README.md
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/oracle
https://www.cnblogs.com/kerrycode/p/13368640.html
边栏推荐
- Oracle rman自动恢复脚本(生产数据向测试迁移)
- Ceaspectuss shipping company shipping artificial intelligence products, anytime, anywhere container inspection and reporting to achieve cloud yard, shipping company intelligent digital container contr
- Take you to master the formatter of visual studio code
- php中根据数字月份返回月份的英文缩写
- oracle EBS标准表的后缀解释说明
- 2021-07-19c CAD secondary development creates multiple line segments
- SQLI-LABS通關(less6-less14)
- CRP实施方法论
- 微信小程序基础
- Yolov5 practice: teach object detection by hand
猜你喜欢
Sqli - Labs Clearance (less6 - less14)
mapreduce概念和案例(尚硅谷学习笔记)
sqli-labs通关汇总-page4
CAD secondary development object
The default Google browser cannot open the link (clicking the hyperlink does not respond)
Only the background of famous universities and factories can programmers have a way out? Netizen: two, big factory background is OK
How to try catch statements that return promise objects in JS
Self study table Au
Flex Jiugongge layout
微信小程序基础
随机推荐
2021-07-17c /cad secondary development creation circle (5)
Oracle段顾问、怎么处理行链接行迁移、降低高水位
User login function: simple but difficult
RMAN增量恢复示例(1)-不带未备份的归档日志
Uniapp introduces local fonts
Tool grass welfare post
In depth study of JVM bottom layer (V): class loading mechanism
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Date time API details
Explain in detail the process of realizing Chinese text classification by CNN
外币记账及重估总账余额表变化(下)
Browser scrolling for more implementations
UEditor .Net版本任意文件上传漏洞复现
Sqli labs customs clearance summary-page2
SQLI-LABS通关(less2-less5)
php中删除指定文件夹下的内容
Use of interrupt()
JS divides an array into groups of three
Huawei mindspire open source internship machine test questions
CVE-2015-1635(MS15-034 )远程代码执行漏洞复现