cacti 0.8.8b & spine 0.8.8b @ centos 6 x86_64 install script

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

cacti 0.8.8b & spine 0.8.8b @ centos 6 x86_64 install script

Post by nationals »

Code: Select all

#!/bin/sh

# script for install cacti 0.8.8b and spine 0.8.8b on Centos Linux Release 6.x x86_64
# Version : 2.0.0
# Make by Patrick.Ru @ China
# E-Mail : patrick.ru@hotmail.com
# Date : 12-Feb-2014


# check if Centos/Redhat Release
if [ ! -f /etc/redhat-release ]; then
    echo
    echo This is not Centos/Redhat Release Linux.
    echo It is not supported!
    echo Exit...
    echo
    exit
fi

# check if CentOS Release
if [ `cat /etc/redhat-release| awk '{ print $1 }'` != "CentOS" ]; then
    echo
    echo This installed release is `cat /etc/redhat-release| awk '{ print $1 }'`
    echo but not CentOS.
    echo This is only support for CentOS release.
    echo Please run it under the CentOS release.
    echo Exit...
    echo
    exit
fi

# check if CentOS Release 6
if [ `cat /etc/redhat-release| awk '{ print $3 }'| awk -F . '{ print $1 }'` != "6" ]; then
    echo
    echo This installed release version is `cat /etc/redhat-release| awk '{ print $3 }'`
    echo but not 6.x.
    echo This is only support for CentOS release 6.x.
    echo Please run it under the CentOS release 6.x.
    echo Exit...
    echo
    exit
fi

# check if x86_64 arch
if [ `uname -p` != "x86_64" ]; then
    echo
    echo This installed release version is `uname -p`
    echo but not x86_64
    echo This is only support for x86_64
    echo Please run it under the x86_64
    echo Exit
    echo
    exit
fi

# config the CentOS Linux for selinux and firewall
chkconfig iptables off
chkconfig ip6tables off
service iptables stop
service ip6tables stop
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
/usr/sbin/setenforce 0

# config the yum source for in china
if [ ! -f /etc/yum.repos.d/CentOS-Base.repo.bak ]; then
    cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
fi
sed -i 's/^#baseurl/baseurl/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/^mirrorlist/d' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/mirror.centos.org/mirrors.ustc.edu.cn/g' /etc/yum.repos.d/CentOS-Base.repo
yum check-update
yum makecache 
yum update -y 

# set locale
bashprofile=~/.bash_profile
echo export LC_ALL=C >> $bashprofile
source $bashprofile

# wget cacti and spine tarball
which wget > /dev/null 2>&1 || yum install wget -y
mkdir -p /usr/src/cacti
cd /usr/src/cacti
wget -N http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz
wget -N http://www.cacti.net/downloads/spine/cacti-spine-0.8.8b.tar.gz

# install and config httpd
yum install -y httpd
chkconfig httpd on
service httpd start

# install and config mysql-server
yum install -y mysql-server
chkconfig mysqld on
service mysqld start
mysqladmin -u root password dbadmin

# install support software
yum install -y php php-gd php-mysql php-cli php-ldap php-snmp rrdtool net-snmp-utils

# install cacti
cd /usr/src/cacti
tar zxvf cacti-0*.tar.gz
mv -f cacti-0*/* /var/www/html/
sed -i 's/\/cacti\//\//g' /var/www/html/include/global.php
chown -R apache:apache /var/www/html/
service httpd restart

mysql -u root -pdbadmin -e 'CREATE DATABASE `cacti` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;'
mysql -u root -pdbadmin -e "CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'cactiuser';"
mysql -u root -pdbadmin -e 'GRANT ALL PRIVILEGES ON `cacti` . * TO 'cactiuser'@'localhost';'
mysql -u root -pdbadmin -e 'flush privileges;'
mysql -u cactiuser -pcactiuser cacti < /var/www/html/cacti.sql

touch /etc/cron.d/cacti
echo "*/5 * * * * apache php /var/www/html/poller.php > /dev/null 2>&1" > /etc/cron.d/cacti

# install spine
cd /usr/src/cacti
tar zxvf cacti-spine-*.tar.gz
cd cacti-spine-*
yum install -y gcc gcc-c++ libtool net-snmp-devel openssl-devel mysql mysql-devel unzip
aclocal
libtoolize --force
autoheader
autoconf
automake
./configure
make && make install
cp /usr/local/spine/etc/spine.conf.dist  /usr/local/spine/etc/spine.conf

# install plugin
cd /usr/src/cacti
wget http://docs.cacti.net/_media/plugin:settings-v0.71-1.tgz -O settings.tgz
tar zxvf settings*.tgz -C /var/www/html/plugins
wget http://docs.cacti.net/_media/plugin:clog-v1.7-1.tgz -O clog.tgz 
tar zxvf clog*.tgz -C /var/www/html/plugins 
wget http://docs.cacti.net/_media/plugin:monitor-v1.3-1.tgz -O monitor.tgz
tar zxvf monitor*.tgz -C /var/www/html/plugins
wget http://docs.cacti.net/_media/plugin:thold-v0.5.0.tgz -O thold.tgz 
tar zxvf thold*.tgz -C /var/www/html/plugins 
wget http://docs.cacti.net/_media/plugin:realtime-v0.5-2.tgz -O realtime.tgz
tar zxvf realtime*.tgz -C /var/www/html/plugins && mkdir /var/www/html/plugins/realtime/cache
wget http://docs.cacti.net/_media/plugin:ntop-v0.2-1.tgz -O ntop.tgz
tar zxvf ntop*.tgz -C /var/www/html/plugins
wget http://www.network-weathermap.com/files/php-weathermap-0.97c.zip
unzip php-weathermap-0.*.zip -d /var/www/html/plugins/
chown -R apache:apache /var/www/html/plugins


# install ntopng
ifconfig eth1 > /dev/null 2>&1 
if [ $? -eq 0 ]; then
mkdir -p /usr/src/cacti/ntopng
cd /usr/src/cacti/ntopng
wget -N http://mirrors.hust.edu.cn/epel/6/x86_64/GeoIP-1.4.8-1.el6.x86_64.rpm
wget -N http://www.nmon.net/centos/6/x86_64/Packages/ntopng-1.1.2_7299-7299.x86_64.rpm
wget -N http://mirrors.hust.edu.cn/epel/6/x86_64/openpgm-5.1.118-3.el6.x86_64.rpm
wget -N http://mirrors.hust.edu.cn/epel/6/x86_64/redis-2.4.10-1.el6.x86_64.rpm
wget -N http://mirrors.hust.edu.cn/epel/6/x86_64/zeromq3-3.2.4-1.el6.x86_64.rpm
rpm -Uvh *.rpm
chkconfig ntopng on
cp /etc/ntopng/ntopng.conf.sample /etc/ntopng/ntopng.conf
test /usr/local/share/ntopng/httpdocs/geoip || mkdir -p /usr/local/share/ntopng/httpdocs/geoip
cd /usr/local/share/ntopng/httpdocs/geoip
wget -N http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
wget -N http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz
wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz
gunzip *.dat.gz
service ntopng start
else
    echo
    echo You much has at least 2 nic to install ntopng
    echo
fi

echo
echo "####################################################################"
echo
echo Auto install cacti 0.8.8b and spine 0.8.8b on centos 6 x86_64 is
echo
echo All finish!
echo
echo Please access this cacti system at: http://`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' |
cut -d: -f2 | awk '{ print $1}'`
echo
echo "####################################################################"
echo
exit
nationals
Cacti User
Posts: 76
Joined: Wed Aug 27, 2008 5:21 am
Location: China
Contact:

Re: cacti 0.8.8b & spine 0.8.8b @ centos 6 x86_64 install sc

Post by nationals »

use yum to install ntopng:

Code: Select all

cat > /etc/yum.repos.d/ntop.repo <<EOF
[ntop]
name=ntop packages
baseurl=http://rpm.ntop.org/\$releasever/\$basearch/
enabled=1
gpgkey=http://www.nmon.net/centos/RPM-GPG-KEY-deri
EOF
rpm -Uvh http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm 
yum install -y ntopng && chkconfig ntopng on
cp /etc/ntopng/ntopng.conf.sample /etc/ntopng/ntopng.conf
cd /usr/local/share/ntopng/httpdocs/geoip
wget http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
gunzip GeoIPASNum.dat.gz
wget http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNumv6.dat.gz
gunzip GeoIPASNumv6.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCityv6-beta/GeoLiteCityv6.dat.gz
gunzip GeoLiteCityv6.dat.gz
service ntopng start
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests