nagios系統(tǒng)搭建筆記
define host{
use linux-server
host_name 192.168.100.1
alias 192.168.100.1
address 192.168.100.1
}
define host{
use linux-server
host_name 192.168.100.2
alias 192.168.100.2
address 192.168.100.2
}
(2)cat /etc/nagios/objects/service/vianetgroup.cfg
############## jiaxiao quan server ################
define hostgroup{
hostgroup_name jiaxiao-server
alias jiaxiao quan server
members 192.168.100.1,192.168.100.2
}
(3)cat /etc/nagios/objects/service/vianetservice.cfg
#############Nagios NRPE################
define service {
use generic-service
hostgroup_name jiaxiao-server
service_description Load
check_command check_nrpe!check_load
}
define service {
use generic-service
hostgroup_name jiaxiao-server
service_description Disk_Free
check_command check_nrpe!check_disk
}
define service {
use generic-service
hostgroup_name jiaxiao-server
service_description CPU
check_command check_nrpe!check_cpu
}
(4)啟動nagios
/usr/bin/nagios -v /etc/nagios/nagios.cfg 正常
/etc/init.d/nagios restart 正常
瀏覽器打開http://120.132.xx.xx:8080/nagios/ 查看, 正常
5.配置nsca
在2.14上起nsca daemon服務,在100.6通過send_nsca傳送到2.14(120.132.xx.xx)統(tǒng)一進行前端頁面展示管理。
(1)編譯nsca
wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nsca-2.7.2.tar.gz
tar -zxvf nsca-2.7.2.tar.gz
cd nsca-2.7.2
./configure make all
(2)nsca2.14服務端配置(之前已配置好)
cp sample-config/nsca.cfg /etc/nagios/
cp src/nsca /usr/sbin/
配置password
vi /etc/nagios/nsca.cfg
password=139com
開啟nsca程序
/usr/sbin/nsca -c /etc/nagios/nsca.cfg –daemon
vi /usr/local/nagios/etc/nagios.cfg
check_external_commands=1
accept_passive_service_checks=1
accept_passive_host_checks=1
(3)100.6nsca客服端配置
cp sample-config/send_nsca.cfg /etc/nagios/
cp src/send_nsca /usr/bin/
配置password
vi /etc/nagios/send_nsca.cfg
password=139com
vi /usr/local/nagios/etc/nagios.cfg
enable_notifications=0
obsess_over_services=1
ocsp_command=submit_check_result
obsess_over_hosts=1
ochp_command=submit_host_result
cat submit_check_result
#!/bin/sh
return_code=-1
case “$3″ in
OK)
return_code=0
;;
WARNING)
return_code=1
;;
CRITICAL)
return_code=2
;;
UNKNOWN)
return_code=-1
;;
esac
/usr/bin/printf “%st%st%st%sn” “$1″ “$2″ “$return_code” “$4″ | /usr/bin/send_nsca -H 120.132.xx.xx -p 15667 -c /etc/nagios/send_nsca.cfg
cat submit_host_result
#!/bin/sh
/usr/bin/printf “%st%st%st%sn” “$1″ “$2″ “$3″ |/usr/bin/send_nsca -H 120.132.xx.xx -p 15667 -c /etc/nagios/send_nsca.cfg
(3)測試
echo “192.168.100.8;TEST_NSCA;2;hahajusttest” | /usr/bin/send_nsca -H 120.132.xx.xx-p 15667 -to 10 -d “;” -c /etc/nagios/send_nsca.cfg
1 data packet(s) sent to host successfully.
6.在2.14上配置被動監(jiān)控
(1)cat vianethost.cfg
############ jiaoxiao quan server ##################
define host{
use passive-server
host_name 192.168.100.1
alias 100.1(jiaxiao_web)
address 192.168.100.1
}
define host{
use passive-server
host_name 192.168.100.2
alias 100.2(jiaxiao_web)
address 192.168.100.2
}
(2)cat vianetgroup.cfg
############## jiaxiao quan server ################
define hostgroup{
hostgroup_name jiaxiao-server
alias jiaxiao quan server
members 192.168.100.1,192.168.100.2
}
(3)cat vianetservice.cfg
#############Nagios NRPE################
define service {
use passive-service
hostgroup_name jiaxiao-server
service_description Load
}
define service {
use passive-service
hostgroup_name jiaxiao-server
service_description Disk_Free
}
define service {
use passive-service
hostgroup_name jiaxiao-server
service_description CPU
}
(4)啟動nagios
/usr/bin/nagios -v /etc/nagios/nagios.cfg 正常
/etc/init.d/nagios restart 正常
瀏覽器打開http://120.132.xx.xx:10000/nagios/查看, 正常
over!!
評論