分类: 系统运维
2011-12-05 11:40:23
我的安装步骤
1、 所需软件
被监控端需要安装 nagios-plugins和nrpe
httpd-2.2.21.tar
php-5.3.8.tar
nagios-3.2.3.tar
nrpe-2.12.tar.gz
nagios-plugins-1.4.15.tar.gz
2、nagios安装
#tar zxvf nagios-3.2.3.tar
#cd nagios-3.23
#./configure
–prefix=/usr/local/nagios
#make all
#make install all
2.2、nagios-plugins的安装
#tar –xvzf nagios-plugins-1.4.15.tar
#cd nagios-plugins-1.4.15
#./configure --prefix=/usr/local/nagios
#make all
#make install all
安装完成以后在/usr/local/nagios-plugins会产生一个libexec的目录,将该目录全部移动到/usr/local/nagios目录下
3、Nrpe安装
#tar –zxvf nrpe-2.12.tar.gz
#cd nrpe-2.12
#./configure
--prefix=/usr/local/nagios
#Make all
#Make install al
启动nrpe,端口为5666
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d
4、appache安装
#Tar –zxvf httpd-2.2.21.tar
#Cd httpd-2.2.21
#./configure
--prefix=/usr/local/apache2
#Make all
#Make install all
在/etc/rc.conf上加上
apache_enable=”yes”
accf_data_load="YES"
accf_http_load="YES"
apache22_http_accept_enable="YES"
5、php的安装:
#tar –zxvf php-5.3.8.tar
#cd php-5.3.8
#./configure
--prefix=/usr/local/php_5.2.17
--with-apxs2=/usr/local/apache2/bin/apxs
--with-mysql=/usr/var/db/mysql # 有安装mysql可以加上
-with-config-file-path=/usr/local/bin
#make all
#make install all
4、Nagios的设定:
a、配置apache
DirectoryIndex index.html index.php
LoadModule php5_module modules/libphp5.so 加载PHP模块
ServerAdmin localhost
ServerName localhost:80(localhost可以改成你的网站主页地址,端口自然也可以改)
AddType application/x-httpd-php .php 加上这句将php后缀的给php解析
###nagios
ScriptAlias /nagios/cgi-bin "/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
Require valid-user
Alias /nagios "/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
Require valid-user
配置完成后先尝试能不能解析html确保apache能够正常工作后在尝试解析php
b、设置访问权限
在/usr/local/nagios/share目录下
[]#/usr/local/apache/bin/htpasswd –c /usr/local/nagios/etc/htpasswd nagios
这个apache目录根据安装目录的不同而不同,主要所以用.htpasswd这个命令生成用户名和密码
c、设置nagios
修改cgi.cfg 改use_authentication=1为use_authentication=0,即不用验证.不然有一些页面不会显示。
建立所有的cfg文件
然后检查配置文件是否出错
/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
出现Total Warnings: 0
Total Errors: 0
为正常
出错的话,就是.cfg文件有问题 根据错误提示 一个个修正
3.5、启动后台进程
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
/usr/local/etc/rc.d/nagios start #如果启动没反应,而且想重启的话就先kill掉
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
/usr/local/apache2/bin/apachectl -k start
看是否有错误再一个一个修正
(如果有些页面看不到的话.可以在cgi.cfg文件中
把带有authorized的选项前的#号去掉即可)
这些配置完以后,基本的nagios配置完成。
开机启动nagios
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg