nagios+NRPE+pnp4nagios+ndoutils+mysql监控项目部署文档

项目规划、文档整理:张凌希

 

 

一、安装环境

监控中心:Red Hat Enterprise Linux Server release 5.6  ip  192.168.1.157

软件:

nagios-3.2.3.tar.gz

nrpe-2.13.tar.gz

nagios-cn-3.2.3.tar          

pnp4nagios-0.6.19.tar.gz

cmake-2.8.10.tar.gz      

mysql-5.5.12.tar.gz          

ndoutils-1.5.2.tar.gz

fontconfig-2.4.2.tar.gz   

freetype-2.4.10.tar.gz

gd-2.0.35.tar.gz

jpegsrc.v6b.tar.gz

rrdtool-1.4.7.tar.gz

php-5.3.18.tar.gz

nagios-plugins-1.4.16.tar.gz

 

被监控机:

二、Nagios安装:

1、 创建nagios用户和软件目录:

useradd -s /sbin/nologin nagios

mkdir /usr/local/nagios

chown -R nagios.nagios /usr/local/nagios

2、 查看sendmail是否开启,用于发送报警邮件:

[root@localhost ~]# /etc/init.d/sendmail status

sendmail (pid  3899) is running...

3、 编译安装nagios

./configure --prefix=/usr/local/nagios/

make all

make install

make install-commandmode 

make install-config  

`   4nagios插件安装

yum install openssl-devel -y

        ./configure --prefix=/usr/local/nagios

        make

        make install

5nagios中文化插件安装

./configure

make all

make install

三、 MySQL安装:

1、         cmake 安装

./configure

make && make install

2、         MySQL安装

yum install ncurses-devel -y

cmake -DCMAKE_INSTALL_PREFIX= /usr/local/mysql/ -DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=latin1 -DEXTRA_CHARSETS=utf8,gbk -DWITH-MYSQLD-LDFLAGS=-ltcmalloc_minimal -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_CSV_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_NDB_STORAGE_ENGINE=0 -DWITH_ARCHIVE_STORAGE_ENGINE=0 -DINSTALL_LIBDIR=/usr/lib64 -DINSTALL_SHAREDIR=/usr/share/mysql -DINSTALL_MANDIR=/usr/share/man -DINSTALL_INFODIR=/usr/share/info -DWITH_BIG_TABLES=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB_DIR=bundled -DENABLED_ASSEMBLER=1 -DENABLED_PROFILING=1 -DENABLED_THREAD_SAFE_CLIENT=1 -DWITH_READLINE=1 -DWITH_PTHREAD=1 -DWITH_EMBEDDED_SESRVER=1 -DWITH_QUERY_CACHE=0 -DWITH_GEOMETRY=0 -DWITH_MYSQLD_LDFLAGS=-all-static -DWITH_DEBUG=0

make && make install

./mysql_install_db --datadir=/mysqldata/ --basedir=/usr/local/mysql/ --user=mysql

修改root密码,增加验证。

四、PHP安装

1jpeg6安装

jpegsrc.v6b.tar.gz

freetype-2.4.10.tar.gz

fontconfig-2.4.2.tar.gz    

gd-2.0.35.tar.gz

rrdtool-1.4.7.tar.gz

php-5.3.18.tar.gz

       mkdir -p /usr/local/jpeg

       mkdir -p /usr/local/jpeg/bin

       mkdir -p /usr/local/jpeg/lib

       mkdir -p /usr/local/jpeg/include

       mkdir -p /usr/local/jpeg/man

       mkdir -p /usr/local/jpeg/man1

       mkdir -p /usr/local/jpeg/man/man1

cp /usr/share/libtool/config.guess /usr/local/jpeg/

cp /usr/share/libtool/config.sub  /usr/local/jpeg/

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

make && make install

2freetype安装

./configure --prefix=/usr/local/freetype

make && make install

3fontconfig安装

yum install libxml*

./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config

make && make install

4、 gd安装

 yum -y install gettext gettext-devel

./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/gd --with-zlib --with-freetype=/usr/local/freetype/ --with-fontconfig=/usr/local/fontconfig/

    make && make install

5、 rrdtool安装

yum -y install libart_lgpl-devel

./configure --prefix=/usr/local/rrdtool

安装时报错:

configure: error: Please fix the library issues listed above and try again.

第一:

安装 cgilib-0.5.tar.gz

从这里下载:

weget http://download.chinaunix.net/down.php?id=2531&ResourceID=1333&site=1

tar zxvf cgilib-0.5.tar.gz

cd cgilib-0.5

make

cp libcgi.a /usr/local/lib

cp cgi.h /usr/include

如果还不行,请看

第二:

安装libart_lgpl-devel这个包

yum –y install libart_lgpl-devel

如果还报错configure: error: Please fix the library issues listed above and try again. 请看

第三:

把这两个包装上pango-devel cairo-devel

yum –y install pango-devel* cairo-devel*

然后

cd cd rrdtool-X.X.X

./configure --prefix=/usr/local/rrdtool

这样肯定能行,一般在第二部就能解决了。

如果还是不行的话,试试yum install libxml2-devel

我就是yum install libxml2-devel解决的

6、 安装php

yum install httpd-devel -y

/etc/httpd/modules/libphp5.so

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-gd=/usr/local/gd/  --with-mysql=/usr/local/mysql/ --with-mysqli=mysqlnd --with-jpeg-dir=/usr/local/jpeg/ --with-zlib-dir --enable-mbstring=all --with-pdo-mysql --with-freetype-dir=/usr/local/freetype/  --enable-sockets --enable-mbstring --with-apxs2=/usr/sbin/apxs

编译报错:

configure: error: Cannot find libmysqlclient under /usr/local/mysql/.

Note that the MySQL client library is not bundled anymore!

ln -s /usr/lib64/libmysqlclient* /usr/local/mysql/lib/

 

        cp php.ini-production  /usr/local/php/etc/php.ini

        /usr/local/php/etc/php.ini 文件修改

        date.timezone = Asia/Shanghai

        short_open_tag = On

        expose_php = off

 

 

五、 安装和配置http

yum install httpd

 

修改配置文件/etc/httpd/conf/httpd.conf

User nagios

Group nagios

DirectoryIndex index.html index.html.var index.php

AddType application/x-httpd-php .php

#setting for nagios

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

         <Directory "/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

         </Directory>

 

Alias /nagios "/usr/local/nagios/share"

         <Directory "/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

         </Directory>

增加验证密钥文件:

htpasswd -c /usr/local/nagios/etc/htpasswd.users

重启服务后可测试是否完成