Issue
Monitoring performance and utilization of switches running Cumulus Linux is imperative in an operational data center environment. graphite
provides scalable real time graphing. collectd
is a powerful tool for gathering metrics using its wide range of plugins, such as CPU, disk, load, memory, and interface statistics. collectd
can be used to place statistics in a database and collectd-graphite
is a plugin that runs inside the collectd
process and sends collectd
data to a graphite
instance for graphing.
The following document explains how to do the following tasks:
- Install
collectd
on a Debian host - Install
collectd
on a Cumulus Linux switch - Install
graphite
on a Debian host
Solution
Installing collectd on a Debian Host
Before you install collectd
, you need to have Debian installed on a server or virtual machine. You must install sudo
before running through the installation steps.
1. Use apt-get
to install collectd
:
sudo apt-get –y install collectd
2. Update the /etc/collectd/collectd.conf
file and replace <<<$HOSTNAME>>>
with the hostname of the server where you are installing collectd
:
Hostname <<<$HOSTNAME>>> FQDNLookup true #BaseDir "/var/lib/collectd" #PluginDir "/usr/lib/collectd" #TypesDB "/usr/share/collectd/types.db" "/etc/collectd/my_types.db" Interval 10 Timeout 2 ReadThreads 5 Include "/etc/collectd/conf.d"
3. Create a file called /etc/collectd/conf.d/network.conf
with the following contents:
vim /etc/collectd/conf.d/network.conf LoadPlugin network <Plugin network> <Listen "10.99.0.1" "25826"> SecurityLevel None Interface eth1 </Listen> Forward false ReportStats true </Plugin>
4. Create a file called /etc/collectd/conf.d/syslog.conf
with the following contents:
vim /etc/collectd/conf.d/syslog.conf LoadPlugin syslog <Plugin syslog> LogLevel info </Plugin>
5. Restart collectd
to incorporate all the modifications to the collectd modules:
service collectd restart
Installing collectd on a Cumulus Linux Switch
You will need a switch running Cumulus Linux. You must install sudo
before running through the installation steps.
While these steps seem identical to installing collectd on a Debian server, the configuration is slightly different.
1. Use apt-get
to install collectd-core
:
sudo apt-get –y install collectd-core
2. Update the /etc/collectd/collectd.conf
file and replace <<<$HOSTNAME>>>
with the hostname of the server where you are installing collectd
:
Hostname <<<$HOSTNAME>>> FQDNLookup true #BaseDir "/var/lib/collectd" #PluginDir "/usr/lib/collectd" #TypesDB "/usr/share/collectd/types.db" "/etc/collectd/my_types.db" Interval 10 Timeout 2 ReadThreads 5 Include "/etc/collectd/conf.d"
3. Create a file called
with the following contents:/etc/collectd/conf.d/
network.conf
vim /etc/collectd/conf.d/network.conf LoadPlugin network <Plugin network> <Server "10.1.1.101" "25826"> SecurityLevel None Interface eth0 </Server> MaxPacketSize 1024 Forward true ReportStats true </Plugin>
4. Create a file called /etc/collectd/conf.d/syslog.conf
with the following contents:
vim /etc/collectd/conf.d/syslog.conf LoadPlugin syslog <Plugin syslog> LogLevel info </Plugin>
5. Restart collectd
to incorporate all the modifications to the collectd
modules:
service collectd restart
Installing and Configuring graphite on a Debian Host
Installing graphite requires the installation of a number of packages on the Debian host. Then you have to configure Apache and some runtime state directories it uses, followed by some security settings. Then you're ready to start up the collector.
Before you install graphite
, you need to have Debian installed on a server or virtual machine. You must install sudo
before running through the installation steps.
1. Download the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies. And then upgrade any previously installed packages and/or related dependencies.
sudo apt-get update sudo apt-get upgrade
2. Install the following packages:
sudo apt-get install -y apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common python2.7 python-pip python-cairo python-django python-django-tagging libapache2-mod-wsgi python-twisted python-memcache python-pysqlite2 python-simplejson vim
3. Use Python's pip
to install the latest versions of whisper
, carbon
, and graphite
:
pip install whisper pip install carbon pip install graphite-web
4. Configure graphite
. Set up a vhost
by copying the example provided by Graphite in their repo. In this file, provide the URL used to access to your graphite
dashboard:
cd /opt/graphite/examples sudo cp example-graphite-vhost.conf /etc/apache2/sites-available/graphite.conf sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
5. Replace the WSGISocketPrefix value in the Apache vhost
section with the following:
sed -i 's/WSGISocketPrefix run\/wsgi/WSGISocketPrefix \/var\/run\/apache2\/wsgi/g' /etc/apache2/sites-available/graphite.conf
6. WSGIImportScript cannot occur within the <VirtualHost>
section if this path does not exist. So, create the directory structure:
sudo mkdir /var/run/apache2 sudo mkdir /var/run/apache2/wsgi sudo /etc/init.d/apache2 reload
7. Enable the wsgi
Apache module:
a2enmod wsgi
8. Create the graphite
configuration files for graphite wsgi,
carbon
and storage-schemas
by copying the example configuration files to their correct filenames:
cd /opt/graphite/conf/ cp graphite.wsgi.example graphite.wsgi cp carbon.conf.example carbon.conf cp storage-schemas.conf.example storage-schemas.conf
9. Edit storage-schemas.conf
to include a custom tweak provided by stats.d
:
vim /opt/graphite/conf/storage-schemas.conf
Then copy and paste the following parameters into storage-schemas.conf
:
[stats] pattern = ^stats.* retentions = 10:2160,60:10080,600:262974 [carbon] pattern = ^carbon\. retentions = 60:90d [default_1min_for_1day] pattern = .* retentions = 60s:1d
10. Create a file called /opt/graphite/conf/storage-aggregation.conf
:
vim /opt/graphite/conf/storage-aggregation.conf
Then copy and paste the following parameters into /opt/graphite/conf/storage-aggregation.conf
:
[min] pattern = \.min$ xFilesFactor = 0.1 aggregationMethod = min [max] pattern = \.max$ xFilesFactor = 0.1 aggregationMethod = max [sum] pattern = \.count$ xFilesFactor = 0 aggregationMethod = sum [default_average] pattern = .* xFilesFactor = 0.3 aggregationMethod = average
11. Set the ownership on the directory /opt/graphite/storage/
:
chown -R www-data:www-data /opt/graphite/storage/ cd /opt/graphite/webapp/graphite sudo cp local_settings.py.example local_settings.py
12. Add a secret key password to /opt/graphite/webapp/graphite/local_settings.py
:
echo "SECRET_KEY = 'newpw'" >> /opt/graphite/webapp/graphite/local_settings.py
13. Configure Apache:
cd /opt/graphite/webapp/graphite python manage.py syncdb
Now enter your username and password.
user@debian3:/opt/graphite/webapp/graphite# python manage.py syncdb 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 events_event Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating table django_session Creating table django_admin_log Creating table django_content_type Creating table tagging_tag Creating table tagging_taggeditem You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): yes Please enter either "yes" or "no": yes Username (leave blank to use 'user'): E-mail address: user@cumulusnetworks.com Password: Password (again): Superuser created successfully. Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s)
14. Enable the graphite
host:
a2ensite graphite
15. Restart Apache to read the new configuration changes:
/etc/init.d/apache2 restart
16. Restart carbon-cache
:
/opt/graphite/bin/carbon-cache.py stop /opt/graphite/bin/carbon-cache.py start
17. Restart Apache to read the new configuration changes:
/etc/init.d/apache2 restart
18. Start graphite
:
/opt/graphite/bin/run-graphite-devel-server.py /opt/graphite/
Related Links
- Main page: http://graphite.wikidot.com/
- Install page: http://graphite.wikidot.com/installation
collectd-graphite
plugin: http://joemiller.me/2011/04/14/collectd-graphite-plugin/
Hi Team,
I found some problem about `a2ensite graphite`
It is work well below:
```
sudo cp example-graphite-vhost.conf /etc/apache2/sites-available/graphite
```
change to
```
sudo cp example-graphite-vhost.conf /etc/apache2/sites-available/graphite.conf
```
Thanks for letting us know, Phil. I updated the article.