此平台是基于apache2.2.1+php5.3.0+nagios3.1.2+fetion2009等软件的组合搭建而出,这些软件的版本是现阶段最新的。本人经过一段时间的搭建与测试,各个功能都能够成功实现,现源于开源软件,本人却不敢独享,现把搭建与配置过程介绍如下:
一、服务器端的设置
1、下载需求软件:
nagios主程序:
nagios插件程序:
apache程序:
php程序:
libACE程序:
fetion机器人程序:
2、软件的安装
(1) apache的安装
[root@localhost httpd-2.2.11]# ./configure --prefix=/usr/local/apache --enable-so
[root@localhost httpd-2.2.11]# make && make install
(2) php的安装
[root@localhost php-5.2.10]# ./configure --prefix=/usr/local/php    \
>    --with-apxs2=/usr/local/apache/bin/apxs
[root@localhost php-5.2.10]# make && make install
[root@localhost php-5.2.10]# cp php.ini-dist /usr/local/lib/php.ini
[root@localhost php-5.2.10]# vi /usr/local/apache/conf/httpd.conf
    为了配置文件的工整,在配置文件的相关地方加入如下配置:
LoadModule php5_module modules/libphp5.so(如果有,不用加)
AddType application/x-httpd-php .php .html
找到DirectoryIndex index.html
改为:DirectoryIndex index.php index.html
在最后加入nagios的访问目录:
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
</Directory>
Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
请输入内容
(3) nagios的安装
    为了支持Nagios安装完后status map,trend等完全显示,需要gd库的支持,首先看一下gd与gd-devel有没有安装
nagios监控服务器_开源软件[root@localhost php-5.2.10]#rpm -qa|grep gd
nagios监控服务器_开源软件gdb-6.5-37.el5
nagios监控服务器_开源软件libgdiplus-1.2.5-1.el5.centos
nagios监控服务器_开源软件gd-2.0.33-9.4.el5_1.1
nagios监控服务器_开源软件gdbm-1.8.0-26.2.1
nagios监控服务器_开源软件sysklogd-1.4.1-44.el5
nagios监控服务器_开源软件libgdiplus-devel-1.2.5-1.el5.centos
nagios监控服务器_开源软件gd-devel-2.0.33-9.4.el5_1.1
    如果没有,请拿出光盘安装上,或者用yum -y install gd*安装也可
nagios监控服务器_开源软件[root@localhost nagios-3.1.2]# useradd nagios
nagios监控服务器_开源软件[root@localhost nagios-3.1.2]#
./configure --prefix=/usr/local/nagios \
nagios监控服务器_开源软件> --with
-gd-lib=/usr/lib --with-gd-inc=/usr/include --with-nagios-user=nagios \
nagios监控服务器_开源软件> --with-nagios-group=nagios

nagios监控服务器_开源软件[root@localhost nagios-3.1.2]#make all
nagios监控服务器_开源软件[root@localhost nagios-3.1.2]#make install
nagios监控服务器_开源软件[root@localhost nagios-3.1.2]#make install-init
nagios监控服务器_开源软件[root@localhost nagios-3.1.2]#make install-commandmode
nagios监控服务器_开源软件[root@localhost nagios-3.1.2]#make install-config
(4) nagios-plugin的安装
nagios监控服务器_开源软件[root@localhost nagios-plugins-1.4.13]# ./configure --prefix=/usr/local/nagios
nagios监控服务器_开源软件[root@localhost nagios-plugins-1.4.13]# make && make install
(5) 飞信机器人的安装
    在安装飞信之前需要在/usr/lib目录下加上libACE库文件,以便使飞信能够正常使用
nagios监控服务器_开源软件[root@localhost src]#tar zxvf library_linux.tar.gz
nagios监控服务器_开源软件[root@localhost src]#mv libACE* libcrypto.so.0.9.8 libssl.so.0.9.8  /usr/lib
    好了,现在来正式安装飞信
nagios监控服务器_开源软件[root@localhost src]#tar zxvf fetion20090406003-linux.tar.gz
nagios监控服务器_开源软件[root@localhost src]#mv install /usr/local/fetion
nagios监控服务器_开源软件[root@localhost src]#chmod -R 755 /usr/local/fetion
nagios监控服务器_开源软件[root@localhost src]#chown -R nagios:nagios /usr/local/fetion
    测试飞信能否成功发送短信(发送对象需是自己飞信好友):
nagios监控服务器_开源软件[root@localhost src]# /usr/local/fetion/fetion --mobile=137*** --pwd=*** \
nagios监控服务器_开源软件> --to=136*** --msg-utf8="test"
    如果136***能成功收到137***的短信就是正常的哟,如果不能成功看日志。
3、nagios的配置
    首先讲一下,我建有host(主机),hostgroup(主机组),contact(联系人),contactgroup(联系人组),分别讲一下它们的相关情况:
host包含:TH-02,VH-178,VH-132,MH-110,MH-13
hostgroup包含:TG(别名:testgroup) , VG(别名:virtualgroup),MG(别名:maintaingroup);TG包括主机:TH-02,VG包括主机:VH-132,VH-178,MG包括主机:MH-110,MH-13
contact包含:WSP,HW,ZY
contactgroup包含:testers,virtualers,maintainers;testers包含用户:WSP,virtualers包含用户:WSP和HW,maintainers包含用户:ZY
    为了直观起见,请看下图,
nagios监控服务器_开源软件_28
    好了,有了大致模块以后,现在我们正式开始配置nagios吧
(1) host的编辑与添加
    为了灵活使用,我们直接进入/usr/local/nagios/etc/objects目录下面,
nagios监控服务器_开源软件[root@localhost src]#cd /usr/local/nagios/etc/objects/
nagios监控服务器_开源软件[root@localhost objects]# vi hosts.cfg
##########################################################################
nagios监控服务器_开源软件### Define whole host for all the machines
nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define testgroup host for the testers machine
nagios监控服务器_开源软件
nagios监控服务器_开源软件define host{
nagios监控服务器_开源软件                host_name                             TH-02
nagios监控服务器_开源软件                alias                                   testhost02
nagios监控服务器_开源软件                max_check_attempts                 5
nagios监控服务器_开源软件                contact_groups                    testers
nagios监控服务器_开源软件                address                             60.191.*.*
nagios监控服务器_开源软件                }

nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define virtualgroup host for the virtualers machine
nagios监控服务器_开源软件
nagios监控服务器_开源软件define host{
nagios监控服务器_开源软件  host_name    VH-178
nagios监控服务器_开源软件  alias      Virutalhost178
nagios监控服务器_开源软件  max_check_attempts     5    
nagios监控服务器_开源软件  contact_groups    virtualers
nagios监控服务器_开源软件  address      *.*.*.178
nagios监控服务器_开源软件  }
nagios监控服务器_开源软件
nagios监控服务器_开源软件define host{
nagios监控服务器_开源软件  host_name    VH-132
nagios监控服务器_开源软件  alias      Virtualhost132
nagios监控服务器_开源软件  max_check_attempts  5
nagios监控服务器_开源软件  contact_groups    virtualers
nagios监控服务器_开源软件  address      *.*.*.132
nagios监控服务器_开源软件  }
nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define maintaingroup host for the maintainers machine
nagios监控服务器_开源软件
nagios监控服务器_开源软件define host{
nagios监控服务器_开源软件  host_name    MH-110
nagios监控服务器_开源软件  alias      maintainhost110
nagios监控服务器_开源软件  max_check_attempts  5
nagios监控服务器_开源软件  contact_groups    maintainers
nagios监控服务器_开源软件  address      *.*.*.110
nagios监控服务器_开源软件  }
nagios监控服务器_开源软件
nagios监控服务器_开源软件define host{
nagios监控服务器_开源软件  host_name    MH-13
nagios监控服务器_开源软件  alias      maintainhost13
nagios监控服务器_开源软件  max_check_attempts  5
nagios监控服务器_开源软件  contact_groups    maintainers
nagios监控服务器_开源软件  address      *.*.*.13
nagios监控服务器_开源软件  }
nagios监控服务器_开源软件

nagios监控服务器_开源软件
nagios监控服务器_开源软件##############################################################################
nagios监控服务器_开源软件### Define all hostgroup for the whole machine
nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define testgroup
nagios监控服务器_开源软件
nagios监控服务器_开源软件define hostgroup{
nagios监控服务器_开源软件                hostgroup_name         TG
nagios监控服务器_开源软件                alias                     testgroup
nagios监控服务器_开源软件                members                 TH-02
nagios监控服务器_开源软件                }

nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define virtualgroup
nagios监控服务器_开源软件
nagios监控服务器_开源软件define hostgroup{
nagios监控服务器_开源软件  hostgroup_name  VG
nagios监控服务器_开源软件  alias    virtualgroup
nagios监控服务器_开源软件  members    VH-178,VH-132
nagios监控服务器_开源软件  }

nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define maintaingroup
nagios监控服务器_开源软件
nagios监控服务器_开源软件define hostgroup{
nagios监控服务器_开源软件  hostgroup_name  MG
nagios监控服务器_开源软件  alias    maintaingroup
nagios监控服务器_开源软件  members    MH-110,MH-13
nagios监控服务器_开源软件  }

nagios监控服务器_开源软件
nagios监控服务器_开源软件#############################################################################
nagios监控服务器_开源软件### SERVICE DEFINITIONS
nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define a service to "ping" the whole machine
nagios监控服务器_开源软件
nagios监控服务器_开源软件define service{
nagios监控服务器_开源软件                host_name            TH-02,VH-178,VH-132,MH-110
nagios监控服务器_开源软件                service_description             PING
nagios监控服务器_开源软件                is_volatile                             0    
nagios监控服务器_开源软件                check_period                         24x7
nagios监控服务器_开源软件                max_check_attempts                 1    
nagios监控服务器_开源软件                normal_check_interval             1    
nagios监控服务器_开源软件                retry_check_interval                 1    
nagios监控服务器_开源软件                notification_options                 w,u,c,r    
nagios监控服务器_开源软件                notification_interval             1    
nagios监控服务器_开源软件                notification_period                 24x7    
nagios监控服务器_开源软件                check_command   check_ping!100.0,20%!500.0,60%
                  }

nagios监控服务器_开源软件# Define a service to "HTTP" the whole machine
nagios监控服务器_开源软件
nagios监控服务器_开源软件define service{
nagios监控服务器_开源软件                host_name         H-02,VH-178,VH-132,MH-13,MH-110
                 service_description             HTTP
nagios监控服务器_开源软件                is_volatile                             0
nagios监控服务器_开源软件                check_period                         24x7
nagios监控服务器_开源软件                max_check_attempts                 1
nagios监控服务器_开源软件                normal_check_interval             1
nagios监控服务器_开源软件                retry_check_interval                 1
nagios监控服务器_开源软件                notification_options                 w,u,c,r
nagios监控服务器_开源软件                notification_interval             1
nagios监控服务器_开源软件                notification_period                 24x7
nagios监控服务器_开源软件                check_command                   check_http
nagios监控服务器_开源软件                notifications_enabled                0
nagios监控服务器_开源软件                }
    service 可以根据自己的需要加的,我这里只对HTTP与PING来作阐述的。
(2) contacts.cfg的编辑
nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件# CONTACTS.CFG - SAMPLE CONTACT/CONTACTGROUP DEFINITIONS
nagios监控服务器_开源软件#
nagios监控服务器_开源软件# Last Modified: 05-31-2007
nagios监控服务器_开源软件#
nagios监控服务器_开源软件# NOTES: This config file provides you with some example contact and contact
nagios监控服务器_开源软件#                group definitions that you can reference in host and service
nagios监控服务器_开源软件#                definitions.
nagios监控服务器_开源软件#                
nagios监控服务器_开源软件#                You don't need to keep these definitions in a separate file from your
nagios监控服务器_开源软件#                other object definitions.    This has been done just to make things
nagios监控服务器_开源软件#                easier to understand.
nagios监控服务器_开源软件#

nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件#
nagios监控服务器_开源软件# CONTACTS
nagios监控服务器_开源软件#

nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件### Define contact information for all the contacter
nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define contact information for WSP
nagios监控服务器_开源软件
nagios监控服务器_开源软件define contact{
nagios监控服务器_开源软件                contact_name         WSP
nagios监控服务器_开源软件                use                generic-contact    
nagios监控服务器_开源软件                alias                  WY-wsp
nagios监控服务器_开源软件                service_notification_commands    notify-service-by-email,service-notify-by-fei
nagios监控服务器_开源软件                host_notification_commands        notify-host-by-email,host-notify-by-fei
nagios监控服务器_开源软件                email                                        
wsp@wy.cn
nagios监控服务器_开源软件                pager                                          150***
nagios监控服务器_开源软件                }

nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define contact information for HW

nagios监控服务器_开源软件define contact{
nagios监控服务器_开源软件                contact_name           HW
nagios监控服务器_开源软件                use                generic-contact    
nagios监控服务器_开源软件                alias                    WY-hw
nagios监控服务器_开源软件                service_notification_commands   notify-service-by-email,service-notify-by-fei
nagios监控服务器_开源软件                host_notification_commands      notify-host-by-email,host-notify-by-fei
nagios监控服务器_开源软件                email                                        
hewei@wy.cn
nagios监控服务器_开源软件                pager                                           135***
nagios监控服务器_开源软件                }

nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define contact information for ZY

nagios监控服务器_开源软件define contact{
nagios监控服务器_开源软件                contact_name                 ZY
nagios监控服务器_开源软件                 use                     generic-contact    
nagios监控服务器_开源软件                alias                           WY-zy
nagios监控服务器_开源软件                service_notification_commands   notify-service-by-email,service-notify-by-fei
nagios监控服务器_开源软件                host_notification_commands       notify-host-by-email,host-notify-by-fei
nagios监控服务器_开源软件                email                                         zy@wy.cn
nagios监控服务器_开源软件                pager                                           150***
nagios监控服务器_开源软件                }

nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件#
nagios监控服务器_开源软件# CONTACT GROUPS
nagios监控服务器_开源软件#

nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件###############################################################################
nagios监控服务器_开源软件### Define contact group for all ther whole contacter
nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define testers contact group
nagios监控服务器_开源软件
nagios监控服务器_开源软件define contactgroup{
nagios监控服务器_开源软件                contactgroup_name              testers
nagios监控服务器_开源软件                alias                            testhost contacters
nagios监控服务器_开源软件                members                             WSP
nagios监控服务器_开源软件                }
nagios监控服务器_开源软件

nagios监控服务器_开源软件# Define virtualers contact group
nagios监控服务器_开源软件
nagios监控服务器_开源软件define contactgroup{
nagios监控服务器_开源软件                contactgroup_name             virtualers
nagios监控服务器_开源软件                alias                            virtualhost contacters
nagios监控服务器_开源软件                members                            WSP,HW
nagios监控服务器_开源软件                }

nagios监控服务器_开源软件
nagios监控服务器_开源软件
nagios监控服务器_开源软件# Define maintainers contact group
nagios监控服务器_开源软件
nagios监控服务器_开源软件define contactgroup{
nagios监控服务器_开源软件                contactgroup_name             maintainers
nagios监控服务器_开源软件                alias                            maintainhost contacters
nagios监控服务器_开源软件                members                                ZY
nagios监控服务器_开源软件                }

nagios监控服务器_开源软件
(3) commands.cfg的编辑
    为了支持飞信发短信的功能需要在此文件中添加飞信命令,以促使信息的发送,代码如下:
nagios监控服务器_开源软件# 'notify-host-by-fei' command definition

nagios监控服务器_开源软件define command {
nagios监控服务器_开源软件             command_name            host-notify-by-fei ;
nagios监控服务器_开源软件             command_line            /usr/local/fetion/fetion --mobile=137*** --pwd=*** --to=$CONTACTPAGER$ --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$
nagios监控服务器_开源软件             }

nagios监控服务器_开源软件
nagios监控服务器_开源软件# 'notify-service-by-fei' command definition

nagios监控服务器_开源软件define command {
nagios监控服务器_开源软件             command_name         service-notify-by-fei
nagios监控服务器_开源软件             command_line         /usr/local/fetion/fetion --mobile=137*** --pwd=*** --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$
nagios监控服务器_开源软件             }
(4) 编辑nagios.cfg
nagios监控服务器_开源软件为了不监控本机,现把localhost注释掉,找到此行,并且加以注释:
nagios监控服务器_开源软件# cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
nagios监控服务器_开源软件为了使刚才编辑的文件生效,需加入一行:
nagios监控服务器_开源软件cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
(5) 编辑cgi.cfg
    为了保证权限能正常访问nagios的web页面,需把这些行的值改掉:
nagios监控服务器_开源软件authorized_for_system_information=*
nagios监控服务器_开源软件authorized_for_configuration_information=*
nagios监控服务器_开源软件authorized_for_system_commands=nagios
nagios监控服务器_开源软件authorized_for_all_services=*
nagios监控服务器_开源软件authorized_for_all_hosts=*
nagios监控服务器_开源软件authorized_for_all_service_commands=*
nagios监控服务器_开源软件authorized_for_all_host_commands=*
nagios监控服务器_开源软件*号在此表示所有用户,也可以改成相关用户,不过必须逐一添加。
    服务器端的配置基本上大致如此了。
4、启动nagios与apache服务
(1) nagios自启动
nagios监控服务器_开源软件[root@localhost objects]#service nagios restart
nagios监控服务器_开源软件Running configuration check...done.
nagios监控服务器_开源软件Stopping nagios: done.
nagios监控服务器_开源软件Starting nagios: done.
nagios监控服务器_开源软件[root@localhost objects]#chkconfig nagios on
nagios监控服务器_开源软件[root@localhost objects]#
chkconfig --list|grep nagios
nagios监控服务器_开源软件nagios     0:关闭   1:关闭   2:启用   3:启用   4:启用   5:启用   6:关闭
(2) apache的启动
nagios监控服务器_开源软件[root@localhost ~]#export PATH=$PATH:/usr/local/apache/bin
nagios监控服务器_开源软件[root@localhost ~]# apachectl -k start
nagios监控服务器_开源软件httpd (pid 3108) already running
注:为了让apache可以自启动,可以加入到/etc/rc.local之中。
5、测试与浏览
    在启动nagios服务之前,我们可以先测试一下是否配置有没有错误,或者你启动的时候出现错误也可以用下述命令进行测试
nagios监控服务器_开源软件[root@localhost ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg    
nagios监控服务器_开源软件Nagios 3.1.2
nagios监控服务器_开源软件Copyright (c) 2009 Nagios Core Development Team and Community Contributors
nagios监控服务器_开源软件Copyright (c) 1999-2009 Ethan Galstad
nagios监控服务器_开源软件Last Modified: 06-23-2009
nagios监控服务器_开源软件License: GPL
nagios监控服务器_开源软件Website: http://www.nagios.org
nagios监控服务器_开源软件Reading configuration data...
nagios监控服务器_开源软件     Read main config file okay...
nagios监控服务器_开源软件Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
nagios监控服务器_开源软件Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
nagios监控服务器_开源软件Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
nagios监控服务器_开源软件Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
nagios监控服务器_开源软件Processing object config file '/usr/local/nagios/etc/objects/hosts.cfg'...
nagios监控服务器_开源软件     Read object config files okay...
nagios监控服务器_开源软件Running pre-flight check on configuration data...
nagios监控服务器_开源软件Checking services...
nagios监控服务器_开源软件                Checked 9 services.
nagios监控服务器_开源软件Checking hosts...
nagios监控服务器_开源软件                Checked 5 hosts.
nagios监控服务器_开源软件Checking host groups...
nagios监控服务器_开源软件                Checked 3 host groups.
nagios监控服务器_开源软件Checking service groups...
nagios监控服务器_开源软件                Checked 0 service groups.
nagios监控服务器_开源软件Checking contacts...
nagios监控服务器_开源软件                Checked 3 contacts.
nagios监控服务器_开源软件Checking contact groups...
nagios监控服务器_开源软件                Checked 3 contact groups.
nagios监控服务器_开源软件Checking service escalations...
nagios监控服务器_开源软件                Checked 0 service escalations.
nagios监控服务器_开源软件Checking service dependencies...
nagios监控服务器_开源软件                Checked 0 service dependencies.
nagios监控服务器_开源软件Checking host escalations...
nagios监控服务器_开源软件                Checked 0 host escalations.
nagios监控服务器_开源软件Checking host dependencies...
nagios监控服务器_开源软件                Checked 0 host dependencies.
nagios监控服务器_开源软件Checking commands...
nagios监控服务器_开源软件                Checked 26 commands.
nagios监控服务器_开源软件Checking time periods...
nagios监控服务器_开源软件                Checked 5 time periods.
nagios监控服务器_开源软件Checking for circular paths between hosts...
nagios监控服务器_开源软件Checking for circular host and service dependencies...
nagios监控服务器_开源软件Checking global event handlers...
nagios监控服务器_开源软件Checking obsessive compulsive processor commands...
nagios监控服务器_开源软件Checking misc settings...
nagios监控服务器_开源软件Total Warnings: 0
nagios监控服务器_开源软件Total Errors:     0
    呵呵,没有错误,可能您在配置之前或多或少会出现问题的,根据相关错误提示,逐一排查,相信您定会成功的。
    现在我们打开nagios的web页面,输入:http://***.com/nagios样例
    先看map页面,大致页面如下
nagios监控服务器_监控_319
    再看hosts相关链接页面:
nagios监控服务器_服务器_320
    最后,我们再看一下hostgroups页面:
nagios监控服务器_监控_321
二、客户端的配置:
1、需求软件的下载:
nagios插件程序:
nrpe软件:
2、软件的安装
(1) nagios插件的安装:
    首先在安装前建立nagios用户,命令如下:
nagios监控服务器_开源软件[root@yibaner src]# useradd nagios -s /sbin/nologin -M
nagios监控服务器_开源软件[root@yibaner src]# tar zxvf nagios-plugins-1.4.13.tar.gz
nagios监控服务器_开源软件[root@yibaner src]# cd nagios-plugins-1.4.13
nagios监控服务器_开源软件[root@yibaner nagios-plugins-1.4.13]# ./configure --prefix=/usr/local/nagios
nagios监控服务器_开源软件[root@yibaner nagios-plugins-1.4.13]# make && make install
nagios监控服务器_开源软件[root@yibaner nagios-plugins-1.4.13]# chown -R nagios.nagios /usr/local/nagios/
(2) nrpe的程序的安装:
nagios监控服务器_开源软件[root@yibaner src]# tar zxvf nrpe-2.12.tar.gz
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# cd nrpe-2.12
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# ./configure
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# make all
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# make install-plugin
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# make install-daemon
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# make install-daemon-config
(3) 修改nrpe.cfg配置文件:
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# vi /usr/local/nagios/etc/nrpe.cfg
nagios监控服务器_开源软件将server_address的值修改为本机的IP地址:
nagios监控服务器_开源软件server_address=*.*.*.110
nagios监控服务器_开源软件将allowed_hosts的值修改为远程监控服务器的IP地址:
nagios监控服务器_开源软件allowed_hosts=*.*.*.27
(4) 运行nrpe服务:
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
(5) 查看nrpe运行情况:
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]# netstat -nap | grep nrpe
tcp   0    0    *.*.*.110:5666    0.0.0.0:*   LISTEN     3538/nrpe    
nagios监控服务器_开源软件从上述情况来看,nrpe成功运行,并且占用了5666端口
(6) 设置nrpe自启动:
nagios监控服务器_开源软件[root@yibaner nrpe-2.12]#vi /etc/rc.local
nagios监控服务器_开源软件在其中加中此行:
nagios监控服务器_开源软件/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
(7) 在监控服务器端测试被监控服务器是否正常运行
nagios监控服务器_开源软件[root@localhost src]# telnet *.*.*.110 5666

    测试如果一切正常,整个配置过程全部告一段落,只需到监控服务器中设置对被监控服务器的所需服务的监控即可。

注:It appears as though you do not have permission to view information for any of the hosts you requested...
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
and check the authorization options in your CGI configuration file.

出现此错误 ,可能是没有编辑 cgi.cfg,  或者 不按照以上写的来编辑cgi.cfg配置文件的话,直接修改里面的一个参数:
use_authentication=1  默认为1,改为0即可
我想增加一个用户,要怎么设置? 前面都是按照上面写的设置的

可以试一下这个命令htpasswd /usr/local/nagios/etc/htpasswd.users <username>

第一步:
/usr/local/apache/bin/htpasswd /usr/local/nagios/etc/htpasswd.users 用户名称
第二步:
在httpd.conf中写成下面这样:
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.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>