Charts on Shinken via Graphite
A graph is a convenient way to see the evolution of a server's metrics. When we think of graph in the linux world, we usually think of Munin. Very powerful solution that I use in some cases. However, the latter has its own agent who will interrogate the target machine in order to obtain the data interpreted in the form of a graph afterwards. When you already have a monitoring server like Shinken, it's like doing the job twice. To overcome this we are going to set up a Graphite server.
The program is made up of three parts.
- Whisper, a database engine
- Carbon, listening server which takes care of inserting the data into the database
- Graphite, web interface in python Django
Installation of Graphite
Installing dependencies
1
|
apt–get install python–cairo python–django–tagging python–twisted python–memcache fontconfig
|
1
2
|
pip install django
pip install zope.interface
|
You also need a web server, with the library allowing you to load a Django program.
1
|
apt–get install apache2 libapache2–mod–wsgi
|
Graphite installation
1
2
3
4
|
pip install https://github.com/graphite–project/ceres/tarball/master
pip install whisper
pip install carbon
pip install graphite–web
|
Setting up the default configuration
1
2
3
|
cd /opt/graphite/conf
cp carbon.conf.example carbon.conf
cp storage–schemas.conf.example storage–schemas.conf
|
Setting up the apache vHost
1
2
3
4
5
6
7
8
9
10
11
|
cd /opt/graphite
cp –a examples/example–graphite–vhost.conf /etc/apache2/sites–available/graphite
cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sed –i s%« @DJANGO_ROOT@/contrib/admin/media/ »%« /usr/share/pyshared/django/contrib/admin/media/ »% /etc/apache2/sites–available/graphite
sed –i ‘s%WSGISocketPrefix run/wsgi/%WSGISocketPrefix /var/run/apache2/wsgi%’ /etc/apache2/sites–available/graphite
a2ensite graphite
|
Warning, if you are on a more recent distribution with a version of Apache greater than 2.4, you must modify the vHost as follows
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<Directory /opt/graphite/conf/>
#Order deny,allow
#Allow from all
Options All
AllowOverride All
Require all granted
</Directory>
<Directory /opt/graphite/webapp>
Options All
AllowOverride All
Require all granted
</Directory>
|
We activate the vHost
1
|
service apache2 reload
|
Database creation
1
2
3
|
cd /opt/graphite/webapp/graphite
python manage.py syncdb
chown –R www–data:www–data /opt/graphite/storage/
|
We launch the Carbon server
1
2
|
cd /opt/graphite/
./bin/carbon–cache.py start
|
Send test data
1
|
echo « carbon.installation.test $RANDOM `date +%s` » | nc –w 1 localhost 2003
|
At this stage we have functional Graphite, if you go to the address of your server in HTTP you should see your test data appear on the web interface.
Junction at Shinken
We install the Graphite module from the Shinken repositories
1
2
3
|
su shinken
shinken install ui–graphite
shinken install graphite
|
We add the graphite-ui module to the WebUI under /etc/shinken/modules/webui.cfg
1
|
modules auth–cfg–password,SQLitedb,ui–graphite
|
We add the graphite module to the broker under /etc/shinken/brokers/broker-master.cfg
1
|
modules webui,graphite
|
We configure the graphite module under /etc/shinken/modules/graphite.cfg
1
2
3
4
5
6
|
define module {
module_name graphite
module_type graphite_perfdata
host localhost
port 2003
}
|
We configure access to the graphite webui under /etc/shinken/modules/ui-graphite.cfg
1
2
3
4
5
6
|
define module {
module_name ui–graphite
module_type graphite–webui
uri http://172.16.10.6 ; ip de votre serveur graphite
templates_path /var/lib/shinken/share/templates/graphite/
}
|
Be careful not to put a slash at the end of the URL, otherwise the links will not work.
And finally we relaunch Shinken to take all this into account.
1
|
/etc/init.d/shinken restart
|
You should now see your graphs in the tab of the same name on the Shinken web interface
On the Graphite web interface, your hosts should also appear.
The “4 hours” tab may not work. This is because the timezone is not the same on the two components.
To adjust the shinken timezone, go to the /etc/shinken/shinken.cfg file
1
|
use_timezone=Europe/Paris
|
And for graphite you have to activate the configuration file by copying the example
1
2
|
cd /opt/graphite/webapp/graphite
cp local_settings.py.example local_settings.py
|
And uncomment the line corresponding to the timezone value
1
|
TIME_ZONE = ‘Europe/Paris’
|