Skip to content

Instantly share code, notes, and snippets.

@daniellawrence
Created October 24, 2012 14:03
Show Gist options
  • Save daniellawrence/3946215 to your computer and use it in GitHub Desktop.
Save daniellawrence/3946215 to your computer and use it in GitHub Desktop.
Installing graphite on a fresh ubuntu server.
#!/bin/bash
################################################################################
# Quick script to get graphite up and going on a freshly installed ubuntu server
# Don't use this in production, this for purely for testing and play boxes.
# Written by: Daniel@danielscottlawrence.com
################################################################################
GRAPHITE_URL="https://github.com/graphite-project/graphite-web/zipball/master"
GRAPHITE_ZIP="graphite-web-latest.zip"
CARBON_URL="https://github.com/graphite-project/carbon/zipball/master"
CARBON_ZIP="carbon-latest.zip"
if [[ "$( /usr/bin/whoami )" != "root" ]]; then
echo "This script must be run as root or using sudo."
exit 1
fi
if [[ -f /opt/graphite ]];then
echo "This will delete everything under /opt/graphite"
echo -n "Type DELETE to continue: "
read TEXT
if [[ ${TEXT} != "DELETE" ]];then
echo "You didn't type 'DELETE'"
echo "exiting...."
exit 2
fi
rm -rf /opt/graphite
fi
apt-get install -y python-pip python-dev zip python-cairo git wget
if [[ ! -f "${GRAPHITE_ZIP}" ]];then
echo "Downloading ${GRAPHITE_ZIP}"
wget -O ${GRAPHITE_ZIP} ${GRAPHITE_URL}
fi
if [[ ! -f "${CARBON_ZIP}" ]];then
echo "Downloading ${CARBON_ZIP}"
wget -O "${CARBON_ZIP}" https://github.com/graphite-project/carbon/zipball/master
fi
# -------------------------------------------------------------------
# install carbon
# -------------------------------------------------------------------
unzip -o "${CARBON_ZIP}"
cd graphite-project-carbon*
pip install -r requirements.txt
python ./setup.py install
cd ..
# -------------------------------------------------------------------
# install graphite-web
# -------------------------------------------------------------------
unzip -o "${GRAPHITE_ZIP}"
cd graphite-project-graphite-web-*
mv requirements.txt requirements.txt.backup
grep -v cairographics requirements.txt.backup > requirements.txt
echo "git+git://github.com/graphite-project/ceres.git#egg=ceres" >> requirements.txt
pip install -r requirements.txt
python ./setup.py install
# -------------------------------------------------------------------
# Setup carbon
# -------------------------------------------------------------------
cd /opt/graphite/conf
mv carbon.conf{.example,}
mv storage-schemas.conf{.example,}
# -------------------------------------------------------------------
# start carbon
# -------------------------------------------------------------------
/opt/graphite/bin/carbon-cache.py start
# -------------------------------------------------------------------
# Setup webapp
# -------------------------------------------------------------------
cd /opt/graphite/webapp/graphite/
mv local_settings.py{.example,}
python ./manage.py syncdb --noinput
python ./manage.py createsuperuser --username="graphite" --email="graphite@localhost.com" --noinput
# -------------------------------------------------------------------
# start graphite web
# -------------------------------------------------------------------
gunicorn_django -b 0.0.0.0:8000 -D
# -------------------------------------------------------------------
# Let the user know its done...
# -------------------------------------------------------------------
IP=$( ifconfig | awk '$2 !~ /127.0.0.1/ && /addr:[0-2]/ {print $2}' | cut -d: -f2 | head -1 )
clear
cat << EOF
---------------------------------------------------------------------
Graphite Installed
---------------------------------------------------------------------
Open up the following link to visit you newly installed graphite dashboard:
http://${IP}:8000/dashboard
---------------------------------------------------------------------
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment