nagios+pnp4nagios配置实例,供大家学习参考。
没有过多的文字介绍,仅提供了安装步骤,大家自行研读吧。
yum -y install wget openssl-devel vixie-cron libart_lgpl-devel pango-devel cairo-devel gd-devel perl-devel zlib-devel libjpeg-devel libpng-devel freetype-dir vim* curl-devel libxml2-devel bzip2-devel
host nagios.manwrx.com
alias vi=vim
groupadd -g 1000 mysql
useradd -g 1000 -u 1000 -d /dev/null -s /sbin/nologin mysql
cd /usr/src
tar xvzf mysql-5.1.55-linux-i686-glibc23.tar.gz
mv mysql-5.1.55-linux-i686-glibc23 /usr/local/mysql
cd /usr/local/mysql/
chown -R mysql.mysql .
./scripts/mysql_install_db --datadir=/usr/local/mysql/data/ --user=mysql
chown -R root .
chown -R mysql.mysql data/
rm -fr /etc/my.cnf
cp support-files/my-medium.cnf /etc/my.cnf
bin/mysqld_safe --datadir=/usr/local/mysql/data/ --user=mysql &
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
service mysqld restart
echo 'PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
echo '/usr/local/mysql/lib/' >> /etc/ld.so.conf
ldconfig -v
cd /usr/src
wget http://mirrors.ispros.com.bd/apache/httpd/httpd-2.2.19.tar.bz2
tar xvjf httpd-2.2.19.tar.bz2
cd httpd-2.2.19
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl
make
make install
echo '/usr/local/apache/bin/apachectl start' >> /etc/rc.local
vi /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php .phps
DirectoryIndex index.php index.html
cd /usr/src
wget http://cn.php.net/distributions/php-5.3.6.tar.bz2
tar xvjf php-5.3.6.tar.bz2
cd php-5.3.6
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-zip --with-zlib-dir --with-libxml-dir --enable-sockets --with-openssl-dir --enable-mbstring --enable-gd-native-ttf --with-png-dir --with-freetype-dir --with-jpeg-dir --with-pcre-dir --with-bz2 --with-curl
make
make install
cp php.ini-production /usr/local/php/lib/php.ini
groupadd -g 1002 nagios
useradd -g 1002 -u 1002 -d /dev/null -s /sbin/nologin nagios
cd /usr/src
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
tar xvzf nagios-3.2.3.tar.gz
cd nagios-3.2.3
./configure --prefix=/usr/local/nagios
make all
make install
make install-init
make install-config
make install-commandmode
cat sample-config/httpd.conf |grep -v "#" >> /usr/local/apache/conf/httpd.conf
cd /usr/src
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
tar xvzf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --prefix=/usr/local/nagios
make
make install
cd /usr/src
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar xvzf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure --prefix=/usr/local/nagios
make
make install
chown -R nagios:nagios /usr/local/nagios
#### 添加浏览nagios用户名,###
/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/usr/local/apache/bin/htpasswd /usr/local/nagios/etc/htpasswd.users manwrx
vi/usr/local/nagios/etc/cgi.cfg
vi /usr/local/nagios/etc/objects/commands.cfg
chkconfig nagios on
service nagios restart
/usr/local/apache/bin/apachectl start
echo '/usr/local/apache/bin/apachectl start' >> /etc/rc.local
cd /usr/src
wget http://mirrors.xmu.edu.cn/CPAN/authors/id/T/TI/TIMB/DBI-1.616.tar.gz
tar xvzf DBI-1.616.tar.gz
cd DBI-1.616
perl Makefile.PL
make install
cd /usr/src
wget http://mirrors.xmu.edu.cn/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.019.tar.gz
tar xvzf DBD-mysql-4.019.tar.gz
cd DBD-mysql-4.019
perl Makefile.PL --with-mysql=/usr/local/mysql --mysql_config=/usr/local/mysql/bin/mysql_config
make install
cd /usr/src
wget http://ncu.dl.sourceforge.net/project/nagios/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz
tar xvzf ndoutils-1.4b9.tar.gz
cd ndoutils-1.4b9
./configure --prefix=/usr/local/nagios CPPFLAGS=-I/usr/local/mysql/include/ --with-mysql-inc=/usr/local/mysql/include/ LDFLAGS=-L/usr/local/mysql/lib/mysql/ --with-mysql-lib=/usr/local/mysql/lib/mysql/ --enable-mysql --with-mysql=/usr/local/mysql/ --with-ndo2db-user=nagios --with-ndo2db=nagios --disable-pgsql
sed -i 's!<mysql/mysql.h>! </usr/local/mysql/include/mysql.h!g>' include/config.h
sed -i 's! <mysql/errmsg.h>! </usr/local/mysql/include/errmsg.h>!g' include/config.h
make
/usr/local/mysql/bin/mysql
mysql> create database nagios;
mysql> grant all privileges on nagios.* to nagios@'localhost' identified by '123456';
cd src
cp ndo2db-3x ndomod-3x.o file2sock log2ndo /usr/local/nagios/bin/
cd ..
cp config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
cp config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
/usr/local/mysql/bin/mysql -u nagios -p'123456' nagios < ./db/mysql.sql
vi /usr/local/nagios/etc/ndo2db.cfg
vi /usr/local/nagios/etc/ndomod.cfg
cat config/nagios.cfg |grep -v "#" |sed 's!2!3!g' >> /usr/local/nagios/etc/nagios.cfg
/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg
echo '/usr/local/nagios/bin/ndo2db-3x -c /usr/local/nagios/etc/ndo2db.cfg ' >> /etc/rc.local
cd /usr/src
tar xvzf rrdtool-1.4.5.tar.gz
cd rrdtool-1.4.5
./configure --prefix=/usr/local/rrdtool
make
make install
cd /usr/src
wget http://ncu.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.14.tar.gz
tar xvzf pnp4nagios-0.6.14.tar.gz
cd pnp4nagios-0.6.14
./configure --prefix=/usr/local/pnp4nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool
make all
make install
make install-webconf
make install-config
make install-init
sed -n '7,13p' ./sample-config/nagios.cfg-sample |sed '/^$/d' >> /usr/local/nagios/etc/nagios.cfg
cat ./sample-config/httpd.conf |grep -v "#" >> /usr/local/apache/conf/httpd.conf
编辑命令配置文件
vi /usr/local/nagios/etc/objects/commands.cfg
define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}
define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
}
编辑模板文件
vi /usr/local/nagios/etc/objects/templates.cfg
rm -fr /usr/local/pnp4nagios/share/install.php
####在添加主机的时候可以用use 两个模版
###如 use linux-servers,host-pnp