本文转自:http://www.yylog.org/?p=4275
Nagios安装
安装依赖软件包
[root@localhost tmp]#yum install gcc glibc glibc-common gd gd-devel install libxml2 libxml2-devel
创建nagios用户和组
[root@localhost tmp]# groupadd nagios
[root@localhost tmp]# useradd -g nagios nagios -s /sbin/nologin
创建nagios安装目录及权限设定
[root@localhost tmp]# mkdir /usr/local/nagios
[root@localhost tmp]# chown -R nagios.nagios /usr/local/nagios
[root@localhost tmp]# tar -zxvf nagios-3.2.3.tar.gz
[root@localhost tmp]# cd nagios-3.2.3
编译nagios安装包
依次编译安装二进制运行程序、初始化脚本、配置文件样本并设置运行目录权限
[root@localhost nagios-3.2.3]# ./configure –prefix=/usr/local/nagios
[root@localhost nagios-3.2.3]# make all
[root@localhost nagios-3.2.3]# make install
[root@localhost nagios-3.2.3]# make install-init
[root@localhost nagios-3.2.3]# make install-commandmode
设置开机服务自动启动
[root@localhost nagios-3.2.3]# chkconfig –add nagios
[root@localhost nagios-3.2.3]# chkconfig nagios on
[root@localhost nagios-3.2.3]# chkconfig –list nagios
nagios 0:off 1:off 2:on 3:on 4:on 5:on 6:off
安装nagios插件
[root@localhost tmp]# tar -zxvf nagios-plugins-1.4.14.tar.gz
[root@localhost tmp]# cd nagios-plugins-1.4.14
[root@localhost nagios-plugins-1.4.14]# ./configure –prefix=/usr/local/nagios
[root@localhost nagios-plugins-1.4.14]# make
[root@localhost nagios-plugins-1.4.14]# make install
安装Nagios汉化插件
[root@localhost tmp]# tar jxvf nagios-cn-3.2.3.tar.bz2
[root@localhost tmp]# cd nagios-cn-3.2.3
[root@localhost nagios-cn-3.2.3]# ./configure
[root@localhost nagios-cn-3.2.3]# make all
[root@localhost nagios-cn-3.2.3]# make install
安装Apache
[root@localhost tmp]# tar -zxvf httpd-2.0.64.tar.gz
[root@localhost tmp]# cd httpd-2.0.64
[root@localhost httpd-2.0.64]# ./configure –prefix=/usr/local/apache –enable-so
[root@localhost httpd-2.0.64]# make
[root@localhost httpd-2.0.64]# make install
安装PHP
[root@localhost tmp]#yum install libpng libpng-devel libjpeg libjpeg-devel freetype freetype-devel gdgd-devel flex
[root@localhost tmp]# tar -jxvf php-5.1.2.tar.bz2
[root@localhost tmp]# cd php-5.1.2
[root@localhost php-5.1.2]# ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –with-gd –with-freetype-dir –with-png-dir –with-zlib
[root@localhost php-5.1.2]# make
[root@localhost php-5.1.2]# make install
[root@localhost /]# vi /usr/local/apache/conf/httpd.conf
#User nbody修改为
User nagios
Group nagios
DirectoryIndex index.html index.php
#增加如下内容
AddType application/x-httpd-php .php
#配置Nagios的Web用户验证访问
#setting for nagios
ScriptAlias /nagios/cgi-bin “/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
Alias /nagios “/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
创建htpasswd用户验证文件,用户访问http://ip/nagios时输入用户名及密码。
[root@localhost /]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios
New password:
Re-type new password:
Adding password for user nagios
启动apache服务
[root@localhost /]# /usr/local/apache/bin/apachectl start
[root@localhost /]# ps -ef|grep apa
启动nagios服务
[root@localhost /]# service nagios restart
此时可直接访问Nagios的web监控页面了,输入htpasswd用户名及口令即可。
Nagios中文界面如图:
本文转自:http://www.yylog.org/?p=4275