Skip to content

Instantly share code, notes, and snippets.

@taka3110
Last active August 29, 2015 14:23
Show Gist options
  • Save taka3110/11bd0be40e3d1d73633d to your computer and use it in GitHub Desktop.
Save taka3110/11bd0be40e3d1d73633d to your computer and use it in GitHub Desktop.
cacti-fastinstall.sh
#!/bin/sh
#cacti-fastinstall.sh
#taka3110
#for CentOS6
cp -pi /etc/sysconfig/selinux ~/selinux.org
sed -i -e "s/SELINUX=enforcing/SELINUX=disabled/" /etc/sysconfig/selinux
setenforce 0
yum -y install rrdtool rrdtool-perl net-snmp net-snmp-utils httpd mysql-server php-mysql php wget
/etc/init.d/mysqld start
mysql -e "create database cacti;"
mysql -e "grant all privileges on cacti.* to cactiuser@localhost identified by 'cactiuser';"
wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
tar xzvf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /var/www/html/cacti
mysql -u cactiuser -pcactiuser cacti < /var/www/html/cacti/cacti.sql
echo "#cacti" >> /etc/crontab
echo "*/5 * * * * root /usr/bin/php /var/www/html/cacti/poller.php >/dev/null 2>&1" >> /etc/crontab
cp -pi /etc/php.ini /etc/php.ini.org
sed -i -e "s/;date.timezone =/date.timezone = \"Asia\/Tokyo\"/" /etc/php.ini
/etc/init.d/snmpd start
/etc/init.d/httpd start
/etc/init.d/iptables stop
chkconfig iptables off
wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.7.tar.gz
tar xvfz better-cacti-templates-1.1.7.tar.gz
cp better-cacti-templates-1.1.7/scripts/ss_get_mysql_stats.php /var/www/html/cacti/scripts/
sed -i -e "s/\$mysql_user = 'cactiuser';/\$mysql_user = 'cactimon';/" /var/www/html/cacti/scripts/ss_get_mysql_stats.php
sed -i -e "s/\$mysql_pass = 'cactiuser';/\$mysql_pass = 'cactimon';/" /var/www/html/cacti/scripts/ss_get_mysql_stats.php
# http://ip-address/cacti/index.php
## add MySQL monitoring
# mysql -u root
# grant process,super on *.* to cactimon@"localhost" identified by 'cactimon';
## for remote
# grant process,super on *.* to cactimon@"%" identified by 'cactimon';
# flush privileges;
## cacti template
# cp cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.7.xml /var/www/html/mysql.xml
## load http://ipaddress/mysql.xml
# rm -f /var/www/html/mysql.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment