下载nagios nagios-plugs nrpe
  下载apache
1) 安装apache
进入tar包解压路径( zxvf 选项解压 tar.bz jxvf选项解压)
cd /usr/httpd-2.2.11
安装
./configure --prefix=/usr/local/apache && make && make install
在安装完nagios后在/usr/local/apache/f添加
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin">
    AuthType Basic
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthUserFile /usr/local/nagios/etc/htpasswd
    Require valid-user
</Directory>
Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
    AuthType Basic
    Options None
rubyinstaller包解压后怎么安装
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "nagios Access"
    AuthUserFile /usr/local/nagios/etc/htpasswd
    Require valid-user
</Directory>
或者用Include /usr/nagios-3.06/f  方式添加
2)安装nagios
  cd /usr/nagios-3.0.6  (nagios 3.1版本tar包有些问题,安装后不能访问目前建议使用低版本)
安装
a)添加nagios用户
adduser nagios
b)执行安装命令
./configure --prefix=/usr/local/nagios 
make all
make install       
make install-init     ##This installs the init
make install-commandmode 
make install-config    ##将初始的配置文件安装到/usr/local/nagios/etc
3)安装nagios-plugs
./configure --prefix=/usr/local/nagios/ --enable-redhat-pthread-workaround(此选项针对redhat)
make all
make install
4)安装nrpe测试本地
# ./configure --prefix=/usr/local/nagios  --enable-ssl
make all
make install-plugin
make install-daemon
make install-daemon-config
Install the NRPE daemon as a service under xinetd.
make install-xinetd
Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.
only_from = 127.0.0.1 210.51.4.114 <nagios_ip_address>
Add the following entry for the NRPE daemon to the /etc/services file.
nrpe 5666/tcp # NRPE
Restart the xinetd service.
service xinetd restart
5)测试nrpe情况
# netstat -at|grep nrpe
tcp        0      0 *:nrpe                  *:*                    LISTEN   
# netstat -an|grep 5666
tcp        0      0 0.0.0.0:5666            0.0.0.0:*              LISTEN 
可以看到5666端口已经在监听了
6)执行
/usr/local/nagios/libexec/check_nrpe -H localhost
测试nrpe是否正常工作
7)执行下面命令检查nagios配置
/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
7)执行下面命令启动nagios
/usr/local/nagios/bin/nagios –d /usr/local/nagios/etc/nagios.cfg
8)为nagios登录界面添加用户及密码
/usr/local/apache/bin/htpasswd –c /usr/local/nagios/etc/htpasswd nagios
9)修改/usr/local/nagios/etc/cgi.cfg
default_user_name=nagios
更改文件内的nagiosadmin为nagiosadmin,nagios
10)chmod 777 /usr/local/nagios/var/d
chmod 777 /usr/local/nagios/var/rw
11)启动apache
/usr/local/apache/bin/apachectl start
通过192.168.1.12/nagios访问nagios
12)添加开机自启动
echo “/usr/local/apache/bin/apachectl start”  >>  /etc/rc.local
echo “/usr/local/nagios/bin/nagios –d /usr/local/nagios/etc/nagios.cfg”  >>  /etc/rc.local
/i?d=1  如缺少监控脚本可在此站下载
客户端安装配置
在客户端只需安装nagios-plugin nrpe
安装步骤与服务端相同
安装完成之后修改其相关配置
Vi /etc/xinetd.d/nrpe 修改only_from添加服务端IP
  only_from      = 127.0.0.1 192.168.6.252(服务端IP
vi $nagioshome/etc/nrpe.cfg 添加相关command命令
重启xinetd服务
从服务端测试nrpe通信
/usr/local/nagios/libexec/check_nrpe -H IP(客户端IP)
配置相关cfg文件(可参考田逸相关nagios文档)
手动添加hosts.cfg
define host{
        host_name              254-test
        address                192.168.6.254
        check_command          check-host-alive
        contact_groups          test
        max_check_attempts        5
        notification_interval      10
        notification_period        24x7
        notification_options        d,u,r
        }
添加hostgroups.cfg
define hostgroup{
        hostgroup_name  game-hosts              ; The name of the hostgroup
        members        hm1-1,hm5-1,hm9-1,hm7-1,hm8-1    ; Comma separated list of hosts that belong to this group
        }
添加服务services.cfg
define service{
        host_name                      *
        service_description            traffic
        check_command                  check_nrpe_traffic
        contact_groups                  test
        check_period                    24x7
        max_check_attempts              4
        normal_check_interval          3
        retry_check_interval            2
        contact_groups                  test

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。