因爲check_oracle_health是使用perl語言編寫的,所以在安裝該插件以前,首先要安裝oracle的客戶端實例,分別是basic,sqlplus,sdk包括perl的oracle插件(DBI和DBD)。html
Oracle Instant Client的主頁在http://www.oracle.com/technology/tech/oci/instantclient/index.html;同一軟件按配置分紅了不一樣的可下載包,讓用戶能夠按照本身的需求,找到最合適的部分下載。要成功配置DBD::Oracle, 須要instantclient-basic-xxx,instantclient-sdk-xxx,instantclient-sqlplus-xxx這三個文件,能夠下載zip包或者rpm包,zip包的話使用unzip命令在當前目錄解壓這三個zip文件,會自動生成instantclient_xxx目錄,這裏麪包含了以上三個包裏面的全部文件。ios
這時候這三個zip文件已經沒用,能夠刪之,也可備份供之後重用。web
wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.609.tar.gz sql
tar zxvf DBI-1.609.tar.gz 瀏覽器
cd DBI-1.609oracle
perl Makefile.PL app
make allui
make install 插件
wget http://mirrors.neusoft.edu.cn/cpan/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.52.tar.gz
tar zxvf DBD-Oracle-1.52.tar.gz
cd DBD-Oracle-1.52
perl Makefile.PLrest
此時會遇到錯誤:
解決方法是配置相應的環境變量:
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
注:此路徑爲安裝的instance所在目錄
export PATH=$ORACLE_HOME/bin:$PATH;
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
再執行perl Makefile.PL就能夠了
make
make install
wget http://labs.consol.de/wp-content/uploads/2009/09/check_oracle_health-1.6.3.tar.gz
tar zxvf check_oracle_health-1.6.3.tar.gz
cd check_oracle_health-1.6.3
./configure --prefix=/usr/lib/nagios/plugins --with-nagios-user=nagios --with-nagios-group=nagios --with-mymodules-dir=/usr/lib/nagios/plugins/libexec --with-mymodules-dyn-dir=/usr/lib/nagios/plugins/libexec
make all
make install
安裝完畢後,進入libexec目錄下查看已經有這個插件了。
在此目錄下打開終端,運行插件相應的命令,觀察是否可以正常執行,返回相應的結果。
Icinga2的配置文件與icinga1有很大不一樣,icinga1的配置文件均在object目錄下,分別是hosts.cfg,commands.cfg和services.cfg。可是icinga2的配置文件分爲兩部分,一部分在/etc/icinga2/conf.d目錄下的hosts.conf和services.conf文件,另外一部分是位於/usr/share/icinga2/include目錄下的command-plugins.conf文件。這三個文件與icinga1的文件的對應關係爲
Icinga1 icinga2
hosts.cfg < ————— > hosts.conf
services.cfg < ————— > services.conf
commands.cfg < ————— > command-plugins.conf
具體配置示例:
添加主機:
object Host "Host_Name" {
import "generic-host"
address = "the host’s IP"
}
添加命令:
object CheckCommand " Custom Command " {
import "plugin-check-command"
command = [ PluginDir + " /<file name stored in plugin directory> " ]
/*define all require arguments*/
arguments = {
"--connect"="$connection$"
"--username"="$user_name$"
"--password"="$pwd$"
"--mode"="$Mode$"
"--warning"="$W_ARG$"
"--critical"="$C_ARG$"
}
vars.connection = "the host’s hostname or address you want to connect"
vars.user_name = "user name"
vars.pwd = "password"
}
添加服務:
apply Service "Service Description" {
import "generic-service"
check_command = "Custom Command"
vars.Mode = "select mode you want to Monitor "
vars.W_ARG = beyond parameter1 cause Warning
vars.C_ARG = beyond parameter2 cause Critical
assign where host.name == " Host_Name "
}
把相應的主機,命令和服務都配好後,
重啓icnga2:systemctl restart icinga2
打開瀏覽器,輸入:http://localhost/icingaweb2/
登陸icingaweb2監控頁查看相關的監控信息。
至此,配置完成。