成功源于积累----波爸

思想决定高度,行动决定成败!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
[root@cacti-qmail soft]# tar -zxvf nagios-3.2.1.tar.gz
[root@cacti-qmail soft]#cd nagios-3.2.1
[root@cacti-qmail nagios-3.2.1]# ./configure --prefix=/usr/local/nagios
[root@cacti-qmail nagios-3.2.1]#make all
输入make all 得到下面具体信息
==============================================================
*** 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
使用make install-init在/etc/rc.d/init.d安装启动脚本
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
使用make install-commandmode来配置目录权限
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-commandmode来安装示例配置文件,安装的路径是/usr/local/nagios/etc
make install-webconf
- This installs the Apache config file for the Nagios
web interface
使用make install-webconf来安装apache的配置文件
=================================================================
make install在安装这个动作之前要增加一个nagios用户,并修改它的权限,不然会出现以下错误
=================================================================
cd ./base && make install
make[1]: Entering directory `/home/yahoon/nagios/nagios-2.9/base'
make install-basic
make[2]: Entering directory `/home/yahoon/nagios/nagios-2.9/base'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
/usr/bin/install: invalid user `nagios' 非法用户nagios
make[2]: *** [install-basic] Error 1
make[2]: Leaving directory `/home/yahoon/nagios/nagios-2.9/base'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/home/yahoon/nagios/nagios-2.9/base'
make: *** [install] Error 2
=====================================================================
[root@cacti-qmail nagios-3.2.1]# useradd nagios
[root@cacti-qmail nagios-3.2.1]#mkdir /usr/local/nagios
[root@cacti-qmail nagios-3.2.1]#chown nagios.nagios /usr/local/nagios
[root@cacti-qmail nagios-3.2.1]#make all
[root@cacti-qmail nagios-3.2.1]#make install; make install-init;make install-commandmode;make install-config;make install-webconf
验证程序是否被正确安装
切换目录到安装路径(这里是/usr/local/nagios),看是否存在 etc、bin、 sbin、 share、 var这五个目录,如果存在则可以表明程序被正确的安装到系统了。后表是五个目录功能的简要说明:
bin Nagios执行程序所在目录,nagios文件即为主程序
etc Nagios配置文件位置,初始安装完后,只有几个*.cfg-sample文件
sbin Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录
Share Nagios网页文件所在的目录
Var Nagios日志文件、spid 等文件所在的目录
修改nagios页面文件
[root@cacti-qmail nagios-3.2.1]# more /etc/httpd/conf/nagios.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"
<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"
<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>
基本上这个文件可以直接使用,所以直接复制过去
[root@cacti-qmail nagios-3.2.1]# cp /etc/httpd/conf/nagios.conf /var/www/html/
生成nagios页面访问账号
根据这个配置文件中指定的AuthUserFile项,它指定的是通过Apache访问Nagios的合法用户的帐户名单库文件,需要使用 htpasswd命令对这个名单库进行用户的添加。而默认安装环境下在/usr/local/nagios/etc/目录下是没有 htpasswd.uses这个文件的,所以需要手动添加。请特别注意,用root身份建立的htpasswd.user文件的权限问题,应该在建立该文 件完毕后立即更改为nagios用户nagios组的所有权
[root@cacti-qmail nagios-3.2.1]# touch /usr/local/nagios/etc/htpasswd.users
建立Nagios的网页访问用户帐户文件(这里必须要与Nagios网页配置文件当中AuthUserFile指定的路径文件名一致)
[root@cacti-qmail nagios-3.2.1]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users
viong
New password:
Re-type new password:
Adding password for user viong
[root@cacti-qmail nagios-3.2.1]# cat /usr/local/nagios/etc/htpasswd.user
viong:HbfEis6w0gKqI
修改nagios主配置文件
[root@cacti-qmail nagios-3.2.1]# vi /usr/local/nagios/etc/nagios.cfg
log_file=/usr/local/nagios/var/nagios.log( 默认无nagios.log文件,需要手动创建)
command_check_interval=15s
#command_check_interval=-1
设定命令检查的时间间隔,将原来值-1的项注释掉,启用原来备用值为15s(15秒)。这项的时间间隔值请按实际需求情况设定。
[root@cacti-qmail nagios-3.2.1]# touch /usr/local/nagios/var/nagios.log
[root@cacti-qmail nagios-3.2.1]# chown nagios.nagios /usr/local/nagios/var/nagios.log
NagiosCGI配置文件
[root@cacti-qmail nagios-3.2.1]# vi /usr/local/nagios/etc/cgi.cfg
use_authentication=1 (默认是启动身份验证)
设定启用身份验证
authorized_for_system_information=viong
设定系统信息的授权用户
authorized_for_configuration_information=viong
设定配置信息的授权用户
authorized_for_system_commands=viong
设定系统命令的授权用户
authorized_for_all_services=viong
设定全部监测服务的授权用户。
authorized_for_all_hosts=viong
设定全部被监测主机的授权用户
authorized_for_all_service_commands=viong
设定全部监测服务命令的授权用
authorized_for_all_host_commands=viong
设定全部主机命令的授权用户
测试nagios是否成功
设置nagios为开机启动
[root@cacti-qmailnagios-plugins-1.4.14]#chkconfig nagios on
[root@cacti-qmailnagios-plugins-1.4.14]# service nagios start
测试nagios是否成功启动
在IE输入 http://192.168.15.73/nagios/ 跳出以下窗口
posted on 2012-09-20 16:37  沙场醉客  阅读(3049)  评论(0编辑  收藏  举报