一.安装Apache服务:
[iyunv@KCentOS5C ~]# yum install httpd*
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
httpd i386 2.2.3-6.el5.centos.1 base 1.1 M
httpd-devel i386 2.2.3-6.el5.centos.1 base 145 k
httpd-manual i386 2.2.3-6.el5.centos.1 base 830 k
Installing for dependencies:
apr-devel i386 1.2.7-11 base 237 k
apr-util-devel i386 1.2.7-6 base 54 k
Transaction Summary
=============================================================================
将Apache服务设定为系统启动服务
[iyunv@KCentOS5C ~]# chkconfig httpd on
二.安装Nagios主程序:
1.解压缩Nagios主程序源代码包
[iyunv@KCentOS5C ~]# tar -zxvf nagios-2.9.tar.gz
2.进入Nagios主程序包的解压目录
[iyunv@KCentOS5C ~]# cd nagios-2.9
3.预配置Nagios主程序的环境以及指定安装路径
[iyunv@KCentOS5C nagios-2.9]# ./configure --prefix=/usr/local/nagios
预配置成功后将返回配置环境信息
----------------------------------------------------
*** Configuration summary for nagios 2.9 04-10-2007 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Lock file: ${prefix}/var/nagios.lock
Init directory: /etc/rc.d/init.d
Host OS: linux-gnu
Web Interface Options:
------------------------
HTML URL:http://localhost/nagios/
CGI URL:http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
请注意看最后的提示,如果对以上反馈信息接受的话,则需要继续执行“make all”命令来编译主程序以及CGI。
-----------------------------------------------------
4.编译Nagios主程序
[iyunv@KCentOS5C nagios-2.9]# make all
Nagios主程序编译成功后将返回信息
-----------------------------------------------------
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
如果在编译当中没有发生错误的话,那么可以照以下这些命令继续操作。
make install
- This installs the main program, CGIs, and HTML files
执行“make install”命令来对主程序,CGI以及HTML网页进行安装。
make install-init
- This installs the init script in /etc/rc.d/init.d
执行“install-init”命令来在/etc/rc.d/init.d/目录中安装启动脚本。
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
执行“install-commandmode”命令来安装和配置外部命令对Nagios主路径操作的权限。(这里所谓的外部命令主要是指Apache服务通过CGI来对Nagios的进行的操作。用户将通过Web以执行CGI程序脚本的方式来对Nagios的检测结果进行读取和调用。)
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
执行“make install-config”命令将会在/usr/local/etc/这个Nagios编译安装的主配置路径下安装示例配置模板,这将对于之后的配置制定帮助很大。
*** Support Notes *******************************************
这些关于支持的信息就不再详细讲了
If you have questions about configuring or running Nagios,
please make sure that you:
- Look at the sample config files
- Read the HTML documentation
- Read the FAQs online at http://www.nagios.org/faqs
before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you. This might include:
- What version of Nagios you are using
- What version of the plugins you are using
- Relevant snippets from your config files
- Relevant error messages from the Nagios log file
For more information on obtaining support for Nagios, visit:
http://www.nagios.org/support/
*************************************************************
Enjoy.
-----------------------------------------------------
5.安装Nagios主程序、CGI以及网页
[iyunv@KCentOS5C nagios-2.9]# make install
安装完Nagios主程序、CGI和网页的之后将提示安装成功信息以及剩余可操作的步骤
-----------------------------------------------------
*** Main program, CGIs and HTML files installed ***
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install-init
- This installs the init script in /etc/rc.d/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
-----------------------------------------------------
6.安装Nagios的系统启动脚本
[iyunv@KCentOS5C nagios-2.9]# make install-init
安装完Nagios的系统启动脚本之后将提示脚本安装成功信息以及剩余可操作的步骤
-----------------------------------------------------
*** Init script installed ***
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
-----------------------------------------------------
8.将Nagios服务加入到系统启动服务当中去
[iyunv@KCentOS5C ~]# chkconfig nagios on
9.安装和配置外部命令对Nagios主路径的操作权限
[iyunv@KCentOS5C nagios-2.9]# make install-commandmode
安装配置外操作权限后将提示配置成功信息以及剩余可操作步骤
-----------------------------------------------------
*** External command directory configured ***
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install-config
- This installs *SAMPLE* config files in /usr/local/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
-----------------------------------------------------
11.安装Nagios的配置模板
[iyunv@KCentOS5C nagios-2.9]# make install-config
安装完毕Nagios的配置模板后将反馈安装成功的提示信息。
-----------------------------------------------------
*** Sample config file installed ***
Remember, these are *SAMPLE* config files. You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.
If you have questions about configuring Nagios properly, please:
- Look at the sample config files
- Read the HTML documentation
- Read the FAQs online at http://www.nagios.org/faqs
*BEFORE* you post a question to one of the mailing lists.
-----------------------------------------------------
三.安装Nagios-plugins插件程序:
1.解压缩Nagios-plugins插件源代码包
[iyunv@KCentOS5C ~]# tar -zxvf nagios-plugins-1.4.10.tar.gz
2.进入Nagios-plugins插件包目录
[iyunv@KCentOS5C ~]# cd nagios-plugins-1.4.10
2.配置Apache服务的主配置文件
[iyunv@KCentOS5C ~]# vi /etc/httpd/conf/httpd.conf
这里主要改动以下这些参数:
-----------------------------------------------------
ServerName *:80
配置Apache的服务器名,如果有域名的话请填写正确的服务器名。
Include conf.d/*.conf
确认Apache扩展配置文件的存放路径。
-----------------------------------------------------
3.察看Nagios网页配置模板文件
[iyunv@KCentOS5C ~]# less nagios-2.9/sample-config/httpd.conf
-----------------------------------------------------
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
# Last Modified: 11-26-2005
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file. Customize the paths, etc. as
# needed to fit your system.
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
设定了Nagios的CGI执行目录对应的系统路径。
<Directory "/usr/local/nagios/sbin">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
这里指定了访问用户帐户库文件。
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
设定了Nagios的网页URL对应的系统路径。
<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
这里指定了访问用户帐户库文件
Require valid-user
</Directory>
-----------------------------------------------------
基本上这个文件可以直接使用。根据这个配置文件中指定的AuthUserFile项,它指定的是通过Apache访问Nagios的合法用户的帐户名单库文件,需要使用htpasswd命令对这个名单库进行用户的添加。而默认安装环境下在/usr/local/nagios/etc/目录下是没有htpasswd.user这个文件的,所以需要手动添加。请特别注意,用root身份建立的htpasswd.user文件的权限问题,应该在建立该文件完毕后立即更改为nagios用户nagios组的所有权,并且要增加Nagios同组用户读写权限。
-m Force MD5 encryption of the password.
添加一个MD5口令加密的新用户。
-d Force CRYPT encryption of the password (default).
-p Do not encrypt the password (plaintext).
添加一个口令不加密的新用户。
-s Force SHA encryption of the password.
添加一个SHA口令加密的新用户。
-b Use the password from the command line rather than prompting for it.
-D Delete the specified user.
删除一个指定的用户
On Windows, NetWare and TPF systems the '-m' flag is used by default.
在Windows、NetWare以及TPF这些操作系统中“-m”参数(启用MD5对口令加密)是默认使用的
On all other systems, the '-p' flag will probably not work.
在其他的所有操作系统中“-p”(不对口令启用加密)参数将可能会引起失败。
-------------------------------------------------------------