安装环境:centos-5.5
Nagios是一款用于系统和网络监控的应用程序。它可以在你设定的条件下对主机和服务进行监控,在状态变差和变好的时候给出告警信息。
一、安装apache,php
前提:#yum –y install *gcc*
1、安装freetype (FreeType库是一个 开源的、高质量的且可移植的字体引擎)
# tar -zxvf freetype-2.4.3.tar.gz -C /usr/src/
# cd /usr/src/freetype-2.4.3/
# ./configure --prefix=/usr/local/freetype-2.4.3
# make
# make install
2、安装libpng (支持对 PNG 图形文件的创建、读写等操作)
# tar -zxvf libpng.tar.gz -C /usr/src/
# cd /usr/src/libpng-1.4.4/
# ./configure --prefix=/usr/local/libpng-1.4.4
# make
# make install
3、安装jpeg (显示JPEG图像)
# tar -zxvf jpegsrc.v8b.tar.gz -C /usr/src/
# cd /usr/src/jpeg-8b/
# ./configure --prefix=/usr/local/jpeg-8b
# make
# make install
4、 安装GD库
重新加载 lib # ldconfig
# ldconfig -p | grep jpeg
# ldconfig -p | grep free
# ldconfig -p | grep libpng
# tar -zxvf gd-2.0.33.tar.gz -C /usr/src/
# cd /usr/src/gd-2.0.33/
# ./configure --prefix=/usr/local/gd-2.0.33 --with-jpeg=/usr/local/jpeg-8b/ --with-freetype=/usr/local/freetype-2.4.3/ --with-png=/usr/local/libpng-1.4.4/ --with-zlib --enable-m4_pattern_allow
解决方法:# vim gd_png.c
找到png.h 改为 /usr/local/libpng-1.4.4/include/png.h
# make
# make install
5、 安装apache
# rpm -e httpd -–nodeps 把rpm安装的httpd包卸载
# tar -zxvf httpd-2.2.15.tar.gz -C /usr/src/
# cd /usr/src/httpd-2.2.15/ # ./configure --prefix=/usr/local/apache-2.2.15 --enable-so --enable-rewrite
# make
# make install
6、 安装php
# tar -zxvf .tar.gz -C /usr/src/
# cd /usr/src/php-5.2.10/
# ./configure --prefix=/usr/local/php-5.2.10 --with-apxs2=/usr/local/apache-2.2.15/bin/apxs --with-zlib --with-libxml-dir --enable-gd-native-ttf --enable-mbstring --with-gd=/usr/local/gd-2.0.33/ --with-freetype-dir=/usr/local/freetype-2.4.3/ --with-jpeg-dir=/usr/local/jpeg-8b/ --with-png-dir=/usr/local/libpng-1.4.4/
解决方法:放入系统光盘 yum –y install libxml2* libxml2是一个xml C语言的解析器和工具
# make
# make test
# make install
Apaceh与php整合
# vim /usr/local/apache/conf/httpd.conf
53 LoadModule php5_module modules/libphp5.so
54 AddType application/x-httpd-php .php
167 <IfModule dir_module>
168 DirectoryIndex index.php index.html
169 </IfModule>
# /usr/local/apache/bin/apachectl start
验证:
二、安装nagios
1、创建系统用户
# useradd nagios
# passwd nagios
# groupadd nagcmd
# usermod -G nagcmd nagios
# usermod -G nagcmd apache
3、安装nagios
# tar -zxvf nagios-3.1.2.tar.gz -C /usr/src/
# cd /usr/src/nagios-3.1.2/
# ./configure --with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
修改配置文件:# vim /usr/local/nagios/etc/objects/contacts.cfg
35 email
更改email接收报警内容
# make install-webconf 安装nagios的web配置文件到apache的conf.d目录下
/usr/bin/install: 无法创建一般文件“/etc/httpd/conf.d/nagios.conf”: 没有那个文件或目录 make: *** [install-webconf] 错误 1 |
解决方法以:# mkidr –p /etc/httpd/conf.d
# vim /usr/local/apache/conf/httpd.conf
: -r /etc/httpd/conf.d/nagios.conf 将文件导入到apache配置文件中
# /usr/local/apache/bin/apachectl start 启动apache
# /usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users test 创建登录nagios用户
3、安装插件
1)、nagios-plugis
# tar -zxvf nagios-plugins-1.4.14.tar.gz -C /usr/src/
# cd /usr/src/nagios-plugins-1.4.14/
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
到此,nagios已经安装完成,需要做以下设置,启动Nagios
# chkconfig –add nagios 将nagios添加到服务中
# chkconfig nagios on 设置服务开机启动
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 检查nagios配置是否正确
# service nagios start 启动nagios
# setenforce 0 关闭selinux
验证:http://localhost/nagios
解决方法:# vim /usr/local/nagios/etc/cgi.cfg
78 use_authentication=0
# service nagios restart