nagios-新增oracle資料庫監控
[root@mi6 ~]# cd /usr/local/nagios/
[root@mi6 nagios]# ls
bin etc libexec share
[root@mi6 nagios]# cd libexec/
[root@mi6 libexec]# ./check_oracle --help
check_oracle v1.5 (nagios-plugins 1.5)
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Usage:
check_oracle --tns
check_oracle --db
check_oracle --login
check_oracle --connect
check_oracle --cache
check_oracle --tablespace
check_oracle --oranames
check_oracle --help
check_oracle --version
Check Oracle status
--tns SID/IP Address
Check remote TNS server
--db SID
Check local database (search /bin/ps for PMON process) and check
filesystem for sgadefORACLE_SID.dbf
--login SID
Attempt a dummy login and alert if not ORA-01017: invalid username/password
--connect SID
Attempt a login and alert if an ORA- error is returned
--cache
Check local database for library and buffer cache hit ratios
---> Requires Oracle user/password and SID specified.
---> Requires select on v_ and v_
--tablespace
Check local database for tablespace capacity in ORACLE_SID
---> Requires Oracle user/password specified.
---> Requires select on dba_data_files and dba_free_space
--oranames Hostname
Check remote Oracle Names server
--help
Print this help screen
--version
Print version and license information
If the plugin doesn't work, check that the ORACLE_HOME environment
variable is set, that ORACLE_HOME/bin is in your PATH, and the
tnsnames.ora file is locatable and is properly configured.
When checking local database status your ORACLE_SID is case sensitive.
If you want to use a default Oracle home, add in your oratab file:
*:/opt/app/oracle/product/7.3.4:N
Send email to nagios-users@lists.sourceforge.net if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to nagiosplug-devel@lists.sourceforge.net.
Please include version information with all correspondence (when possible,
use output from the --version option of the plugin itself).
[root@mi6 libexec]#
配置修改如下:
被監控端(oracle資料庫伺服器)
[root@mi6 libexec]# cd /usr/local/nagios/libexec
1、新增oracle的環境變數
[root@mi6 libexec]# vi check_oracle
export ORACLE_SID=mi1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
2、檢測命令是否生效
[root@mi6 libexec]# ./check_oracle --tns mi ###mi是tns名字
OK - reply time 0 msec from mi
[root@mi6 libexec]# ./check_oracle --db mi1 ###mi1是例項名
mi1 OK - 1 PMON process(es) running
[root@mi6 libexec]# ./check_oracle --login mi ###mi是庫名
OK - dummy login connected
[root@mi6 libexec]# ./check_oracle --cache mi system mi123 80 90 ###mi是庫名,system是資料庫使用者,mi123是system使用者密碼
mi OK - Cache Hit Rates: 99.95% Lib -- 99.39% Buff|lib=99.95%;90;80;0;100 buffer=99.39%;90;80;0;100
[root@mi6 libexec]# ./check_oracle --tablespace mi system mi123 ERY 90 80 ###mi是庫名,system是資料庫使用者,mi123是system使用者密碼,ERY是表空間要大寫
mi : LOTTERY OK - .30% used [ 10216 / 10240 MB available ]|LOTTERY=.30%;80;90;0;100
3、修改 /usr/local/nagios/etc/nrpe.cfg 檔案。加入以下內容:
command[check_oracle_tns]=/usr/local/nagios/libexec/check_oracle --tns mi
command[check_oracle_db]=/usr/local/nagios/libexec/check_oracle --db mi1
command[check_oracle_login]=/usr/local/nagios/libexec/check_oracle --login mi
command[check_oracle_cache]=/usr/local/nagios/libexec/check_oracle --cache mi system mi123 80 90
command[check_oracle_tablespace]=/usr/local/nagios/libexec/check_oracle --tablespace mi system mi123 ERY 90 80
4、配置完成後,重啟 xinetd 服務。
service xinetd restart
監控端配置
1、可能會出現的錯誤,如果被監控端配置完後,監控端使用如下命令,出現如下錯誤;
[root@mi3 ~]# /usr/local/nagios/libexec/check_nrpe -H 172.16.10.18 -c check_oracle_tns ###172.16.10.18為資料庫的IP
NRPE: Command 'check_oracle_tns' not defined
解決方法:
由於nrpe是在root使用者下面啟動的,需要在oracle使用者下啟動。
如果在nagios的web管理頁面中出現錯誤提示:Status Information:Cannot determine ORACLE_HOME for sid servername 也同樣是這個問題。
root使用者關掉服務
[root@mi6 libexec]# ps aux|grep nrpe
root 7559 0.0 0.0 61204 752 pts/4 S+ 17:24 0:00 grep nrpe
nagios 23647 0.0 0.0 39988 1136 ? Ss Oct29 0:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@mi6 libexec]# kill -9 23647
[root@mi6 libexec]# ps aux|grep nrpe
root 7597 0.0 0.0 61204 756 pts/4 S+ 17:25 0:00 grep nrpe
oracle使用者開啟服務
[oracle@mi6 bin]$ /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[oracle@mi6 bin]$ exit
[root@mi6 libexec]# ps aux|grep nrpe
oracle 7600 0.0 0.0 39988 1140 ? Ss 17:25 0:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
root 7607 0.0 0.0 61204 756 pts/4 S+ 17:25 0:00 grep nrpe
檢視
[root@mi3 ~]# /usr/local/nagios/libexec/check_nrpe -H 172.16.10.18 -c check_oracle_tns
OK - reply time 0 msec from mi
2、修改oracle主機的配置檔案
[root@mi3 hosts]# cd /usr/local/nagios/etc/objects/hosts
[root@mi3 hosts]# vi oracleRAC1.cfg
define host {
use linux-server
host_name oracleRAC1
alias Oracle 11g
address 172.16.10.18
}
define service {
use generic-service
host_name oracleRAC1
service_description TNS Check
check_command check_nrpe!check_oracle_tns
}
define service {
use generic-service
host_name oracleRAC1
service_description DB Check
check_command check_nrpe!check_oracle_db
}
define service {
use generic-service
host_name oracleRAC1
service_description Login Check
check_command check_nrpe!check_oracle_login
}
define service {
use generic-service
host_name oracleRAC1
service_description Cache Check
check_command check_nrpe!check_oracle_cache
}
define service {
use generic-service
host_name oracleRAC1
service_description Tablespace Check
check_command check_nrpe!check_oracle_tablespace
}
重啟nagios
service nagios restart
[root@mi3 hosts]# vi oracleRAC2.cfg
define host {
use linux-server
host_name oracleRAC2
alias Oracle 11g
address 172.16.10.19
}
define service {
use generic-service
host_name oracleRAC2
service_description TNS Check
check_command check_nrpe!check_oracle_tns
}
define service {
use generic-service
host_name oracleRAC2
service_description DB Check
check_command check_nrpe!check_oracle_db
}
define service {
use generic-service
host_name oracleRAC2
service_description Login Check
check_command check_nrpe!check_oracle_login
}
define service {
use generic-service
host_name oracleRAC2
service_description Cache Check
check_command check_nrpe!check_oracle_cache
}
define service {
use generic-service
host_name oracleRAC2
service_description Tablespace Check
check_command check_nrpe!check_oracle_tablespace
}
測試
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --tns mi
OK - reply time 10 msec from mi
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --db mi2
mi2 OK - 1 PMON process(es) running
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --login mi
OK - dummy login connected
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --cache mi system mi123 80 90
mi OK - Cache Hit Rates: 99.97% Lib -- 99.65% Buff|lib=99.97%;90;80;0;100 buffer=99.65%;90;80;0;100
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --tablespace mi system mi123 LOTTERY 90 80
mi : LOTTERY OK - .30% used [ 10216 / 10240 MB available ]|LOTTERY=.30%;80;90;0;100
[root@mi6 nagios]# ls
bin etc libexec share
[root@mi6 nagios]# cd libexec/
[root@mi6 libexec]# ./check_oracle --help
check_oracle v1.5 (nagios-plugins 1.5)
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Usage:
check_oracle --tns
check_oracle --db
check_oracle --login
check_oracle --connect
check_oracle --cache
check_oracle --tablespace
check_oracle --oranames
check_oracle --help
check_oracle --version
Check Oracle status
--tns SID/IP Address
Check remote TNS server
--db SID
Check local database (search /bin/ps for PMON process) and check
filesystem for sgadefORACLE_SID.dbf
--login SID
Attempt a dummy login and alert if not ORA-01017: invalid username/password
--connect SID
Attempt a login and alert if an ORA- error is returned
--cache
Check local database for library and buffer cache hit ratios
---> Requires Oracle user/password and SID specified.
---> Requires select on v_ and v_
--tablespace
Check local database for tablespace capacity in ORACLE_SID
---> Requires Oracle user/password specified.
---> Requires select on dba_data_files and dba_free_space
--oranames Hostname
Check remote Oracle Names server
--help
Print this help screen
--version
Print version and license information
If the plugin doesn't work, check that the ORACLE_HOME environment
variable is set, that ORACLE_HOME/bin is in your PATH, and the
tnsnames.ora file is locatable and is properly configured.
When checking local database status your ORACLE_SID is case sensitive.
If you want to use a default Oracle home, add in your oratab file:
*:/opt/app/oracle/product/7.3.4:N
Send email to nagios-users@lists.sourceforge.net if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to nagiosplug-devel@lists.sourceforge.net.
Please include version information with all correspondence (when possible,
use output from the --version option of the plugin itself).
[root@mi6 libexec]#
配置修改如下:
被監控端(oracle資料庫伺服器)
[root@mi6 libexec]# cd /usr/local/nagios/libexec
1、新增oracle的環境變數
[root@mi6 libexec]# vi check_oracle
export ORACLE_SID=mi1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
2、檢測命令是否生效
[root@mi6 libexec]# ./check_oracle --tns mi ###mi是tns名字
OK - reply time 0 msec from mi
[root@mi6 libexec]# ./check_oracle --db mi1 ###mi1是例項名
mi1 OK - 1 PMON process(es) running
[root@mi6 libexec]# ./check_oracle --login mi ###mi是庫名
OK - dummy login connected
[root@mi6 libexec]# ./check_oracle --cache mi system mi123 80 90 ###mi是庫名,system是資料庫使用者,mi123是system使用者密碼
mi OK - Cache Hit Rates: 99.95% Lib -- 99.39% Buff|lib=99.95%;90;80;0;100 buffer=99.39%;90;80;0;100
[root@mi6 libexec]# ./check_oracle --tablespace mi system mi123 ERY 90 80 ###mi是庫名,system是資料庫使用者,mi123是system使用者密碼,ERY是表空間要大寫
mi : LOTTERY OK - .30% used [ 10216 / 10240 MB available ]|LOTTERY=.30%;80;90;0;100
3、修改 /usr/local/nagios/etc/nrpe.cfg 檔案。加入以下內容:
command[check_oracle_tns]=/usr/local/nagios/libexec/check_oracle --tns mi
command[check_oracle_db]=/usr/local/nagios/libexec/check_oracle --db mi1
command[check_oracle_login]=/usr/local/nagios/libexec/check_oracle --login mi
command[check_oracle_cache]=/usr/local/nagios/libexec/check_oracle --cache mi system mi123 80 90
command[check_oracle_tablespace]=/usr/local/nagios/libexec/check_oracle --tablespace mi system mi123 ERY 90 80
4、配置完成後,重啟 xinetd 服務。
service xinetd restart
監控端配置
1、可能會出現的錯誤,如果被監控端配置完後,監控端使用如下命令,出現如下錯誤;
[root@mi3 ~]# /usr/local/nagios/libexec/check_nrpe -H 172.16.10.18 -c check_oracle_tns ###172.16.10.18為資料庫的IP
NRPE: Command 'check_oracle_tns' not defined
解決方法:
由於nrpe是在root使用者下面啟動的,需要在oracle使用者下啟動。
如果在nagios的web管理頁面中出現錯誤提示:Status Information:Cannot determine ORACLE_HOME for sid servername 也同樣是這個問題。
root使用者關掉服務
[root@mi6 libexec]# ps aux|grep nrpe
root 7559 0.0 0.0 61204 752 pts/4 S+ 17:24 0:00 grep nrpe
nagios 23647 0.0 0.0 39988 1136 ? Ss Oct29 0:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@mi6 libexec]# kill -9 23647
[root@mi6 libexec]# ps aux|grep nrpe
root 7597 0.0 0.0 61204 756 pts/4 S+ 17:25 0:00 grep nrpe
oracle使用者開啟服務
[oracle@mi6 bin]$ /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[oracle@mi6 bin]$ exit
[root@mi6 libexec]# ps aux|grep nrpe
oracle 7600 0.0 0.0 39988 1140 ? Ss 17:25 0:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
root 7607 0.0 0.0 61204 756 pts/4 S+ 17:25 0:00 grep nrpe
檢視
[root@mi3 ~]# /usr/local/nagios/libexec/check_nrpe -H 172.16.10.18 -c check_oracle_tns
OK - reply time 0 msec from mi
2、修改oracle主機的配置檔案
[root@mi3 hosts]# cd /usr/local/nagios/etc/objects/hosts
[root@mi3 hosts]# vi oracleRAC1.cfg
define host {
use linux-server
host_name oracleRAC1
alias Oracle 11g
address 172.16.10.18
}
define service {
use generic-service
host_name oracleRAC1
service_description TNS Check
check_command check_nrpe!check_oracle_tns
}
define service {
use generic-service
host_name oracleRAC1
service_description DB Check
check_command check_nrpe!check_oracle_db
}
define service {
use generic-service
host_name oracleRAC1
service_description Login Check
check_command check_nrpe!check_oracle_login
}
define service {
use generic-service
host_name oracleRAC1
service_description Cache Check
check_command check_nrpe!check_oracle_cache
}
define service {
use generic-service
host_name oracleRAC1
service_description Tablespace Check
check_command check_nrpe!check_oracle_tablespace
}
重啟nagios
service nagios restart
[root@mi3 hosts]# vi oracleRAC2.cfg
define host {
use linux-server
host_name oracleRAC2
alias Oracle 11g
address 172.16.10.19
}
define service {
use generic-service
host_name oracleRAC2
service_description TNS Check
check_command check_nrpe!check_oracle_tns
}
define service {
use generic-service
host_name oracleRAC2
service_description DB Check
check_command check_nrpe!check_oracle_db
}
define service {
use generic-service
host_name oracleRAC2
service_description Login Check
check_command check_nrpe!check_oracle_login
}
define service {
use generic-service
host_name oracleRAC2
service_description Cache Check
check_command check_nrpe!check_oracle_cache
}
define service {
use generic-service
host_name oracleRAC2
service_description Tablespace Check
check_command check_nrpe!check_oracle_tablespace
}
測試
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --tns mi
OK - reply time 10 msec from mi
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --db mi2
mi2 OK - 1 PMON process(es) running
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --login mi
OK - dummy login connected
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --cache mi system mi123 80 90
mi OK - Cache Hit Rates: 99.97% Lib -- 99.65% Buff|lib=99.97%;90;80;0;100 buffer=99.65%;90;80;0;100
[root@mi7 etc]# /usr/local/nagios/libexec/check_oracle --tablespace mi system mi123 LOTTERY 90 80
mi : LOTTERY OK - .30% used [ 10216 / 10240 MB available ]|LOTTERY=.30%;80;90;0;100
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29819001/viewspace-1321607/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Zabbix+Python監控Oracle資料庫PythonOracle資料庫
- zabbix6.2新增mysql資料庫監控MySql資料庫
- Zabbix5.0 配置 ODBC 監控 Oracle 資料庫Oracle資料庫
- 【SQL】Oracle資料庫監控sql執行情況SQLOracle資料庫
- 【SQL】Oracle資料庫SQL監控報告示例SQLOracle資料庫
- Oracle 19C+13.4EMCC資料庫監控Oracle資料庫
- MySQL監控-Datadog資料庫監控調研MySql資料庫
- 監控資料庫活動資料庫
- 資料庫監控---PIGOSS BSM資料庫Go
- 資料庫繁忙程度監控資料庫
- Oracle資料庫監控和運維關注哪些方面Oracle資料庫運維
- Zabbix監控神通資料庫教程資料庫
- shell監控mysql 8.0資料庫MySql資料庫
- shell監控mysql 5.7資料庫MySql資料庫
- Python呼叫阿里雲資料庫監控資料Python阿里資料庫
- 使用免費的Oracle雲服務-使用並監控ATP資料庫Oracle資料庫
- 資料庫DML監控一例資料庫
- 資料庫管理-第145期 最強Oracle監控EMCC深入使用-02(20240205)資料庫Oracle
- Spark+Kafka實時監控Oracle資料預警SparkKafkaOracle
- 資料庫監控工具--PIGOSSBSM運維監控管理系統資料庫Go運維
- MySQL資料庫與Nacos搭建監控服務MySql資料庫
- 如何使用 taosKeeper 做好監控工作,時序資料庫 TDengine 3.0 監控工具詳解資料庫
- Oracle DG備庫手動管理新增資料檔案Oracle
- oracle批量新增更新資料Oracle
- 效能測試之資料庫監控分析工具PMM資料庫
- 幾款SQLSERVER資料庫監控軟體介紹SQLServer資料庫
- 自定義帶監控的資料庫連線池資料庫
- 前端資料監控到底在監控什麼?前端
- IndexedDB 資料庫新增資料Index資料庫
- ORACLE監控之OSW部署Oracle
- 系統監控&JVM監控指標資料查詢JVM指標
- 監控採集上報和儲存監控資料策略
- 「Oracle」Oracle 資料庫安裝Oracle資料庫
- UAVStack的慢SQL資料庫監控功能及其實現SQL資料庫
- 最新!2019 年最好用的 7 款資料庫監控工具資料庫
- 效能測試之資料庫監控分析工具Grafana+Prometheus資料庫GrafanaPrometheus
- 監控資料庫連線遇到的一個小問題資料庫
- Oracle ADG 備庫新增備庫Oracle
- 七麥資料釋出「版本更新監控」功能 挖掘共性探尋新增長