Skip to content

Instantly share code, notes, and snippets.

@nilesh1013
Forked from bohde/graphite_pip_uwsgi_recipe.sh
Last active December 18, 2015 16:29
Show Gist options
  • Save nilesh1013/5811704 to your computer and use it in GitHub Desktop.
Save nilesh1013/5811704 to your computer and use it in GitHub Desktop.
# install pip first so that you can install virtual environment with that
sudo apt-get install python-pip
# Install virtual environment first.
sudo pip install virtualenv
# graphite-web install is hardcoded in setup.cfg to /opt/graphite
sudo mkdir /opt/graphite
sudo chown brad.users /opt/graphite
# run under python2.7 virtualenv
virtualenv --python=python2.7 ~/ve/graphite
source ~/ve/graphite/bin/activate
# install the necessary python packages (simplejson is for flot graphs)
pip install graphite-web carbon whisper django django-tagging uwsgi simplejson
#if you getting following error while installing uwsgi (you need a C compiler to build uWSGI)
sudo apt-get install python2.7-dev
and then pip install uwsgi
# use example configurations
cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf
cp /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf/storage-schemas.conf
# feed carbon 1000 random data points at 90 second intervals
perl -e '$ts = time(); for (1..1000) { printf "foo.bar %d %d\n", int(rand(10000)), $ts - 90 * $_ }' \
| nc -c localhost 2003
# make sure the database gets created
(cd /opt/graphite/webapp/graphite; python manage.py syncdb)
#at this point you might get few following errors:
#1- Could not import graphite.local_settings, using defaults!
#For this copy the local-settings example file to local-settings.py
cp /opt/graphite/local_settings.py.example /opt/graphite/local_settings.py
#2- django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
#For this make sure to set the secret key in /opt/graphite/webapp/graphite/app_settings.py
#3- ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings #documentation for more details.
#put the sqlite settings in django's local_settings.py, they might be there commented, just uncomment them.
# start graphite-web under uwsgi using built-in http server on port 8085
$HOME/ve/graphite/bin/uwsgi --http localhost:8085 --master --processes 4 --home $HOME/ve/graphite --pythonpath /opt/graphite/webapp/graphite --wsgi-file=/opt/graphite/conf/graphite.wsgi.example
# view a graph of the random data
firefox http://localhost:8085/render/?width=800&height=600&target=foo.bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment