Mindmajix

Monitoring instances using Munin and Collectd – OpenStack

The health of the underlying infrastructure operating our on-premise cloud solution is important, but of equal importance is to understand the metrics given by the Compute instances themselves. For this, we can get metrics sent from them by using a monitoring tool called Collectd, and we can leverage Munin for an overall view of our running virtual instances.

How to accomplish it…

To set Munin and Collectd up, carry out the following steps:

Munin

We can configure Munin to look at more than just the CPU, memory, and disk space of the host, by invoking the libvirt plugin to query values within the running instances on our Compute hosts:

  • The libvirt munin plugin is conveniently provided by the Ubuntu repositories, so we grab these in the usual way:
sudo apt-get update
sudo apt-get -y install munin-libvirt-plugins
  • Once downloaded, we then configure the munin libvirt plugins on the Compute host:
cd /etc/munin/plugins
sudo ln -s /usr/share/munin/plugins/libvirt-blkstat sudo ln -s /usr/share/munin/plugins/libvirt-ifstat sudo ln -s /usr/share/munin/plugins/libvirt-cputime sudo ln -s /usr/share/munin/plugins/libvirt-mem
  • With the plugins in place, we now need to configure them. This is done by placing a file in /etc/munin/plugin-conf.d/libvirt, with the following contents:
[libvirt*] user root
env.address qemu:///system
env.tmpfile /var/lib/munin/plugin-state/libvirt
  • Once this is done, we restart the munin-node service, and we will see an additional category show up in Munin, named Virtual Machine, where we can then see how much memory, CPU, and disk activity is being consumed as a whole on the host:

Screenshot_755

Collectd

Collectd is set up in three parts. There is a collectd server that listens over UDP for data sent from the clients. There is the client collectd service that sends the data to the collectd server. Finally, there is a web interface to Collectd, named collectd-web that allows easy viewing of the graphs sent from collectd:

Collectd server

  • We first install collectd and the required Perl resources in the usual way from Ubuntu’s repositories:
sudo apt-get update
sudo apt-get -y install collectd libjson-perl
  • Once installed, we configure the service to listen on a port we choose. The configuration of collectd is done in /etc/collectd/collectd.conf. In the following configuration, we listen on UDP port 12345:
Hostname "servername"
Interval      10
ReadThreads 5
LoadPlugin network <Plugin network>
Listen "*" "12345" </Plugin>
LoadPlugin cpu LoadPlugin df LoadPlugin disk LoadPlugin load LoadPlugin memory LoadPlugin processes LoadPlugin swap LoadPlugin syslog LoadPlugin users LoadPlugin interface <Plugin interface>
Interface "eth0" </Plugin> LoadPlugin tcpconns
LoadPlugin rrdtool <Plugin "rrdtool"> CacheFlush 120
WritesPerSecond 50 </Plugin>
Include "/etc/collectd/filters.conf"
Include "/etc/collectd/thresholds.conf"
  • We restart the service to pick up these changes:
sudo service collectd restart

Collectd Client

  • The collectd client and server use the same package, so we install the client in the same way.
sudo apt-get update
sudo apt-get -y install collectd libjson-perl
  • The configuration file for the guest is the same as for the server, but we specify different options. Edit /etc/collectd/collectd.conf with the following contents:
FQDNLookup true
Interval      10
ReadThreads 5 LoadPlugin network <Plugin network>
Server "172.16.0.253" "12345" </Plugin>
LoadPlugin cpu LoadPlugin df LoadPlugin disk LoadPlugin load LoadPlugin memory LoadPlugin processes LoadPlugin swap LoadPlugin syslog LoadPlugin users LoadPlugin interface <Plugin interface>
Interface "eth0" </Plugin>
  • Restart the collectd service to pick up this change:
sudo service collectd restart

Collectd-web

At this point, data is being sent over to the collectd server (at address 172.16.0.253). To view this data, we install another package that can interpret the RRD files and present them in an easy-to-use web interface. We first download collected-web the tarball from the following URL: http://collectdweb.appspot.com/download/

  • We then unpack the archive, as follows:
tar zxvf collectd-web_0.4.0.tar.gz
  • Then, we copy everything over to the web server DocumentRoot directory:
sudo cp -a ./collectd-web /var/www
  • Create or modify the /etc/collectd/collection.conf file with the following contents:
datadir: "/var/lib/collectd/" libdir: "/usr/lib/collectd/"
  • We then run the standalone server that will listen locally for requests from Apache:
cd /var/www/collectd-web
sudo nohup python runserver.py &
  • After this, we edit the vhost file that controls DocumentRoot of our Apache setup (on Ubuntu, this is /etc/apache2/sites-enabled/000-default) to ensure that .htaccess files are understood with the AllowOverride all configuration:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews AllowOverride all
Order allow,deny allow from all
</Directory>
  • We can now simply reload Apache to pick up the changes, as follows:
sudo service apache2 reload
  • Now, we point our web browser to our installation, for example, http://172.16.0.253/collectd-web, to view the collectd stats from the listed servers.

How it works…

Munin has plugins for various monitoring activities, including libvirt. As libvirt is used to manage the running instances on our Compute nodes, they hold an array of information that we can send to Munin to allow us to get a better understanding of what is happening in and on our OpenStack Compute hosts and instances.

Collectd is regarded as one of the standard ways of collecting resource information from servers and instances. It can act as a server and a client, and as such, we use the same installation binaries on both our monitoring host and guests. The difference is in the configuration file, /etc/collectd/collectd.conf. For the server, we specify that we listen on a specific port using the following lines in the server’s configuration file:

<Plugin network> Listen "*" "12345"
</Plugin>

For the client configuration, we specify where we want the data sent to using the following lines in the client’s configuration file:

<Plugin network>
Server "172.16.0.253" "12345" </Plugin>

To bring the two together in a convenient interface to collectd, we install the collectd-web interface that has a standalone service that is used in conjunction with Apache to provide us with the interface.


 

0 Responses on Monitoring instances using Munin and Collectd – OpenStack"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.