Created
September 6, 2012 21:05
-
-
Save ryanobjc/3660373 to your computer and use it in GitHub Desktop.
package up graphite using fpm
This file contains hidden or 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 | |
VER=0.9.10 | |
HERE=`pwd` | |
apt-get install python-setuptools python-django-tagging python-pysqlite2 python-memcache python-ldap python-django python-cairo-dev | |
wget https://launchpad.net/graphite/0.9/${VER}/+download/graphite-web-${VER}.tar.gz | |
wget https://launchpad.net/graphite/0.9/${VER}/+download/carbon-${VER}.tar.gz | |
wget https://launchpad.net/graphite/0.9/${VER}/+download/whisper-${VER}.tar.gz | |
tar zxvf graphite-web-${VER}.tar.gz | |
tar zxvf carbon-${VER}.tar.gz | |
tar zxvf whisper-${VER}.tar.gz | |
# fpm package up whisper: | |
fpm -v ${VER} -s python -t deb whisper-$VER/setup.py | |
# install whisper... optional? | |
dpkg -i python-whisper_${VER}_all.deb | |
(cd carbon-${VER} ; python setup.py install) | |
(cd graphite-web-${VER} ; python setup.py install) | |
cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf | |
cat >/opt/graphite/conf/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, ... | |
# Carbon's internal metrics. This entry should match what is specified in | |
# CARBON_METRIC_PREFIX and CARBON_METRIC_INTERVAL settings | |
[carbon] | |
pattern = ^carbon\. | |
retentions = 60:90d | |
[everything_1min_13months] | |
priority = 100 | |
pattern = .* | |
retentions = 1m:395d | |
EOF | |
sed -i -e 's/@DJANGO_ROOT@/\/usr\/lib\/python2.7\/dist-packages\/django/' /opt/graphite/examples/example-graphite-vhost.conf | |
cp /opt/graphite/webapp/graphite/local_settings.py.example /opt/graphite/webapp/graphite/local_settings.py | |
echo "MEMCACHE_HOSTS = ['127.0.0.1:11211']" >> /opt/graphite/webapp/graphite/local_settings.py | |
cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi | |
cd /opt/graphite/webapp/graphite | |
echo no | python manage.py syncdb | |
python manage.py createsuperuser --email [email protected] --username spire | |
chown -R www-data:www-data /opt/graphite/storage | |
cat > /etc/init.d/carbon-cache <<EOF | |
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: carbon-cache | |
# Required-Start: $remote_fs $syslog | |
# Resuired-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: | |
# Short-Description: Carbon-Cache | |
### END INIT INFO | |
set -e | |
case "$1" in | |
start) | |
sudo -E -u www-data nohup /opt/graphite/bin/carbon-cache.py start > /opt/graphite/storage/carbon-cache.log 2>&1 < /dev/null & | |
;; | |
stop) | |
sudo -E -u www-data pkill carbon-cache.py | |
;; | |
*) | |
log_action_msg "Usage: /etc/init.d/carbon-cache {start|stop}" || true | |
exit 1 | |
esac | |
exit 0 | |
EOF | |
chmod +x /etc/init.d/carbon-cache | |
# now fpm the whole mess | |
cd $HERE | |
fpm -s dir -t deb -n graphite -v ${VER} --post-install=postinst.sh /etc/init.d/carbon-cache /opt/graphite |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment