多少年前就装过了,今天再来用yum装一次,都忘干净了~~
主监控机:CentOS 6.5 192.168.0.105
被监控机:CentOS 6.5 192.168.0.107
主监控机设置:
1、安装epel,http,php
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -ivh epel-release-latest-.noarch.rpm
yum -y install httpd php
2、安装nagios、nagios-plugin与nrpe (nagios 4.3.4版本)
yum install -y nagios nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe
3、启动apache与nagios
/etc/init.d/httpd restart
/etc/init.d/nagios start
4、登陆http://localhost/nagios/,输入用户密码后查看是否正常运行
注:别忘记了nagios后面那个/,不然……
被监控机设置:
1、安装需要软件
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -ivh epel-release-latest-.noarch.rpm
yum install -y nagios-plugins nagios-plugins-nrpe nrpe nagios-plugins-load nagios-plugins-disk nagios-plugins-swap
2、配置nrpe
vi /etc/nagios/nrpe.cfg 修改监控机的地址或域名
allowed_hosts=127.0.0.1,192.168.0.105
3、修改/etc/hosts.allow增加主监控机ip
echo 'nrpe:192.168.0.105' >> /etc/hosts.allow
4、启动 NRPE 守护进程:
/usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
可以将此命令加入 /etc/rc.local ,以便开机自动启动。
echo "/usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d" >> /etc/rc.local
以下在主监控机上执行
1、从主监控机上检查 NRPE 是否正常:
/usr/lib64/nagios/plugins/check_nrpe -H 192.168.0.107
输出为NRPE v3.2.0
2. 添加nrpe的定义
vi /etc/nagios/objects/commands.cfg
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
3. 增加主监控机配置项vi /etc/nagios/objects/11.cfg
define host{
use linux-server
host_name 192.168.0.107
alias 192.168.0.107
address 192.168.0.107
}
define service{
use generic-service
host_name 192.168.0.107
service_description load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name 192.168.0.107
service_description PING
check_command check_ping!100.0,%!200.0,%
max_check_attempts
normal_check_interval
}
define service{
use generic-service
host_name 192.168.0.107
service_description FTP
check_command check_ftp!
max_check_attempts
normal_check_interval
}
define service{
use generic-service
host_name 192.168.0.107
service_description SSH
check_command check_ssh
max_check_attempts
normal_check_interval
}
define service{
use generic-service
host_name 192.168.0.107
service_description HTTP
check_command check_http
max_check_attempts
normal_check_interval
}
并把11.cfg添加到nagios主配置项
echo "cfg_file=/etc/nagios/objects/11.cfg" >> /etc/nagios/nagios.cfg
其他机器如法炮制即可
4. 重启监控机nagios
/etc/init.d/nagios reload
重新打开监控查看,是否已经有新机器上线!
看看效果
哎!想当年那环境,苦逼的离线安装各种软件。。。。没网真的不行啊!!!!!