Wednesday, 15 May 2013

Monitoring Clouds with Ganglia- Part 2

Monitoring Cloud Instances with Ganglia

In the PREVIOUS POST we had a brief look at Ganglia and its architecture. In this post, we are going to set up Ganglia's gmond and gmetad daemons along with its Web interface.
Setup Architecture

In this setup, I am going to be installing both the gmond and gmetad components on the same machine. You can follow the same steps for setting up a Ganglia cluster containing gmetad on one machine and gmond on multiple servers that you wish to monitor. Just follow the steps and you should do just fine :-)

Installation Procedure

STEP 1: Installing Prerequisites

NOTE: Make sure you have internet access and are performing these commands using root or equivalent privileges.

# yum install gcc gcc-c++ autoconf automake expat-devel libconfuse-devel rrdtool rrdtool-devel apr-devel libconfuse

Download and compile pcre

# wget

# tar zxvf pcre-8.32.tar.gz
# cd pcre-8.32

# ./configure
# make
# make install

STEP 2: Installing Ganglia

Download and compile the latest Ganglia release. 

NOTE: The machine running gmetad should be compiled with --with-gmetad option enabled. Rest of your servers need not be compiled with this option unless you plan to run gmetad daemon on them.

# wget

# tar zxvf ganglia-3.5.0.tar.gz

# cd ganglia-3.5.0
# ./configure --sysconfdir=/etc/ganglia/ --sbindir=/usr/sbin/ --with-gmetad --enable-static-build
# make
# make install

STEP 3: Install gmond daemon

Generate the gmond config file

# gmond --default_config > /etc/ganglia/gmond.conf

You may get the following error on executing the above statement:

'gmond: error while loading shared libraries: cannot open shared object file: No such file or directory'

Run the following command to create a symlink and then try again:

# ln -s /lib64/ /lib64/
# gmond --default_config > /etc/ganglia/gmond.conf

Open the gmond configuration file in a text editor of your choice. Here, I am using vi editor:

# vi /etc/ganglia/gmond.conf

Provide a suitable name to your Ganglia Cluster. Here, I am providing the name as ''

cluster {
name = ""
owner = "unspecified"
latlong = "unspecified"
url = "unspecified"

Once done editing, save the file and exit the vi editor.

Copy the init scripts and start the gmond service

# cd ganglia-3.5.0/gmond
# cp gmond.init /etc/init.d/gmond
# /etc/init.d/gmond start
# chkconfig --add gmond
# chkconfig gmond on

STEP 4: Installing gmetad daemon

We now create a folder for storing the generated rrd files and provide it the necessary permissions as well:

# mkdir -p /var/lib/ganglia/rrds/
# chown nobody:nobody /var/lib/ganglia/rrds/

Once done, we now copy the init files for gmetad:
# cd ganglia-3.5.0/gmetad
# cp gmetad.init /etc/init.d/gmetad
# vi /etc/init.d/gmetad

Comment the line starting with daemon and add the following line next to it as shown:

# daemon $GMETAD
($GMETAD -c /etc/ganglia/gmetad.conf -d 1 > /dev/null 2>&1 ) &

Start the gmetad process

# /etc/init.d/gmetad start
# chkconfig --add gmetad
# chkconfig gmetad on

With this, your Ganglia gmond and gmetad services are now running.

STEP 5: Install Ganglia Web UI

To install the web interface, we first install apache httpd and php:

# yum install httpd php

You can download the Ganglia Web interface from its sourceforge repository (as shown below), untar it in the required folder and install it out.

# wget
# tar zxvf ganglia-web-3.5.7.tar.gz
# mv ganglia-web-3.5.7 /var/www/html/ganglia
# cd /var/www/html/ganglia
# make install

Once done, you need to start the httpd service if its not started up already

# service httpd start

You can now browse to the Ganglia Web UI using a Web Browser. Type in the following in the address bar:


Et voila... you should have your Ganglia Web interface up and displaying the state of your monitored servers as shown

NOTE: For setting up gmond on the rest of your servers, all you ned to follow are STEPS 1, 2 and 3 as described above. Also, remember to maintain the Cluster Name (specified in STEP 3) across your gmond servers that belong to the same cluster.

That's it for now.. stay tuned for more such guides coming your way shortly !!