【nagios服务端】
1、检测所需要的软件库
yum -y install gcc gcc-c++ libxml2 libxml2-devel autoconf make libart_lgpl libart_lgpl-devel gd gd-devel openssl-devel libjpeg libjpeg-devel libpng libpng-devel freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel pango-devel cairo-devel
2、Add nagios for nagios system:
#useradd nagios �Cs /sbin/nologin �Cg nagios
#yum �Cy install httpd php gcc glibc glibc-common gd gd-devel openssl openssl-devel
创建Nagios账户和组
[root@UnixHot src]#groupadd nagioscmd
[root@UnixHot src]# useradd -g nagioscmd nagios
[root@UnixHot src]#usermod -g nagcmd apache
#tar zvxf nagios-3.2.3.tar.gz �CC /data/nagios
#cd /data/nagios
# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagioscmd
#make all
#make install
#make install-init
#make install-commandmode
#make install-config
Install nagios-plugins
#cd /data
# tar zvxf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
# ./configure --prefix=/usr/local/nagios
#make all
#make install
Add & Change access nagios web site password:
#htpasswd �Cc /usr/local/nagios/etc/htpasswd.user nagiosadmin
>123456
>123456
Install plugin-nrpe
# tar xf nrpe-2.12.tar.gz
# cd nrpe-2.12
./configure --prefix=/usr/local/nrpe --with-nagios-user=nagios --with-nagios-group=nagioscmd --with-nrpe-user=nagios --with-nrpe-group=nagioscmd
make all
make install-plugin
Install apache
前提:64位操作系统安装apache,需要apr和apr-util的支持,此处省略,这2款软件的安装目录在/usr/local/apache/apr和apr-util,目录需要在编译安装之前就需要建好,而且是在apache之下
解压安装:tar -xf http-2.2.10.tar.gz && cd http-2.2.10 && ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apache/apr --with-apr-util=/usr/local/apache/apr-util && make && make install
Install php(由于后面要用到Pnp,所以这里需要让php支持gd、png、jpeg、zlib等模块)
./configure -prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr --with-freetype-dir=/usr --with-gd=/usr/local/gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-libdir=lib64 --with-zlib --enable-sockets && make && make install
ps:64位操作系统安装php的库很容易报错,就我在安装的时候出现的问题,总结如下:
1、"configure: error: libjpeg.(a|so) not found“
解决:之前已经安装过了libjpeg 和libjpeg-devel了,仍然找不到库文件,明显是路径问题,默认会在/usr/lib/目录里查找相应的文件.但用whereis libjpeg发现.libjpeg被安装在了/usr/lib64/目录里.
# whereis libjpeg
libjpeg: /usr/lib/libjpeg.so /usr/lib64/libjpeg.so
即复制到/usr/lib目录里
cp -frp /usr/lib64/libjpeg.* /usr/lib/
configure一般的搜索编译路径为/usr/lib/下,因为php默认就在/usr/lib/下找相关库文件,而x64机器上是在:/usr/lib64.这时你就可以直接把需要的库文件从/usr/lib64中拷贝到/usr/lib/中去就可以了.
2、configure: error: Cannot find MySQL header files under /usr/local/src/mysql-5.1.14-beta-linux-i686-glibc23/include/.
Note that the MySQL client library is not bundled anymore!
--解决:查看系统有没有安装mysql header
find / -name mysql.h
root># find / -name mysql.h
/usr/local/mysql/include/mysql.h
/usr/include/mysql/mysql.h
/home/soft/mysql-5.5.28/include/mysql.h
--有的话,重新编译,加入--with-mysql=/usr
修改apache配置
找到:
DirectoryIndex index.html index.html.var
# tar zvxf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagioscmd
#make all
#make install
# tar xf nrpe-2.12.tar.gz
# cd nrpe-2.12
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagioscmd --with-nrpe-user=nagios --with-nrpe-group=nagioscmd
make all
make install-plugin
# make install-daemon
allowed_hosts=127.0.0.1,192.168.1.150(nagios服务器地址)
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg �Cd
# netstat �Clntp
tcp 0 0 192.168.1.165:5666 0.0.0.0:* LISTEN 16431/nrpe
如果返回Connection refused or timed out,则要注意防火墙和selinux,可以先清空防火墙规则看看能否检测到版本,不过在真实环境下不可能会让防火墙规则清空,则需要这样添加即可:
vi /etc/sysconfig/iptables
-A INPUT -s xx(nagios服务端ip) -p tcp --dport 5666 -j ACCEPT
然后再重启iptables,注意规则先后顺序
如果客户端在安装nrpe的时候,出现如下错误:
cd ./src/ && make install
make[1]: Entering directory `/home/1/nrpe-2.13/src'
make install-plugin
make[2]: Entering directory `/home/1/nrpe-2.13/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install: invalid group `nagios'
make[2]: *** [install-plugin] Error 1
make[2]: Leaving directory `/home/1/nrpe-2.13/src'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/home/1/nrpe-2.13/src'
make: *** [install] Error 2
看看nagios用户属于什么组,最好是把nagios加入到nagios本身组中,我曾经把nagios加入到自己建的组中,然后就出现了如上错误
####x64操作系统编译方式安装php出现的种种问题的解决
http://www.oschina.net/question/17_87