Skip to content

Instantly share code, notes, and snippets.

@memosanchez
Forked from emilisto/config.js
Created March 12, 2014 22:13
Show Gist options
  • Save memosanchez/9517596 to your computer and use it in GitHub Desktop.
Save memosanchez/9517596 to your computer and use it in GitHub Desktop.
{
graphitePort: 2003,
graphiteHost: "localhost",
port: 8125,
backends: [ "./backends/graphite" ]
}
upstream django {
server unix:/tmp/uwsgi-graphite.sock;
}
server {
server_name graphite-local.shootitlive.com;
listen 80;
location / {
include uwsgi_params;
uwsgi_pass django;
}
}
[uwsgi]
vacuum = true
master = true
processes = 8
pidfile = /tmp/uwsgi-graphite.pid
socket = /tmp/uwsgi-graphite.sock
chmod-socket = 666
gid = graphite
uid = graphite
pythonpath = /opt/graphite/webapp
pymodule-alias = graphite.local_settings=/opt/graphite/webapp/graphite/local_settings.py
module = wsgi
buffer-size = 65536
sudo adduser graphite
sudo mkdir /opt/graphite
sudo chown graphite:graphite /opt/graphite
cd /opt/graphite
virtualenv env
source env/bin/activate
# Download files from this gist to $(pwd)
pip install -r requirements.txt
# pip install pycairo doesn't work because "cairo doesn't use setup tools",
# wtf? Well, we'll just have to resort to this kind of idiocy to get a simple
# standard package set up.
pushd /tmp
sudo apt-get install libcairo2-dev
curl http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2 | tar xvj
cd py2cairo-1.10.0
./waf configure --prefix=/opt/graphite/env
./waf build && ./waf install
popd
pip install graphite-web carbon
pushd webapp/graphite
cp local_settings.py{.example,}
echo "SECRET_KEY='$(tr -dc "[:alpha:]" < /dev/urandom | head -c 15)'" >> app_settings.py
echo "$(cat <<EOF
ALLOWED_HOSTS = [ "*" ]
DATABASES = {
"default": {
"NAME": "/opt/graphite/storage/graphite.db",
"ENGINE": "django.db.backends.sqlite3"
}
}
EOF
)" > local_settings.py
echo "$(cat <<EOF
#This is the wsgi target that lives under the webapp subdirectory
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
EOF
)" > wsgi.py
python manage.py syncdb
# Answer questions and provide a default password, it will be used to login to
# graphite-web.
popd
pushd conf
cp carbon.conf{.example,} && cp storage-schemas.conf{.example,}
echo "$(cat <<EOF
[stats]
priority = 110
pattern = .*
retentions = 10:2160,60:10080,600:262974
EOF
)" >> storage-schemas.conf
popd
# This one should prolly be added to an init script of some sort if this is a
# production environment.
bin/carbon-cache.py start
# If you used the supervisor scripts
sudo supervisorctl update
sudo supervisorctl status
# Make sure statsd and graphite are running
# Send a count event to statsd
echo -n "iam.the.walrus:1|g" | nc -w 1 -u 127.0.0.1 8125
# Time for test, go to the URL you configured nginx to serve graphite-web at
Django==1.5.1
Twisted==13.0.0
argparse==1.2.1
distribute==0.6.24
django-tagging==0.3.1
txAMQP==0.6.2
uWSGI==1.9.13
whisper==0.9.10
wsgiref==0.1.2
zope.interface==4.0.5
[program:graphite]
command=/opt/graphite/env/bin/uwsgi --ini graphite-uwsgi.ini
directory=/opt/graphite
user=graphite
environment=PATH="/opt/graphite/env/bin"
[program:statsd]
command=statsd statsd-config.js
directory=/opt/graphite
user=graphite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment