標籤:
Icinga2安裝配置check_oracle_health流程1.安裝
由於check_oracle_health是使用perl語言編寫的,因此在安裝該外掛程式之前,首先要安裝oracle的用戶端執行個體,分別是basic,sqlplus,sdk包括perl的oracle外掛程式(DBI和DBD)。
第一步: 下載Oracle Instant Client
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目錄,這裡麵包含了以上三個包裡面的所有檔案。
這時候這三個zip檔案已經沒用,可以刪之,也可備份供以後重用。
第二步:安裝DBI
wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.609.tar.gz
tar zxvf DBI-1.609.tar.gz
cd DBI-1.609
perl Makefile.PL
make all
make install
第三步:安裝DBD
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.PL
此時會遇到錯誤:
解決方案是配置相應的環境變數:
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
註:此路徑為安裝的instance所在目錄
exportPATH=$ORACLE_HOME/bin:$PATH;
exportLD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
再執行perl Makefile.PL就可以了
make
makeinstall
第四步:安裝check_oracle_health
wget http://labs.consol.de/wp-content/uploads/2009/09/check_oracle_health-1.6.3.tar.gz
tarzxvf check_oracle_health-1.6.3.tar.gz
cdcheck_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
makeall
makeinstall
安裝完畢後,進入libexec目錄下查看已經有這個外掛程式了。
在此目錄下開啟終端,運行外掛程式相應的命令,觀察是否能夠正常執行,返回相應的結果。
2.配置
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
具體配置樣本:
host.conf檔案配置:
添加主機:
objectHost "Host_Name" {
import "generic-host"
address = "the host’s IP"
}
command-plugins.conf檔案配置:
添加命令:
objectCheckCommand " Custom Command " {
import"plugin-check-command"
command = [ PluginDir + " /<filename 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 addressyou want to connect"
vars.user_name= "user name"
vars.pwd= "password"
}
services.conf檔案配置:
添加服務:
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 wherehost.name == " Host_Name "
}
把相應的主機,命令和服務都配好後,
重啟icnga2:systemctl restart icinga2
開啟瀏覽器,輸入:http://localhost/icingaweb2/
登入icingaweb2監控頁查看相關的監控資訊。
至此,配置完成。
Icingaweb2監控oracle資料庫的安裝配置流程