微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > nagios系统搭建笔记

nagios系统搭建笔记

时间:10-10 来源:互联网 点击:

l5.x86_64.rpm

(2)修改nrpe.cfg

vi /etc/nagios/nrpe.cfg

allowed_hosts=192.168.100.6

command[check_cpu]=/usr/lib64/nagios/plugins/check_cpu

command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,12,9 -c 30,25,20

command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 12% -c 8% -p /

(3)启动nrpe

/etc/init.d/nrpe start

netstat -npl 查看nrpe5666端口是否启动了。

(4)测试

在100.6执行如下命令进行测试

/usr/lib64/nagios/plugins/check_nrpe -H 192.168.100.1 -c check_cpu

4.配置nagios

(1)cat /etc/nagios/objects/service/vianethost.cfg

################ jiaoxiao quan server ##############################

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)统一进行前端页面展示管理。

(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 “%s\t%s\t%s\t%s\n” “$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 “%s\t%s\t%s\t%s\n” “$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上配置被动监控

(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

####

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top