简单综合部署nagios环境
额 我随便写的因为有的东西在每个机器上,会有很多包有可能存在也有可能不存在,我嫌麻烦所以没有判断,简单的写了一个脚本。因为太忙所以没有继续完美下去哈哈。。。#!/bin/sh -
cd /usr/local/src/gettext-0.18;./configure -prefix=/usr/local/gettext&&make&&make install;
cd /usr/local/src/net-snmp-5.5;./configure -prefix=/usr/local/net-snmp&&make&&make install;
cd /usr/local/src/httpd-2.2.9;./configure -prefix=/usr/local/httpd&&make&&make install;
useradd mysql;
cd /usr/local/src/mysql-5.0.56;./configure -prefix=/usr/local/mysqld&&make&&make install;
tar zxvf /root/PEAR.tar.gz -C /usr/local/;mv PEAR pear;
cd /usr/local/src/php-5.2.9;./configure -prefix=/usr/local/php5 --with-mysql=/usr/local/mysqld --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/usr/local/php5 --enable-ftp --with-pear=/usr/local/pear --with-gettext=/usr/local/gettext &&make&&make install;
useradd nagios;groupadd nagcmd;usermod -G nagcmd apache;usermod -G nagcmd nagios;
cd /usr/local/src/nagios-3.2.1;./configure --prefix=/usr/local/nagios --with-command-group=nagcmd &&make&&make install&&make install-init&&make install-config&&make install-commandmode&&make install-webconf;
chown -R nagios.nagios /usr/local/nagios;
cd /usr/local/src/nagios-plugins-1.4.14;./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios &&make&&make install;
cd /usr/local/src/nrpe-2.12;./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-nrpe-user=nagios --with-nrpe-group=nagios &&make && make install-plugin;
/usr/local/src/mysql-5.0.56/scripts/mysql_install_db --user=mysql
chown -R mysql.mysql /usr/local/mysqld
if [ -e /usr/local/mysqld/var/ ];then echo "exist"
else
mkdir /usr/local/mysqld/var/
chown -R mysql.mysql /usr/local/mysqld/var
fi
/usr/local/mysqld/bin/mysqld_safe --user=mysql&
rpm -e --nodeps httpd;
echo "#setting for nagios" >> /usr/local/httpd/conf/httpd.conf;sed'1,$p' /etc/httpd/conf.d/nagios.conf >> /usr/local/httpd/conf/httpd.conf;cd /usr/local/httpd/conf;sed -e 's/DirectoryIndex index.html/DirectoryIndex index.html index.htm index.php/' -e 's/User/User=nagios/' -e 's/Group/Group=nagios/' -e '/libphp5.so/a\addtype application/x-httpd-php .php' httpd.conf > httpd.conf.bak;rm -f httpd.conf;mv httpd.conf.bak httpd.conf;
/usr/local/httpd/bin/apachectl start;
cd /usr/local/nagios/etc/;/usr/local/httpd/bin/htpasswd -c htpasswd.users syshacker
页:
[1]