Skip to content

Instantly share code, notes, and snippets.

@EButlerIV
Forked from ryanwitt/README.md
Created November 15, 2012 21:16
Show Gist options
  • Save EButlerIV/4081328 to your computer and use it in GitHub Desktop.
Save EButlerIV/4081328 to your computer and use it in GitHub Desktop.
Installing graphite 0.9.10 and statsd on Amazon Linux

Installing

If you trust me, do this:

curl https://raw.github.com/gist/4081328/da26b5ce3fefab63e7cf145f816ac0b3b82ac8b0/install.sh > install.sh
sh install.sh
#!/bin/bash
#
# Carbon (part of Graphite)
#
# chkconfig: 3 50 50
# description: Carbon init.d
. /etc/rc.d/init.d/functions
prog=carbon
RETVAL=0
start() {
echo -n $"Starting $prog: "
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py start
RETVAL=$?
if [ $RETVAL = 0 ]; then
success "carbon started"
else
failure "carbon failed to start"
fi
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py stop > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL = 0 ]; then
success "carbon stopped"
else
failure "carbon failed to stop"
fi
echo
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
PYTHONPATH=/usr/local/lib/python2.6/dist-packages/ /opt/graphite/bin/carbon-cache.py status
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
#!/bin/bash
sudo yum groupinstall -y "Development tools"
sudo yum install -y --enablerepo=epel python-devel.noarch pycairo.x86_64 Django.noarch django-tagging.noarch python-twisted.noarch python-zope-interface.x86_64 fontconfig.x86_64 fontconfig-devel.x86_64 mod_wsgi.x86_64 python-pip.noarch htop dstat
sudo pip-python install whisper carbon graphite-web
sudo chkconfig httpd on
sudo cp /opt/graphite/conf/carbon.conf.example /opt/graphite/conf/carbon.conf
sudo cp /opt/graphite/conf/storage-schemas.conf.example /opt/graphite/conf/storage-schemas.conf
sudo echo > /opt/graphite/conf/storage-schemas.conf << EOF
[carbon]
pattern = ^carbon\.
retentions = 60:90d
[stats]
pattern = ^.*
retentions = 10s:6h,1m:7d,10m:1y,1d:10y
EOF
sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sudo cp /opt/graphite/examples/example-graphite-vhost.conf /etc/httpd/conf.d/graphite.conf
sudo cp /opt/graphite/webapp/graphite/local_settings.py.example /opt/graphite/webapp/graphite/local_settings.py
echo "Creating graphite db..."
sudo python /opt/graphite/webapp/graphite/manage.py syncdb
sudo chown -R apache:apache /opt/graphite/storage/
echo "Create superuser for graphite app:"
sudo python /opt/graphite/webapp/graphite/manage.py createsuperuser stats
sudo wget -O /etc/init.d/carbon https://raw.github.com/gist/4081328/6978bda604c794e21165a81c6b879528d19e8bb4/carbon.init.sh
sudo chmod 0755 /etc/init.d/carbon
sudo chkconfig --add carbon
sudo /opt/graphite/bin/carbon-cache.py start
sudo /etc/init.d/httpd start
sudo yum localinstall -y --nogpgcheck http://nodejs.tchol.org/repocfg/amzn1/nodejs-stable-release.noarch.rpm
sudo yum install -y nodejs-compat-symlinks npm
cd /opt
sudo git clone git://github.com/etsy/statsd.git
cd statsd
#sudo cp exampleConfig.js local.js
echo > /opt/statsd/local.js << EOF
{
graphitePort: 2003
, graphiteHost: "localhost"
}
EOF
sudo wget -O /etc/init.d/statsd https://raw.github.com/gist/4081328/d79bab965d3576b6defe86cf42c7304343f49239/statsd.init.sh
sudo chmod 0755 /etc/init.d/statsd
sudo chkconfig --add statsd
sudo /etc/init.d/statsd start
dstat -cdgilmnprsTy --output /tmp/monitor.csv
#!/bin/bash
#
# StatsD
#
# chkconfig: 3 50 50
# description: StatsD init.d
. /etc/rc.d/init.d/functions
prog=statsd
STATSDDIR=/opt/statsd
statsd=./stats.js
LOG=/var/log/statsd.log
ERRLOG=/var/log/statsderr.log
CONFFILE=${STATSDDIR}/local.js
pidfile=/var/run/statsd.pid
lockfile=/var/lock/subsys/statsd
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
start() {
echo -n $"Starting $prog: "
cd ${STATSDDIR}
# See if it's already running. Look *only* at the pid file.
if [ -f ${pidfile} ]; then
failure "PID file exists for statsd"
RETVAL=1
else
# Run as process
/usr/bin/node ${statsd} ${CONFFILE} >> ${LOG} 2>> ${ERRLOG} &
RETVAL=$?
# Store PID
echo $! > ${pidfile}
# Success
[ $RETVAL = 0 ] && success "statsd started"
fi
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${pidfile}
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} ${prog}
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment