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
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
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
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
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
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
authorized_for_system_information=nagiosadmin,manwrx
authorized_for_configuration_information=nagiosadmin,manwrx
authorized_for_system_commands=nagiosadmin,manwrx
authorized_for_all_services=nagiosadmin,manwrx
authorized_for_all_hosts=nagiosadmin,manwrx
authorized_for_all_service_commands=nagiosadmin,manwrx
authorized_for_all_host_commands=nagiosadmin,manwrx
vi /usr/local/nagios/etc/objects/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
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
tar xvzf DBI-1.616.tar.gz
cd DBI-1.616
perl Makefile.PL
make install
cd /usr/src
wget
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!! ' include/config.h
sed -i 's! ! !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
lock_file=/usr/local/nagios/var/ndo2db.lock
ndo2db_user=nagios
ndo2db_group=nagios
socket_type=tcp
socket_name=/usr/local/nagios/var/ndo.sock
tcp_port=5668
use_ssl=0
db_servertype=mysql
db_host=localhost
db_port=3306
db_name=nagios
db_prefix=nagios_
db_user=nagios
db_pass=123456
max_timedevents_age=1440
max_systemcommands_age=10080
max_servicechecks_age=10080
max_hostchecks_age=10080
max_eventhandlers_age=44640
max_externalcommands_age=44640
debug_level=0
debug_verbosity=1
debug_file=/usr/local/nagios/var/ndo2db.debug
max_debug_file_size=1000000
vi /usr/local/nagios/etc/ndomod.cfg
instance_name=default
output_type=tcpsocket
output=127.0.0.1
tcp_port=5668
use_ssl=0
output_buffer_items=5000
buffer_file=/usr/local/nagios/var/ndomod.tmp
file_rotation_interval=14400
file_rotation_timeout=60
reconnect_interval=15
reconnect_warning_interval=15
data_processing_options=-1
config_output_options=2
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
define host {
name host-pnp
register 0
action_url /pnp4nagios/index.php?host=$HOSTNAME
}
define service {
name srv-pnp
register 0
action_url /pnp4nagios/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
}
rm -fr /usr/local/pnp4nagios/share/install.php
####在添加主机的时候可以用use 两个模版
###如 use linux-servers,host-pnp
阅读(1557) | 评论(0) | 转发(0) |