nagios check_oracle_health install shell
2014-05-27为了简化安装,写成脚本。
#ins_chk_ora_health.sh
#!/bin/sh
#输入ID,或者ID,针对多台主机
ID=$1
if [[ -z "$1" ]];then
echo "Usage: $0 ID"
exit 0;
fi
#防止重复执行后添加多次变量
sed -i '/ORACLE/d' ~/.bash_profile
grep ORACLE ~oracle/.bash_profile >> ~/.bash_profile
. ~/.bash_profile
#解决权限问题,否则报错:libnnz10.so: cannot restore segment prot after reloc
chcon -t texrel_shlib_t $ORACLE_HOME/lib/libnnz10.so
chcon -t texrel_shlib_t $ORACLE_HOME/lib/libclntsh.so.10.1
#添加tnsnames.ora,并防止重复添加
sed -i '/^DB/,$d' $ORACLE_HOME/network/admin/tnsnames.ora
cat >> $ORACLE_HOME/network/admin/tnsnames.ora << EOF
DB${ID} =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.10.1.${ID})(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dydb)
)
)
EOF
#下载解压安装包
wget -c http://wallcopper.com/tar/ora_health.gz -P /opt
cd /opt
tar zxf ora_health.gz
tar zxf DBI-1.631.tar.gz
tar zxf DBD-Oracle-1.70.tar.gz
tar zxf check_oracle_health-1.9.3.4.tar.gz
#安装3个包
pushd DBI-1.631;
perl Makefile.PL;make;make install
popd
pushd DBD-Oracle-1.70;
perl Makefile.PL;make;make install
popd
pushd check_oracle_health-1.9.3.4;
./configure;make;make install
popd
#修改nrpe配置
sed -i '/check_tnsping/d' /usr/local/nagios/etc/nrpe.cfg
sed -i '/check_session/d' /usr/local/nagios/etc/nrpe.cfg
cat > ora.txt << EOF
command[check_tnsping]=/usr/local/nagios/libexec/check_oracle_health --connect=DB${ID} --mode=tnsping
command[check_session]=/usr/local/nagios/libexec/check_oracle_health --connect=DB${ID} --username=system --password=whoami123456 --mo
de=sql --name='select count(1) from v\$session' --name2=current_sessions --warning 100 --critical 300
EOF
sed -i '/check_total_procs/r ora.txt' /usr/local/nagios/etc/nrpe.cfg
/etc/init.d/xinetd restart
#添加用户nagios到oinstall分组,否则报错:CRITICAL - cannot connect to DB17. ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var or PATH (Windows) and or NLS settings, permissions, etc.
usermod -G oinstall nagios
#测试本机是否成功
source ~/.bash_profile
/usr/local/nagios/libexec/check_oracle_health --connect=DB${ID} --mode=tnsping
/usr/local/nagios/libexec/check_oracle_health --connect=DB${ID} --username=system --password=whoami123456 --mode=sql --name='select count(1) from v$session' --name2=current_sessions --warning 100 --critical 300
#nagios主机上增加check_tnsping.sh测试
/user/local/nagios/libexec/check_nrpe -H $1 -c check_tnsping
添加nagios配置:
define service{
use generic-service
host_name 172.16.1.1
service_description tnsping
check_command check_nrpe!check_tnsping
}
相关日志
- 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表空间文件后空间不释放
- oracle最大连接数processes
- nagios check_oracle_health
- 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)