nagios 部署安装 全过程

 nagios 部署安装php

经过web 查看Nagios 产生的结果是依赖于php 的,因此须要安装apache+php
一、 安装apache
tar -zxf httpd-2.0.52.tar.gz
cd httpd-2.0.52
./configure –prefix=/usr/local/apache2 –enable-so
Make && make install
/usr/local/apache2/bin/apachectl start
若是这时看到80 端口打开了或者能访问apache 的默认页面了,说明安装成功!
二、 php 安装
安装php 前须要先安装php 依赖的支持库们
1)  安装zlib-1.2.5.tar.gz
tar -zxf zlib-1.2.5.tar.gz
cd zlib-1.2.5
./configure --prefix=/usr/local/zlib
make && make install
2)  安装libpng-1.4.9.tar.gz
Tar –zxf libpng-1.4.9.tar.gz
cd libpng-1.4.9

cp scripts/makefile.linux makefile(注意,这个软件的makefile不是configure生成的,是直接从scripts里复制出来的)html

make && make install
3 )安装freetype-2.4.8.tar.gz
tar -zxf freetype-2.4.8.tar.gz
cd freetype-2.4.8
./configure --prefix=/usr/local/freetype
make && make install
4)  安装jpegsrc.v8d.tar.gz
tar -zxf jpegsrc.v8d.tar.gz
cd jpeg-8d/

mkdir /usr/local/libjpeg
mkdir /usr/local/libjpeg/include
mkdir /usr/local/libjpeg/bin
mkdir /usr/local/libjpeg/lib
mkdir /usr/local/libjpeg/man
mkdir /usr/local/libjpeg/man/man1
linux

./configure --prefix=/usr/local/libjpeg --enable-shared --enable-staticios

make && make install

(注意,这里configure必定要带--enable-shared参数,否则,不会生成共享库)web

5) 安装 libxml2-2.6.29.tar.gzapache

tar -zxf libxml2-2.6.29.tar.gz
cd libxml2-2.6.29
./configure –prefix=/usr/local/libxml2
make && make install
6 )安装fontconfig-2.8.0.tar.gz
tar -zxf fontconfig-2.8.0.tar.gz
cd fontconfig-2.8.0
./configure  --prefix=/usr/local/fontconfig \
--with-freetype-config=/usr/local/freetype/bin/freetype-config
make && make install

若是./configure 报如下错误,是由于环境变量没配好的缘由vim

checking for LIBXML2... configure: error: Package requirements (libxml-2.0 >= 2.6) were not met:
No package 'libxml-2.0' found
服务器

解决办法:肯定 /usr/local/libxml2/lib/pkgconfig 目录下有 libxml-2.0.pcapp

执行 export PKG_CONFIG_PATH=/usr/local/libxml2/lib/pkgconfig:$PKG_CONFIG_PATHsocket

再次执行./configure  –prefix……就好了

7) 安装 gd-2.0.33.tar.gz

tar -zxf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure  --with-fontconfig=/usr/local/fontconfig \
 --with-png  --with-freetype=/usr/local/freetype  --with-jpeg=/usr/local/libjpeg
make && make install
8)  安装libart_lgpl-2.3.21.tar.gz
tar -zxf libart_lgpl-2.3.21.tar.gz
cd libart_lgpl-2.3.21

./configure --prefix=/usr/local/libart-2.0

make && make install
9)  安装php 的支持库libiconv-1.13.1.tar.gz
tar -zxf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1

./configure --prefix=/usr/local --enable-shared

make && make install
10)  安装php-5.4.0.tar.gz
tar -zxf php-5.4.0.tar.gz
cd php-5.4.0
./configure  --prefix=/usr/local/php \

 --with-apxs2=/usr/local/apache2/bin/apxs \

--with-gd \
--with-pcre-regex \
--enable-mbstring=all \
--with-libmbfl \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-freetype-dir=/usr/local/freetype \
--with-jpeg-dir=/usr/local/libjpeg \
--with-png-dir=/usr \
--with-zlib-dir=/usr/local/zlib \
--enable-xml \
--enable-sockets \
--with-libxml-dir=/usr/local/libxml2
make ZEND_EXTRA_LIBS='-liconv'
make install
三、 修改apache 配置文件使之能够解析php 语言
vim /usr/local/apache2/conf/httpd.conf

添加以下2行:(添在AddType *** 以后)
AddType application/x-httpd-php .php .phtml .php3 .php4 .php5
AddType application/x-httpd-php-source .phps

而后肯定模块libphp5.so已经被load

LoadModule php5_module        modules/libphp5.so
添加apache 索引文件格式
DirectoryIndex index.php index.html index.html.var

添加测试文件,测试php是否安装成功

vim /usr/local/apache2/htdocs/index.php
写入一下内容
<?php
phpinfo();
?>
添加apache 运行用户, 添加nagios 运行用户, 并将nagios 设为apache 的辅组
useradd apache -s /sbin/nologin
useradd nagios -s /sbin/nologin
usermod -G nagios apache
修改apache 的运行用户
vim /usr/local/apache2/conf/httpd.conf
User apache
重启apache ,使修改生效
/usr/local/apache2/bin/apachectl restart
直接经过web 访问该IP ,看到一下界面,说明配置成功

 

四、 安装nagios 主程序
tar -zxf nagios-3.2.3.tar.gz
cd nagios-3.2.3
./configure  --prefix=/usr/local/nagios \
--with-nagios-user=nagios \
--with-nagios-group=nagios \
--with-httpd-conf=/usr/local/apache2/conf
而后安装提示,依次执行
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf

make install-exfoliation/ make install-classicui (3.3.1里有此选项,2选一)

修改apache 的配置文件,使之包含nagios 生成的配置文件
vim /usr/local/apache2/conf/httpd.conf
添加这句话
Include conf/nagios.conf
重启apache
/usr/local/apache2/bin/apachectl restart
 
五、 修改nagios 配置文件

建立nagios web页面及cgi的认证文件

/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users  username

输入密码和确认密码就好了
再修改nagios cgi.cfg 文件,使刚才建立的用户有权限访问nagios
vim /usr/local/nagios/etc/cgi.cfg

在全部的nagiosadmin后面添加,username(上一步建立的用户名)

:1,$s/nagiosadmin/nagiosadmin,username/g
六、 安装nagios 插件
tar -zxf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/usr/local/nagios
make && make install
启动nagios
/etc/init.d/nagios start
访问 http://IP/nagios ,若是看到如下页面,则说明nagios 启动成功

 

若是未启动成功,请查看nagios 日志
tail -f /usr/local/nagios/var/nagios.log
七、 被监控端安装过程

安装前须要添加nagios用户

Useradd nagios –s /sbin/nologin

被监控段须要安装nrpenagios-plugins

nagios-plugins 安装过程同上
nrpe 安装
./configure

make all
make install-plugin
make install-daemon
make install-daemon-config

make install-xinetd

修改/etc/service,在最后添加上nrpe的端口

vim /etc/services
nrpe            5666/tcp                        #nrpe
修改/usr/local/nagios/etc/nrpe.cfg ,在容许主机处添加nagios 服务器的IP
vim /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.12.137
修改/etc/xinetd.d/nrpe, 经过xinet 管理nrpe, only_from 处添加nagios IP
vim /etc/xinetd.d/nrpe
only_from       = 192.168.12.137
而后重启xinet ,并查看端口5666 是否打开
将被监控端/usr/local/nagios/libexec/ 里面的check_nrpe 复制到nagios 服务器/usr/local/nagios/libexec/ 里面
nagios 执行check_nrpe, 测试nrpe 是否能连通。

/usr/local/nagios/libexec/check_nrpe -H 192.168.12.138(被监控端IP

若是返回 NRPE v2.13 ,则说明,nrpe 安装成功 
 
 
 map功能显示不出来:

编辑/etc/ld.so.conf,文件中中加一行/usr/local/lib,运行ldconfig,重启apache。就可看到map功能

相关文章
相关标签/搜索