close
echo -e "\033[31m"
echo -e " Cacti Install Shell Script (CentOS 5.1) "
echo -e " by Lu 2008/04/17 "
echo -e "\033[0m"
DEBUG=n
if [ "`cat /proc/version | grep centos | grep el5`" != "" ]; then
OS="CentOS 5.x"
echo "Detection your OS is CentOS 5.x"
else
echo "[ERROR] Only Support CentOS 5.x"
exit
fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " ntpdate tick.stdtime.gov.tw "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mKill nptd on running...\033[0m"
ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
for i in $ProcessID
do
echo $i
kill -9 $i
done
ntpdate tick.stdtime.gov.tw
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Configure Cacti Install Enviroment "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mKill yum on running...\033[0m"
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
echo $i
kill -9 $i
done
echo -e "\033[32mCacti requires MySQL, PHP, RRDTool, net-snmp, and a webserver that supports PHP such as Apache or IIS. \033[0m"
echo -e "\033[32myum check : httpd mysql-server cacti php php-mysql php-snmp net-snmp net-snmp-utils phpMyAdmin rrdtool gcc libart_lgpl-devel zlib-devel libpng-devel freetype-devel \033[0m"
if [ ! -s cacti-0.8.7b.tar.gz ]; then
wget http://www.cacti.net/downloads/cacti-0.8.7b.tar.gz
fi
if [ ! -s cacti-0.8.7b.tar.gz ]; then
echo "cacti-0.8.7b.tar.gz not found !"
exit
fi
if [ ! -s rrdtool-1.2.27.tar.gz ]; then
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.27.tar.gz
fi
if [ ! -s rrdtool-1.2.27.tar.gz ]; then
echo "rrdtool-1.2.27.tar.gz not found !"
exit
fi
if [ ! -s phpMyAdmin-2.11.5.1-all-languages.tar.gz ]; then
wget http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-2.11.5.1-all-languages.tar.gz?download
fi
if [ ! -s phpMyAdmin-2.11.5.1-all-languages.tar.gz ]; then
wget http://jaist.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.11.5.1-all-languages.tar.gz
fi
if [ -s phpMyAdmin-2.11.5.1-all-languages.tar.gz ]; then
tar zxvf phpMyAdmin-2.11.5.1-all-languages.tar.gz -C /var/www/html
mv /var/www/html/phpMyAdmin-2.11.5.1-all-languages /var/www/html/phpMyAdmin
fi
if [ ! -s phpMyAdmin-2.11.5.1-all-languages.tar.gz ]; then
echo "phpMyAdmin-2.11.5.1-all-languages.tar.gz not found !"
fi
YUMARGS=""
if [ "`rpm -q httpd | grep not`" != "" ]; then
YUMARGS="$YUMARGS httpd"
echo "httpd not installed"
else
echo "httpd installed"
fi
if [ "`rpm -q mysql-server | grep not`" != "" ]; then
YUMARGS="$YUMARGS mysql-server"
echo "mysql-server not installed"
else
echo "mysql-server installed"
fi
if [ "`rpm -q php | grep not `" != "" ]; then
YUMARGS="$YUMARGS php"
echo "php not installed"
else
echo "php installed"
fi
if [ "`rpm -q php-mysql | grep not `" != "" ]; then
YUMARGS="$YUMARGS php-mysql"
echo "php-mysql not installed"
else
echo "php-mysql installed"
fi
if [ "`rpm -q php-snmp | grep not `" != "" ]; then
YUMARGS="$YUMARGS php-snmp"
echo "php-snmp not installed"
else
echo "php-snmp installed"
fi
if [ "`rpm -q net-snmp | grep not `" != "" ]; then
YUMARGS="$YUMARGS net-snmp"
echo "net-snmp not installed"
else
echo "net-snmp installed"
fi
if [ "`rpm -q net-snmp-utils | grep not `" != "" ]; then
YUMARGS="$YUMARGS net-snmp-utils"
echo "net-snmp-utils not installed"
else
echo "net-snmp-utils installed"
fi
if [ "`rpm -q gcc | grep not `" != "" ]; then
YUMARGS="$YUMARGS gcc"
echo "gcc not installed, RRDTool need it to compile"
else
echo "gcc installed"
fi
if [ "`rpm -q libart_lgpl-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS libart_lgpl-devel"
echo "libart_lgpl-devel not installed, RRDTool need it to compile"
else
echo "libart_lgpl-devel installed"
fi
if [ "`rpm -q zlib-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS zlib-devel"
echo "zlib-devel not installed, RRDTool need it to compile"
else
echo "zlib-devel installed"
fi
if [ "`rpm -q libpng-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS libpng-devel"
echo "libpng-devel not installed, RRDTool need it to compile"
else
echo "libpng-devel installed"
fi
if [ "`rpm -q freetype-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS freetype-devel"
echo "freetype-devel not installed, RRDTool need it to compile"
else
echo "freetype-devel installed"
fi
#echo $YUMARGS
if [ ! "$YUMARGS" == "" ]; then
echo -e "\033[32mrm -fr /var/cache/yum \033[0m"
rm -fr /var/cache/yum
echo -e "\033[32myum -y install $YUMARGS \033[0m"
yum -y install $YUMARGS
fi
echo -e "\033[32mchkconfig snmpd on \033[0m"
chkconfig snmpd on
echo -e "\033[32mchkconfig httpd on \033[0m"
chkconfig httpd on
echo -e "\033[32mchkconfig mysqld on \033[0m"
chkconfig mysqld on
echo -e "\033[32mservice snmpd restart \033[0m"
service snmpd restart
echo -e "\033[32mservice httpd restart \033[0m"
service httpd restart
echo -e "\033[32mservice mysqld restart \033[0m"
service mysqld restart
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Install and Configure RRDTool (Round Robin Database tool)"
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mtar zxvf cacti-0.8.7b.tar.gz -C /var/www/html \033[0m"
tar zxvf cacti-0.8.7b.tar.gz -C /var/www/html
echo -e "\033[32mmv /var/www/html/cacti-0.8.7b /var/www/html/cacti \033[0m"
mv /var/www/html/cacti-0.8.7b /var/www/html/cacti
echo -e "\033[32mtar zxvf rrdtool-1.2.27.tar.gz \033[0m"
tar zxvf rrdtool-1.2.27.tar.gz
echo -e "\033[32mcd rrdtool-1.2.27 \033[0m"
cd rrdtool-1.2.27
pwd
echo -e "\033[32m./configure \033[0m"
./configure
echo -e "\033[32mmake \033[0m"
make
echo -e "\033[32mmake install\033[0m"
make install
echo -e "\033[32mcd /usr/local/bin\033[0m"
cd /usr/local/bin
pwd
echo -e "\033[32mln -s /usr/local/rrdtool-1.2.27/bin/rrdtool rrdtool \033[0m"
ln -s /usr/local/rrdtool-1.2.27/bin/rrdtool rrdtool
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Install and Configure Cacti "
echo -e "####################################"
echo -e "\033[0m"
cd /var/www/html/cacti
echo -e "\033[32mReference : /etc/cacti/db.php \033[0m"
#echo -e "\033[32mmysql -e \" create database cacti; \" \033[0m"
#mysql -e " create database cacti; "
#echo -e "\033[32mmysqladmin --user=root create cacti \" \033[0m"
mysqladmin --user=root create cacti
mysql -e "use cacti; show databases; "
echo -e "\033[32mmysql cacti < cacti.sql \" \033[0m"
mysql cacti < cacti.sql
mysql -e "use cacti; show tables; "
#echo -e "\033[32mmysql -e \"set password for cactiuser@localhost = password('cactiuser'); \" \033[0m"
#mysql -e "set password for cactiuser@localhost = password('cactiuser') ; "
#echo -e "\033[32mCreate MySQL Account : cactiuser, Password : cactiuser \033[0m"
#mysql -e "use mysql; insert into user values('localhost','cactiuser',PASSWORD('cactiuser'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); "
echo -e "\033[32mmysql -e \" GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY PASSWORD('cactiuser'); \" \033[0m"
mysql -e "GRANT ALL PRIVILEGES ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser' ; "
echo -e "\033[32mmysql -e \" flush privileges; \" \033[0m"
mysql -e " flush privileges; "
echo -e "\033[32mmysql -e \"use mysql; select * from user where User='cactiuser'; \" \033[0m"
mysql -e "use mysql; select * from user where User='cactiuser'; "
#chown -R cactirunner rra/ log/
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Modify /etc/crontab "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mModify /etc/crontab\033[0m"
#echo "Deleting old setting , Adding MRTG to /etc/crontab..."
sed -i -e "/poller/d" /etc/crontab
echo "*/5 * * * * root /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1 " >> /etc/crontab
echo "" >> /etc/crontab
cat /etc/crontab | grep poller
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Run Cacti "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mservice snmpd restart \033[0m"
service snmpd restart
echo -e "\033[32mservice httpd restart \033[0m"
service httpd restart
echo -e "\033[32mservice mysqld restart \033[0m"
service mysqld restart
#echo -e "\033[32mfirefox http://localhost/phpMyAdmin & \033[0m"
#echo -e "\033[32mUserName : root \033[0m"
#echo -e "\033[32mPassword : \033[0m"
#firefox http://localhost/phpMyAdmin &
echo -e "\033[32mfirefox http://localhost/cacti & \033[0m"
echo -e "\033[32mUserName : admin \033[0m"
echo -e "\033[32mPassword : admin \033[0m"
firefox http://localhost/cacti &
---------------------------------------------------------------------------------------------------------------------------------------
參考網址:http://forum.icst.org.tw/phpbb/viewtopic.php?f=24&t=14860
---------------------------------------------------------------------------------------------------------------------------------------
echo -e " Cacti Install Shell Script (CentOS 5.1) "
echo -e " by Lu 2008/04/17 "
echo -e "\033[0m"
DEBUG=n
if [ "`cat /proc/version | grep centos | grep el5`" != "" ]; then
OS="CentOS 5.x"
echo "Detection your OS is CentOS 5.x"
else
echo "[ERROR] Only Support CentOS 5.x"
exit
fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " ntpdate tick.stdtime.gov.tw "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mKill nptd on running...\033[0m"
ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
for i in $ProcessID
do
echo $i
kill -9 $i
done
ntpdate tick.stdtime.gov.tw
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Configure Cacti Install Enviroment "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mKill yum on running...\033[0m"
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
echo $i
kill -9 $i
done
echo -e "\033[32mCacti requires MySQL, PHP, RRDTool, net-snmp, and a webserver that supports PHP such as Apache or IIS. \033[0m"
echo -e "\033[32myum check : httpd mysql-server cacti php php-mysql php-snmp net-snmp net-snmp-utils phpMyAdmin rrdtool gcc libart_lgpl-devel zlib-devel libpng-devel freetype-devel \033[0m"
if [ ! -s cacti-0.8.7b.tar.gz ]; then
wget http://www.cacti.net/downloads/cacti-0.8.7b.tar.gz
fi
if [ ! -s cacti-0.8.7b.tar.gz ]; then
echo "cacti-0.8.7b.tar.gz not found !"
exit
fi
if [ ! -s rrdtool-1.2.27.tar.gz ]; then
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.27.tar.gz
fi
if [ ! -s rrdtool-1.2.27.tar.gz ]; then
echo "rrdtool-1.2.27.tar.gz not found !"
exit
fi
if [ ! -s phpMyAdmin-2.11.5.1-all-languages.tar.gz ]; then
wget http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-2.11.5.1-all-languages.tar.gz?download
fi
if [ ! -s phpMyAdmin-2.11.5.1-all-languages.tar.gz ]; then
wget http://jaist.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.11.5.1-all-languages.tar.gz
fi
if [ -s phpMyAdmin-2.11.5.1-all-languages.tar.gz ]; then
tar zxvf phpMyAdmin-2.11.5.1-all-languages.tar.gz -C /var/www/html
mv /var/www/html/phpMyAdmin-2.11.5.1-all-languages /var/www/html/phpMyAdmin
fi
if [ ! -s phpMyAdmin-2.11.5.1-all-languages.tar.gz ]; then
echo "phpMyAdmin-2.11.5.1-all-languages.tar.gz not found !"
fi
YUMARGS=""
if [ "`rpm -q httpd | grep not`" != "" ]; then
YUMARGS="$YUMARGS httpd"
echo "httpd not installed"
else
echo "httpd installed"
fi
if [ "`rpm -q mysql-server | grep not`" != "" ]; then
YUMARGS="$YUMARGS mysql-server"
echo "mysql-server not installed"
else
echo "mysql-server installed"
fi
if [ "`rpm -q php | grep not `" != "" ]; then
YUMARGS="$YUMARGS php"
echo "php not installed"
else
echo "php installed"
fi
if [ "`rpm -q php-mysql | grep not `" != "" ]; then
YUMARGS="$YUMARGS php-mysql"
echo "php-mysql not installed"
else
echo "php-mysql installed"
fi
if [ "`rpm -q php-snmp | grep not `" != "" ]; then
YUMARGS="$YUMARGS php-snmp"
echo "php-snmp not installed"
else
echo "php-snmp installed"
fi
if [ "`rpm -q net-snmp | grep not `" != "" ]; then
YUMARGS="$YUMARGS net-snmp"
echo "net-snmp not installed"
else
echo "net-snmp installed"
fi
if [ "`rpm -q net-snmp-utils | grep not `" != "" ]; then
YUMARGS="$YUMARGS net-snmp-utils"
echo "net-snmp-utils not installed"
else
echo "net-snmp-utils installed"
fi
if [ "`rpm -q gcc | grep not `" != "" ]; then
YUMARGS="$YUMARGS gcc"
echo "gcc not installed, RRDTool need it to compile"
else
echo "gcc installed"
fi
if [ "`rpm -q libart_lgpl-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS libart_lgpl-devel"
echo "libart_lgpl-devel not installed, RRDTool need it to compile"
else
echo "libart_lgpl-devel installed"
fi
if [ "`rpm -q zlib-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS zlib-devel"
echo "zlib-devel not installed, RRDTool need it to compile"
else
echo "zlib-devel installed"
fi
if [ "`rpm -q libpng-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS libpng-devel"
echo "libpng-devel not installed, RRDTool need it to compile"
else
echo "libpng-devel installed"
fi
if [ "`rpm -q freetype-devel | grep not `" != "" ]; then
YUMARGS="$YUMARGS freetype-devel"
echo "freetype-devel not installed, RRDTool need it to compile"
else
echo "freetype-devel installed"
fi
#echo $YUMARGS
if [ ! "$YUMARGS" == "" ]; then
echo -e "\033[32mrm -fr /var/cache/yum \033[0m"
rm -fr /var/cache/yum
echo -e "\033[32myum -y install $YUMARGS \033[0m"
yum -y install $YUMARGS
fi
echo -e "\033[32mchkconfig snmpd on \033[0m"
chkconfig snmpd on
echo -e "\033[32mchkconfig httpd on \033[0m"
chkconfig httpd on
echo -e "\033[32mchkconfig mysqld on \033[0m"
chkconfig mysqld on
echo -e "\033[32mservice snmpd restart \033[0m"
service snmpd restart
echo -e "\033[32mservice httpd restart \033[0m"
service httpd restart
echo -e "\033[32mservice mysqld restart \033[0m"
service mysqld restart
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Install and Configure RRDTool (Round Robin Database tool)"
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mtar zxvf cacti-0.8.7b.tar.gz -C /var/www/html \033[0m"
tar zxvf cacti-0.8.7b.tar.gz -C /var/www/html
echo -e "\033[32mmv /var/www/html/cacti-0.8.7b /var/www/html/cacti \033[0m"
mv /var/www/html/cacti-0.8.7b /var/www/html/cacti
echo -e "\033[32mtar zxvf rrdtool-1.2.27.tar.gz \033[0m"
tar zxvf rrdtool-1.2.27.tar.gz
echo -e "\033[32mcd rrdtool-1.2.27 \033[0m"
cd rrdtool-1.2.27
pwd
echo -e "\033[32m./configure \033[0m"
./configure
echo -e "\033[32mmake \033[0m"
make
echo -e "\033[32mmake install\033[0m"
make install
echo -e "\033[32mcd /usr/local/bin\033[0m"
cd /usr/local/bin
pwd
echo -e "\033[32mln -s /usr/local/rrdtool-1.2.27/bin/rrdtool rrdtool \033[0m"
ln -s /usr/local/rrdtool-1.2.27/bin/rrdtool rrdtool
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Install and Configure Cacti "
echo -e "####################################"
echo -e "\033[0m"
cd /var/www/html/cacti
echo -e "\033[32mReference : /etc/cacti/db.php \033[0m"
#echo -e "\033[32mmysql -e \" create database cacti; \" \033[0m"
#mysql -e " create database cacti; "
#echo -e "\033[32mmysqladmin --user=root create cacti \" \033[0m"
mysqladmin --user=root create cacti
mysql -e "use cacti; show databases; "
echo -e "\033[32mmysql cacti < cacti.sql \" \033[0m"
mysql cacti < cacti.sql
mysql -e "use cacti; show tables; "
#echo -e "\033[32mmysql -e \"set password for cactiuser@localhost = password('cactiuser'); \" \033[0m"
#mysql -e "set password for cactiuser@localhost = password('cactiuser') ; "
#echo -e "\033[32mCreate MySQL Account : cactiuser, Password : cactiuser \033[0m"
#mysql -e "use mysql; insert into user values('localhost','cactiuser',PASSWORD('cactiuser'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); "
echo -e "\033[32mmysql -e \" GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY PASSWORD('cactiuser'); \" \033[0m"
mysql -e "GRANT ALL PRIVILEGES ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser' ; "
echo -e "\033[32mmysql -e \" flush privileges; \" \033[0m"
mysql -e " flush privileges; "
echo -e "\033[32mmysql -e \"use mysql; select * from user where User='cactiuser'; \" \033[0m"
mysql -e "use mysql; select * from user where User='cactiuser'; "
#chown -R cactirunner rra/ log/
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Modify /etc/crontab "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mModify /etc/crontab\033[0m"
#echo "Deleting old setting , Adding MRTG to /etc/crontab..."
sed -i -e "/poller/d" /etc/crontab
echo "*/5 * * * * root /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1 " >> /etc/crontab
echo "" >> /etc/crontab
cat /etc/crontab | grep poller
if [ "$DEBUG" == "y" ]; then echo "Press any key to continue..." ; read ; fi
echo -e "\033[31m"
echo -e "############# Step ###############"
echo -e " Run Cacti "
echo -e "####################################"
echo -e "\033[0m"
echo -e "\033[32mservice snmpd restart \033[0m"
service snmpd restart
echo -e "\033[32mservice httpd restart \033[0m"
service httpd restart
echo -e "\033[32mservice mysqld restart \033[0m"
service mysqld restart
#echo -e "\033[32mfirefox http://localhost/phpMyAdmin & \033[0m"
#echo -e "\033[32mUserName : root \033[0m"
#echo -e "\033[32mPassword : \033[0m"
#firefox http://localhost/phpMyAdmin &
echo -e "\033[32mfirefox http://localhost/cacti & \033[0m"
echo -e "\033[32mUserName : admin \033[0m"
echo -e "\033[32mPassword : admin \033[0m"
firefox http://localhost/cacti &
---------------------------------------------------------------------------------------------------------------------------------------
參考網址:http://forum.icst.org.tw/phpbb/viewtopic.php?f=24&t=14860
---------------------------------------------------------------------------------------------------------------------------------------
全站熱搜
留言列表