Created
July 19, 2013 17:04
-
-
Save ccarrasc/6040727 to your computer and use it in GitHub Desktop.
Script to install graphite locally on CentOs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Add the EPEL repo if not added already | |
yum repolist | grep -i epel | |
if [ $? -ne 0 ]; then | |
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm | |
fi | |
# Install the preqs | |
yum install gcc-c++ httpd python-devel python-pip python-sqlite2 \ | |
memcached pycairo Django django-tagging Twisted \ | |
fontconfig bitmap bitmap-fonts mod_wsgi mod_python git -y | |
# Alias pip | |
PIP=`which pip-python` | |
# TODO: check if it is already installed ('pip show' is only in later versions) | |
$PIP install python-memcached | |
# Install graphite components in /opt/graphite/ | |
$PIP install whisper | |
$PIP install carbon | |
$PIP install graphite-web | |
# Copy example configs | |
cd /opt/graphite/conf | |
cp carbon.conf.example carbon.conf | |
cp storage-schemas.conf.example storage-schemas.conf | |
# Create/Sync with SQLite | |
cd /opt/graphite/webapp/graphite | |
python manage.py syncdb | |
# Create symlink for graphite to write to | |
mv /opt/graphite/storage/ /var/graphite/ | |
ln -s /var/graphite /opt/graphite/storage | |
chcon -Rv --type=httpd_sys_content_t /opt/graphite/storage | |
chcon -Rv --type=httpd_sys_content_t /var/graphite | |
chown -R apache:apache /var/graphite/ | |
# Replace the token @DJANGO@ with the appropriate django path in the apache config | |
DJANGO_ROOT=`find / -name django -type d -print` | |
echo $DJANGO_ROOT | |
cp /opt/graphite/examples/example-graphite-vhost.conf /etc/httpd/conf.d/graphite-vhost.conf | |
sed -i "s|@DJANGO_ROOT@|$DJANGO_ROOT|" /etc/httpd/conf.d/graphite-vhost.conf | |
# Copy the example wsgi config | |
cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi | |
# Restart Apache httpd (at this point, we should be able to browse to http://localhost) | |
apachectl -k restart | |
# Install scons & statsite for udp datagrams | |
cd /opt/ | |
wget http://prdownloads.sourceforge.net/scons/scons-2.3.0.tar.gz | |
tar -xvzf scons-2.3.0.tar.gz | |
rm -f scons-2.3.0.tar.gz | |
cd scons-2.3.0 | |
python ./setup.py install --standard-lib | |
cd /opt/ | |
rm -rf scons-2.3.0 | |
git clone https://github.com/armon/statsite.git | |
cd /opt/statsite/ | |
scons | |
# Create a statsite config | |
cat << 'EOF' > /etc/statsite.conf | |
[statsite] | |
port = 8125 | |
udp_port = 8125 | |
log_level = INFO | |
flush_interval = 10 | |
timer_eps = 0.01 | |
stream_cmd = python /opt/statsite/sinks/graphite.py localhost 2003 | |
EOF | |
# Create the upstart script for statsite | |
cat << 'EOF' > /etc/init/statsite.conf | |
description "Statsite for Graphite" | |
start on started | |
stop on shutdown | |
respawn | |
script | |
exec /opt/statsite/statsite -f /etc/statsite.conf | |
end script | |
EOF | |
# Create the upstart script for carbon-cache | |
cat << 'EOF' > /etc/init/carbon-cache.conf | |
description "Carbon-Cache for Graphite" | |
start on started | |
stop on shutdown | |
respawn | |
script | |
exec /opt/graphite/bin/carbon-cache.py start | |
end script | |
EOF | |
# Enable httpd, carbon-cache, and statsite daemons | |
chkconfig httpd on | |
initctl start carbon-cache | |
initctl start statsite | |
# Open up ports | |
iptables -I INPUT -p tcp --dport 2003 -j ACCEPT | |
iptables -I INPUT -p udp --dport 8125 -j ACCEPT | |
iptables -I INPUT -p tcp --dport 80 -j ACCEPT | |
service iptables save | |
echo "If everything went well, you should be able to browse to http://localhost and see graphite" | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment