nagios check_oracle_health
2014-04-11check_oracle_health is a plugin to check various parameters of an Oracle database
1、nagios提供一个shell脚本check_oracle用来监测oracle,但是更复杂的监测还需配置check_oracle_health.
http://labs.consol.de/download/shinken-nagios-plugins/check_oracle_health-1.9.3.4.tar.gz
tar zxvf check_oracle_health-1.9.3.4.tar.gz
cd check_oracle_health-1.9.3.4
./configure;make;make install
参考文档:
http://labs.consol.de/lang/en/nagios/check_oracle_health/
2、为了连接Oracle,需要配置oracle参数,远程简单化,可以用instantclient代替,如果在oracle数据库上配置监测,没有必要
instantclient-basic-linux.x64-11.2.0.4.0.zip
instantclient-sdk-linux.x64-11.2.0.4.0.zip
instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
cd /;unzip *.zip
###########################################
vi ~/.bash_profile增加
export PATH=$PATH:/instantclient_11_2
export LD_LIBRARY_PATH=/instantclient_11_2
export ORACLE_HOME=/instantclient_11_2
export NLS_LANG=AMERICAN_CHINA.ZHS16GBK
export TNS_ADMIN=/instantclient_11_2
alias lsqlplus='rlwrap sqlplus /nolog'
3、check_oracle_health是Perl脚本,为了使用check_oracle_health,需要安装perl-DBI,perl-DBD-oracle
perl-DBI可以用yum安装
yum install perl-DBI (perl-DBD-mysql )
或者下载
wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.631.tar.gz
#tar -zxvf DBI-1.631.tar.gz
#cd DBI-1.631
#perl Makefile.PL
#make all
#make install
perl-DBD-oracle安装需要提前配置好oracle客户端环境
wget http://www.cpan.org/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.70.tar.gz
tar zxf DBD-Oracle-1.70.tar.gz
perl Makefile.PL
make;make install
4、为了使用sqlplus,可以安装rlwrap
wget http://utopia.knoware.nl/~hlub/rlwrap/rlwrap-0.37.tar.gz
tar zxf rlwrap-0.37.tar.gz
cd rlwrap-0.37
./configure --prefix=/usr
make;make install
5、配置/instantclient_11_2/tnsnames.ora
DB01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.10.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = backupdb)
)
)
6、实例:
./check_oracle_health --connect DB01 --mode tnsping
./check_oracle_health --connect DB01 --username system --password 123456 --mode list-tablespaces
./check_oracle_health --connect DB01 --username system --password 123456 --mode latch-waiting --name 'user lock'
./check_oracle_health --connect DB01 --username system --password 123456 --mode tablespace-usage --name SYSTEM
./check_oracle_health --connect DB01 --username system --password 123456 --mode tablespace-free --name USERS
./check_oracle_health --mode pga-in-memory-sort-ratio
./check_oracle_health --mode sga-shared-pool-free
7、oracle也可以创建nagios监测专用账户
CREATE USER nagios IDENTIFIED BY oraclemon;
GRANT CREATE SESSION TO nagios;
GRANT SELECT any dictionary TO nagios;
GRANT SELECT ON V_$SYSSTAT TO nagios;
GRANT SELECT ON V_$INSTANCE TO nagios;
GRANT SELECT ON V_$LOG TO nagios;
GRANT SELECT ON SYS.DBA_DATA_FILES TO nagios;
GRANT SELECT ON SYS.DBA_FREE_SPACE TO nagios;
8、数据库nrpe.cfg配置实例
command[check_oracle_health_soft]=/usr/local/nagios/libexec/check_oracle_health --connect=prod --user=nagios --password=oradbmon --mode=soft-parse-ratio
command[check_oracle_health_tnsping]=/usr/local/nagios/libexec/check_oracle_health --connect=prod --user=nagios --password=oradbmon --mode=tnsping
command[check_oracle_health_tbs]=/usr/local/nagios/libexec/check_oracle_health --connect=prod --user=nagios --password=oradbmon --mode=tablespace-usage
command[check_oracle_health]=/usr/local/nagios/libexec/check_oracle_health --connect=你oracle的SID --user=oracle用户 --password=oracle密码 --mode=tablespace-usage
9、nagios配置实例
/usr/local/nagios/libexec/check_nrpe -H 你的被监控机IP地址 -c check_oracle_health
/usr/local/nagios/libexec/check_nrpe -H 192.168.10.10 -c check_oracle_health_tnsping
/usr/local/nagios/libexec/check_nrpe -H 192.168.10.10 -c check_oracle_health_tbs
define service{
use generic-service
host_name 172.10.1.019
service_description tnsping
check_command check_nrpe!check_oracle_health_tnsping
}
10、常见问题
1)CRITICAL - cannot connect to DB01. install_driver(Oracle) failed: Can't load '/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.10.1: cannot open shared object file: No such file or directory at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.
将nagios用户添加组oinstall
[root@server74 ~]# usermod -G oinstall nagios
[root@server74 ~]# id nagios
uid=502(nagios) gid=503(nagios) groups=503(nagios),500(oinstall)
2)libnnz10.so: cannot restore segment prot after reloc: Permission denied
chcon -t texrel_shlib_t $ORACLE_HOME/lib/libnnz10.so
chcon -t texrel_shlib_t $ORACLE_HOME/lib/libclntsh.so.10.1
3) setenforce 0
setenforce: SELinux is disabled
4)/etc/ld.so.conf添加$ORACLE_HOME/lib(一般此步骤非必须)
执行ldconfig
分类:Linux、操作系统 | 标签: database、nagios |相关日志
- oracle中drop一个表,让数据文件释放空间
- oracle批量杀掉死锁进程
- ORA-00257: archiver error. Connect internal only, until freed. (DBD ERROR: OCISessionBegin)
- oracle同义词SYNONYM
- substr()函数
- oracle create dblink
- oracle 启动归档模式
- oracle表空间文件
- linux删除oracle表空间文件后空间不释放
- nagios check_oracle_health install shell
- oracle最大连接数processes
- cx_Oracle for python
- 数据库查询重复行shell脚本
- oracle导入txt数据文件实例
- mysql导入txt数据文件实例
- 修改NLS_CHARACTERSET和NLS_NCHAR_CHARACTERSET字符集
- NLS_NCHAR_CHARACTERSET和NLS_CHARACTERSET的区别
- 如何安装mysql-5.6.12
- 设置NLS_LANG环境变量
- Oracle Golden Gate数据库同步技术
- mysql或oracle合并行函数
- Oracle InstantClient安装步骤
- shell sqlplus run sql
- oracle误删datafile
- mysqld_safe — MySQL Server Startup Script
- 如何禁用mysql端口3306
- oracle触发器实例 (8)
- sql语句处理BLOB (8)
- Drizzle A database for the Cloud (1)
- SGA/PGA的设置与调整 (9)
- 根据v$SGA_TARGET_ADVICE设置SGA SIZE (6)
- shmmax/shmall和sga_max_size/sga_target应该设置多大 (3)
- exp/imp和expdp/impdp的逻辑哲学 (1)
- oracle安装后期stop big port (1)
- OLTP和OLAP的区别 (3)
- mysql创建数据库及用户 (1)
- Mysql分支MariaDB简介 (6)
- ORA-01843: not a valid month (3)
- sql语句where 1=1和1=2的作用 (4)
- 如何安装mysql-5.5.31 (8)
- rlwrap实现sqlplus使用上下键查历史命令
- CentOS_x64_6.3 install Oracle 10.2.0.1报错ins_emdb.mk (2)