Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luniki/40b2fb1a9a7f0b6632f4 to your computer and use it in GitHub Desktop.
Save luniki/40b2fb1a9a7f0b6632f4 to your computer and use it in GitHub Desktop.
#!/bin/bash
sudo apt-get install python-software-properties libpq-dev
# System level dependencies for Graphite
sudo apt-get install memcached python-dev python-pip
sudo apt-get install postgresql postgresql-client
sudo apt-get install libcairo2 libcairo2-dev python-cairo python-psycopg2
sudo apt-get install pkg-config build-essential
#Create a user and database for graphite:
# sudo -u postgres createuser graphite
# superuser = yes
# sudo -u postgres createdb -O graphite graphite
Change the password of the postgres and graphite users:
# sudo -u postgres psql -d template1
template1=# ALTER USER postgres WITH PASSWORD '<password>';
template1=# ALTER USER graphite WITH PASSWORD '<password>';
# Get latest pip
sudo pip install --upgrade pip
# Install carbon and graphite deps
cat >> /tmp/graphite_reqs.txt << EOF
django==1.5
python-memcached
django-tagging
twisted<12.0
whisper
carbon
graphite-web
EOF
sudo pip install -r /tmp/graphite_reqs.txt
DATABASES = {
'default': {
'NAME': 'graphite',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'graphite',
'PASSWORD': 'XXXXXXXXXXXXXXXX',
'HOST': 'postgres-0.example.com',
'PORT': '5432'
}
}
#
# Configure carbon
#
cd /opt/graphite/conf/
sudo cp carbon.conf.example carbon.conf
# Create storage schema and copy it over
# Using the sample as provided in the statsd README
# https://github.com/etsy/statsd#graphite-schema
cat >> /tmp/storage-schemas.conf << EOF
# Schema definitions for Whisper files. Entries are scanned in order,
# and first match wins. This file is scanned for changes every 60 seconds.
#
# [name]
# pattern = regex
# retentions = timePerPoint:timeToStore, timePerPoint:timeToStore, ...
[stats]
priority = 110
pattern = ^stats\..*
retentions = 10s:6h,1m:7d,10m:1y
EOF
sudo cp /tmp/storage-schemas.conf storage-schemas.conf
# Make sure log dir exists for webapp
sudo mkdir -p /opt/graphite/storage/log/webapp
# Copy over the local settings file and initialize database
cd /opt/graphite/webapp/graphite/
sudo cp local_settings.py.example local_settings.py
sudo python manage.py syncdb # Follow the prompts, creating a superuser is optional
# statsd
cd /opt && sudo git clone git://github.com/etsy/statsd.git
# StatsD configuration
cat >> /tmp/localConfig.js << EOF
{
graphitePort: 2003
, graphiteHost: "127.0.0.1"
, port: 8125
}
EOF
sudo cp /tmp/localConfig.js /opt/statsd/localConfig.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment