make install
=======================
这一步完成后会在/usr/local/nagios/下生成两个目录libexec和share
======================================
chown nagios.nagios /usr/local/nagios
然后
tar -zxvfnagios-nrpe_2.8.1.orig.tar.gz
cd nagios-nrpe_2.8.1
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
========================================================
vi /usr/local/nagios/etc/nrpe.cfg
将allowed_hosts=127.0.0.1
修改成你的nagios服务器的ip
=======================================
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
启动nrpe
================================================
netstat -an|grep 5666
察看是否在5666端口上监听
注意: 释放端口5666,很重要
===================================
/usr/local/nagios/libexec/check_nrpe -H localhost
察看是否能返回nrpv版本号,返回则正常!
=============================================
vi/usr/local/nagios/etcnrpe.cfg
可以看到里面监控对象
# The following examples use hardcoded command arguments...
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
=============================================================
我们为了监控swap
在nrpe.cfg中添加
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
===================================================
然后再启动nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d
这样子,在监控端算是设置完了!!!
2。我们来设置nagios服务器端的设置!
安装nagios-nrpe_2.8.1.orig.tar.gz
这里安装过程比上面再被监控服务安装少两部
=========================================
tar -zxvfnagios-nrpe_2.8.1.orig.tar.gz
cd nagios-nrpe_2.8.1
./configure
make all
make install-plugin
================================
然后我们测试下连通性
/usr/local/nagios/libexec/check_nrpe -H 被监控端ip
如果返回nrpe版本号,那么正常!
如果返回拒绝连接!那么telnet ip 5666看是否正常
======================================================
配置:
=================================
由于nrpe外构组件,所以必须在commands.cfg中定义(我这里的nagios版本是3.0.3和2。x的版本有些不一样)
[root@localhost etc]# vi /usr/local/nagios/etc/objects/commands.cfg
最下面添加
#check nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
========================================================
[root@localhost etc]# vi /usr/local/nagios/etc/nagios.cfg
中间添加
cfg_file=/usr/local/nagios/etc/objects/aiyo-mailserver.cfg
最后面的 aiyo-mailserver.cfg你们可以自己改,或者Linux1.cfg也可以!
=================================================
新建aiyo-mailserver.cfg
[root@localhost etc]# vi /usr/local/nagios/etc/objects/aiyo-mailserver.cfg
添加
define host{
use linux-server
host_name aiyo-mailserver
alias aiyo-mailserver
address 210.51.47.213
}
define service{
use generic-service
host_name aiyo-mailserver
service_description HTTP
check_command check_http
}
define service{
use generic-service
host_name aiyo-mailserver
service_description
check_command check_ftp
define service{
use generic-service
host_name aiyo-mailserver
service_description
check_command check_ssh
}
define service{
use generic-service
host_name aiyo-mailserver
service_description SMTP
check_command check_smtp
}
define service{
use generic-service
host_name aiyo-mailserver
service_description POP3
check_command check_pop
}
define service{
use generic-service
host_name aiyo-mailserver
service_description check-swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name aiyo-mailserver
service_description check-load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name aiyo-mailserver
service_description check-disk
check_command check_nrpe!check_had1
define service{
use generic-service
host_name aiyo-mailserver
service_description zombie_procs
check_command check_nrpe!check_zombie_procs
}
define service{
use generic-service
host_name aiyo-mailserver
service_description check-users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name aiyo-mailserver
service_description total_procs
check_command check_nrpe!check_total_procs
}
保存,退出!
这个里面定义了对象和服务!
注意:
define host{
use linux-server
这个你要能在commands.cfg找到!如果是3.0.x版本,应该就对的
!如果是2。x版本,不一样定了!
=====================================================
我们来运行
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
检测下是不是都正确!
================================================
正确的话,那么我们重新启动nagios
那么在web页面里面就会出现!!
但是页面显示disk一项可能出现红色警告信息!因为linux下如果我的是sad1,那么写had1就没用了!
哈哈!
临时记下,!明天继续!!!