[原创]nagios搭建配置

nagios搭建配置

一、环境 ubuntu 14.04系统

host1:172.17.0.2 server
host2:172.17.0.3 client

二、安装

1.在两个主机上都执行一下命令:

#apt-get install update -y
#apt-get install build-essential -y

2.host1上安装nagios服务:

#apt-get install nagios3 nagios-nrpe-plugin -y

#apt-get install ndoutils-common -y //需要数据库的支持,执行之前确保mysql已经启动。若没有也可以跳过
#vim /etc/default/ndoutils //修改ENABLE_NDOUTILS=1为1.
#vim /etc/nagios3/nagios.cfg
添加:broker_module=/usr/lib/ndoutils/ndomod-mysql-3x.o config_file=/etc/nagios3/ndomod.cfg

3.启动NDOUtils和nagios:

#service ndoutils start
#/etc/init.d/nagios3 restart

4.host2安装nagios

#apt-get install nagios-nrpe-server nagios-plugins -y
#vim /etc/nagios/nrpe.cfg
allowed_hosts=127.0.0.1 172.17.0.2 //添加server的IP
#/etc/init.d/nagios-nrpe-server restart

5.host1配置监控host2的文件:
#vim /etc/nagios3/nagios.cfg
去掉cfg_dir=/etc/nagios3/servers的注释。
#vim /etc/nagios3/servers/clients.cfg
define host{
use generic-host
host_name host2 hostname
alias host2 hostname
address 172.17.0.3
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
define service {
use generic-service
host_name host2 hostname
service_description SSH
check_command check_ssh
notifications_enabled 0
}

#/etc/init.d/nagios3 restart

参考文档:http://www.tuicool.com/articles/F7zMRnM
原文地址:https://www.cnblogs.com/wsjhk/p/6909297.html