Skip to content
Go to file
Latest commit 80254f4 Mar 29, 2020 History
9 contributors

Users who have contributed to this file

@obfuscurity @deniszh @Dispader @mathyourlife @colini @CMihalcik @CarlFK @b @arska
executable file 146 lines (121 sloc) 5.11 KB
#!/bin/bash -ex
# Graphite installation script for Ubuntu 18.04
# Jason Dixon <>
SYNTHESIZE_HOME=$( cd "$( dirname "$0" )" && pwd )
UBUNTU_RELEASE=`lsb_release -a 2>/dev/null | grep '^Descrip' | cut -s -f 2`
if [ -z $GRAPHITE_RELEASE ]; then
if [ -z $STATSITE_RELEASE ]; then
if [[ ! $UBUNTU_RELEASE =~ 'Ubuntu 18.04' ]]; then
echo "Sorry, this is only supported for Ubuntu Linux 18.04."
exit 1
if [[ -d $GRAPHITE_HOME ]]; then
echo "Looks like you already have a Graphite installation in ${GRAPHITE_HOME}, aborting."
exit 1
# Update apt since the vagrant image might be old
apt-get update -y
# Install package dependencies from apt
RUNLEVEL=1 apt-get install -y git wget curl netbase collectd memcached \
build-essential automake libtool libffi-dev libcairo2-dev libcairo2 libffi6 \
python3-dev python3-pip fontconfig apache2 libapache2-mod-wsgi-py3
# Download source repositories for Graphite/Carbon/Whisper and Statsite
cd /usr/local/src
git clone
git clone
git clone
git clone
# Build and install Graphite/Carbon/Whisper and Statsite
mkdir -p /opt/graphite
cd whisper; \
git checkout ${GRAPHITE_RELEASE}; \
python3 install
cd ../carbon; \
git checkout ${GRAPHITE_RELEASE}; \
pip3 install -r requirements.txt; \
python3 install
cd ../graphite-web; \
pip3 install django==2.2.9; \
git checkout ${GRAPHITE_RELEASE}; \
pip3 install -r requirements.txt; \
python3; \
python3 install
cd ../statsite; \
git checkout ${STATSITE_RELEASE}; \
./; \
./configure; make; \
cp statsite /usr/local/sbin/; \
cp sinks/ /usr/local/sbin/
# Update txamqp to support RabbitMQ 2.4+
# also install service_identity to remove TLS error
pip3 install txamqp service_identity --upgrade
# Install configuration files for Graphite/Carbon and Apache
cp ${SYNTHESIZE_HOME}/templates/statsite/statsite.conf /etc/statsite.conf
mkdir ${GRAPHITE_CONF}/examples
mv ${GRAPHITE_CONF}/*.example ${GRAPHITE_CONF}/examples/
cp ${SYNTHESIZE_HOME}/templates/graphite/conf/* ${GRAPHITE_CONF}/
cp ${SYNTHESIZE_HOME}/templates/collectd/collectd.conf /etc/collectd/
cp ${SYNTHESIZE_HOME}/templates/apache/graphite.conf /etc/apache2/sites-available/
# using systemd units instead of init and upstart files
cp ${SYNTHESIZE_HOME}/templates/systemd/* /etc/systemd/system/
# installing scripts for carbon-cache instances control script
cp ${SYNTHESIZE_HOME}/templates/scripts/* /usr/local/bin/
# Setup the correct Apache site and modules
a2dissite 000-default
a2ensite graphite
a2enmod ssl
a2enmod socache_shmcb
a2enmod rewrite
# Install configuration files for Django
cd ${GRAPHITE_HOME}/webapp/graphite
cp ${SYNTHESIZE_HOME}/templates/graphite/webapp/* .
sed -i -e "s/UNSAFE_DEFAULT/`date | md5sum | cut -d ' ' -f 1`/"
# Setup the Django database
PYTHONPATH=${GRAPHITE_HOME}/webapp migrate --noinput --settings=graphite.settings --run-syncdb
PYTHONPATH=${GRAPHITE_HOME}/webapp collectstatic --noinput --settings=graphite.settings
# Add carbon system user and set permissions
groupadd -g 998 carbon
useradd -c "carbon user" -g 998 -u 998 -s /bin/false carbon
chown www-data:carbon ${GRAPHITE_STORAGE}
chown www-data:www-data ${GRAPHITE_STORAGE}/graphite.db
chown -R carbon ${GRAPHITE_STORAGE}/whisper
mkdir -p ${GRAPHITE_STORAGE}/log/carbon-cache/
chown -R carbon ${GRAPHITE_STORAGE}/log
mkdir ${GRAPHITE_STORAGE}/log/apache2
chown -R www-data ${GRAPHITE_STORAGE}/log/webapp
# Setup hourly systemd timer to rebuild Graphite index
cp ${SYNTHESIZE_HOME}/templates/scripts/graphite-build-index /usr/local/bin/graphite-build-index
systemctl daemon-reload
systemctl enable graphite-build-index.timer
systemctl start graphite-build-index.timer
systemctl start graphite-build-index
# Install Grafana
apt-get install -y apt-transport-https
apt-get install -y software-properties-common wget
wget -q -O - | sudo apt-key add -
add-apt-repository "deb stable main"
apt-get install grafana
# Bootstrap Grafana datasources and dashboards
mkdir -p /etc/grafana/provisioning/datasources/
mkdir -p /etc/grafana/provisioning/dashboards/
cp ${SYNTHESIZE_HOME}/templates/grafana/provisioning/datasources/* /etc/grafana/provisioning/datasources/
cp ${SYNTHESIZE_HOME}/templates/grafana/provisioning/dashboards/* /etc/grafana/provisioning/dashboards/
systemctl restart grafana-server
# Enabling processes start
/usr/local/bin/carbon-cache enable
systemctl enable statsite
systemctl enable grafana-server
# Start our processes
/usr/local/bin/carbon-cache start
service memcached restart
service collectd restart
service apache2 restart
service statsite restart
You can’t perform that action at this time.