This is a continuation of my previous post on how to install Sensu. So I assume that you have a working Sensu environment.

You have Sensu and you want graphics. I only tried with Graphite/Grafana, maybe there are other things you can try but I haven’t.

Make sure you have the Debian backports repository

nano /etc/apt/sources.list
deb wheezy-backports main
To get started, we need to download and install the Graphite components. Graphite is made of several components: the web application (graphite-web), a storage backend called Carbon, and the database library called whisper. During the installation, you will be asked whether you want Carbon to remove the database files if you ever decide to purge the installation. Choose “No” here so that you will not destroy your stats. If you need to start fresh, you can always manually remove the files (kept in var/lib/graphite/whisper).
Now let’s start installing Graphite prerequisites.
apt-get update
apt-get upgrade
apt-get -t wheezy-backports install python-twisted python-twisted-core python-whisper
apt-get -t wheezy-backports install python-flup python-django python-django-tagging
apt-get -y install apache2-mpm-worker libapache2-mod-wsgi python-memcache python-pysqlite2 python-simplejson python-tz python-pyparsing libjs-scriptaculous libjs-jquery libjs-prototype python-pip python-cairo-dev python-cairo python-cairo-dbg python-setuptools python-dev python-cairo python-simplejson  python-tz python-pyparsing libjs-scriptaculous libjs-jquery libjs-prototype git libcairo2-dev libffi-dev linux-tools python-mocker gunicorn
easy_install --upgrade pytz
easy_install whitenoise
easy_install cairocffi
easy_install txAMQP
Configure Graphite & Carbon
cd /opt/graphite/examples
cp example-graphite-vhost.conf /etc/apache2/sites-available/graphite
cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sed -i 's/WSGISocketPrefix run\/wsgi/WSGISocketPrefix \/var\/run\/apache2\/wsgi/g' /etc/apache2/sites-available/graphite
mkdir -p /var/run/apache2/wsgi
a2enmod wsgi
/etc/init.d/apache2 reload
cd /opt/graphite/conf/
cp graphite.wsgi.example graphite.wsgi
cp carbon.conf.example carbon.conf
cp storage-schemas.conf.example storage-schemas.conf
Edit the storage schema and make sure it has the following:
nano /opt/graphite/conf/storage-schemas.conf

pattern = ^stats.*
retentions = 10:2160,60:10080,600:262974

pattern = ^carbon\.
retentions = 60:90d

pattern = .*
retentions = 60s:1d
Edit/create storage aggregation and make sure it has the following:
nano /opt/graphite/conf/storage-aggregation.conf

pattern = \.min$
xFilesFactor = 0.1
aggregationMethod = min

pattern = \.max$
xFilesFactor = 0.1
aggregationMethod = max

pattern = \.count$
xFilesFactor = 0
aggregationMethod = sum

pattern = .*
xFilesFactor = 0.3
aggregationMethod = average
Do some more configs, make sure you change the password to something else:
chown -R www-data:www-data /opt/graphite/storage/
cd /opt/graphite/webapp/graphite
echo "SECRET_KEY = 'your-new-password-here'" >> /opt/graphite/webapp/graphite/
echo "TIME_ZONE = 'Europe/Berlin' " >> /opt/graphite/webapp/graphite/
echo "URL_PREFIX = '/graphite' " >> /opt/graphite/webapp/graphite/
export PATH=$PATH:/usr/lib/python2.7/dist-packages/django/bin
PYTHONPATH=/opt/graphite/webapp/ syncdb --settings=graphite.settings
Operations to perform:
  Synchronize unmigrated apps: url_shortener, account, dashboard, tagging, events
  Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
    Creating table account_profile
    Creating table account_variable
    Creating table account_view
    Creating table account_window
    Creating table account_mygraph
    Creating table dashboard_dashboard_owners
    Creating table dashboard_dashboard
    Creating table dashboard_template_owners
    Creating table dashboard_template
    Creating table events_event
    Creating table url_shortener_link
    Creating table tagging_tag
    Creating table tagging_taggeditem
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying sessions.0001_initial... OK
You have installed Django's auth system, and don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'root'):
Email address:
Password (again):
Superuser created successfully.

Now  execute this:

PYTHONPATH=/opt/graphite/webapp/ collectstatic --settings=graphite.settings
type ‘yes’ and it will start copy a lot of files.
Next, let’s give some permissions:
chown -R www-data:www-data /opt/graphite/storage/
chown -R www-data:www-data /opt/graphite/static/
chown -R www-data:www-data /opt/graphite/webapp/
Now, let’s make Graphite a bit more secure so that not anybody can connect and take a look:
mkdir /opt/graphite/secure
chown -R www-data:www-data /opt/graphite/secure
Create a user for your Graphite login, I am creating the ‘admin’ user here:
htpasswd -c /opt/graphite/secure/.passwd admin
Disable default site, and enable graphite site:
a2dissite default
a2ensite graphite
Now, we are going to edit the graphite file, from apache enabled sites. I have tried out different combinations, this is what worked for me.
First, find your Django root folder:
python -c "
import sys
sys.path = sys.path[1:]
import django
Now, edit the file and put the location you found:
nano /etc/apache2/sites-enabled/graphite
# Enable virtualhosts, perhaps by adding this to your server's config somewhere,
# probably the main httpd.conf
# NameVirtualHost *:80
# This line also needs to be in your server's config.
# LoadModule wsgi_module modules/
# You need to manually edit this file to fit your needs.
# This configuration assumes the default installation prefix
# of /opt/graphite/, if you installed graphite somewhere else
# you will need to change all the occurrences of /opt/graphite/
# in this file to your chosen install location.
<IfModule !wsgi_module.c>
    LoadModule wsgi_module modules/
# XXX You need to set this up!
# Read
# For example, create a directory /var/run/wsgi and use that.
WSGISocketPrefix /var/run/apache2/wsgi

<VirtualHost *:80>
        ServerName <server-ip-here>
        DocumentRoot "/opt/graphite/webapp"
        ErrorLog /opt/graphite/storage/log/webapp/error.log
        CustomLog /opt/graphite/storage/log/webapp/access.log common
        # I've found that an equal number of processes & threads tends
        # to show the best performance for Graphite (ymmv).
        WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
        WSGIProcessGroup graphite
        WSGIApplicationGroup %{GLOBAL}
        WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
        # XXX You will need to create this file! There is a graphite.wsgi.example
        # file in this directory that you can safely use, just copy it to graphite.wgsi
        WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi

        # XXX To serve static files, either:
        # * Install the whitenoise Python package (pip install whitenoise)
        # * Collect static files in a directory by running:
        # collectstatic --noinput --settings=graphite.settings
        #   And set an alias to serve static files with Apache:
        Alias /static/ /opt/graphite/static/

    <Location "/graphite/">
         AuthType Basic
         AuthName "Private Area"
         AuthUserFile /opt/graphite/secure/.passwd
         Require user admin

        # URL-prefixed install #
        # If using URL_PREFIX in local_settings for URL-prefixed install (that is not located at "/"))
        # your WSGIScriptAlias line should look like the following (e.g. URL_PREFX="/graphite"
        # WSGIScriptAlias /graphite /srv/graphite-web/conf/graphite.wsgi/graphite
        # Alias /graphite/static /opt/graphite/webapp/content
        #  <Location "/graphite/static/">
        #        SetHandler None
        # </Location>

        WSGIScriptAlias /graphite /opt/graphite/conf/graphite.wsgi/graphite
        Alias /graphite/static /opt/graphite/webapp/content
          <Location "/graphite/static/">
                SetHandler None

        # XXX In order for the django admin site media to work you
        # must change @DJANGO_ROOT@ to be the path to your django
        # installation, which is probably something like:
        # /usr/lib/python2.6/site-packages/django
        #Alias /media/ "@DJANGO_ROOT@/contrib/admin/media/"

    Alias /media/ "/usr/lib/python2.7/dist-packages/django/contrib/admin/media/"

        # The graphite.wsgi file has to be accessible by apache. It won't
        # be visible to clients because of the DocumentRoot though.
        <Directory /opt/graphite/conf/>
                <IfVersion < 2.4>
                        Order deny,allow
                        Allow from all
                <IfVersion >= 2.4>
                        Require all granted
Restart Carbon and Apache
/opt/graphite/bin/ stop
/opt/graphite/bin/ start
/etc/init.d/apache2 restart
Make Carbon start at boot time
nano /etc/rc.local
/opt/graphite/bin/ stop
/opt/graphite/bin/ start
/etc/init.d/apache2 restart
Test if Graphite is working:
/opt/graphite/bin/ /opt/graphite/
You should see something like this:
Running Graphite from /opt/graphite/ under django development server
/usr/bin/django-admin runserver –pythonpath /opt/graphite/webapp –settings graphite.settings
Performing system checks…
System check identified no issues (0 silenced).
July 06, 2016 – 14:20:59
Django version 1.7.1, using settings ‘graphite.settings’
Starting development server at
Quit the server with CONTROL-C.
If you see something like the above, then your Graphite is working.
Graphite can be tested by opening a browser and accessing :
You can move to downloading and installing Grafana
cd /usr/local/src/
dpkg -i grafana_3.0.4-1464167696_amd64.deb
update-rc.d grafana-server defaults 95 10
service grafana-server start
echo "alias /grafana /usr/share/grafana" > /etc/apache2/sites-enabled/grafana.conf
/etc/init.d/apache2 restart
Edit the /usr/share/grafana/conf/defaults.ini and make sure it is not the same port as Uchiwa. I changed to port 3001
nano /usr/share/grafana/conf/defaults.ini
# The http port  to use
http_port = 3001
Restart grafana service
service grafana-server restart
Open a browser and go to Grafana login page, login with user: admin and pass: admin