Compiling Ganglia gmond and gmetad on OSX 10.5

July 25, 2009 by alex

Ganglia is a set of daemons used for performance monitoring. It works on OSX, but getting it running on that platform can be a bit touchy. Here’s the series of steps which have worked for me recently.

Note : I’m writing this for those who already knows what Ganglia is, and want to get it running on OSX. There are lots of other articles out there describing Ganglia, what it’s used for, and offering more detailed configuration information.

Prep Work

  1. Install Apple’s Developer Tools, so you have a compiler and other necessary stuff. This is on your OSX installation DVDs (with XCode), or you can download from http://developer.apple.com/Tools/.
  2. Install MacPorts from http://www.macports.org/.

Install Ganglia Dependencies

rrdtool is only needed by gmetad. If you are only building gmond, you don’t need it. bash sudo port install rrdtool libconfuse

Build/Install Ganglia

  1. Download the source code from http://sourceforge.net/projects/ganglia/files/.
  2. Check on the status of this bug : http://bugzilla.ganglia.info/cgi-bin/bugzilla/show_bug.cgi?id=168. If it is still not resolved, you will need to patch libmetrics/darwin/metrics.c as instructed. (A patch file is described in the ticket. It’s simple.)
  3. bash ./configure --with-gmetad LDFLAGS="-L/opt/local/lib -L/usr/X11R6/lib" CPPFLAGS="-I/opt/local/include -I/usr/X11R6/include" make sudo make install

Configure Ganglia

  1. Set up the ganglia configuration directory. bash sudo mkdir -p /etc/ganglia/conf.d
  2. Create a default gmond configuration file. Customize as desired. bash sudo gmond -t > /etc/ganglia/gmond.conf
  3. Use the default gmetad config file. Customize as desired. bash cd /your/ganglia/source/directory sudo cp gmetad/gmetad.conf /etc/ganglia
  4. Create default data directory for gmetad’s rrd files. If you locate these elsewhere, make sure to update gmetad.conf. bash sudo mkdir -p /var/lib/ganglia/rrds sudo chown nobody /var/lib/ganglia/rrds

Configure Ganglia Web Frontend

  1. Enable PHP in Apache. It’s already installed. You just need to turn it on. http://www.php.net/manual/en/install.macosx.bundled.php
  2. Copy the Ganglia web frontend to an Apache-accessible directory. My user account is ‘alex’, so I used /Users/alex/Sites/ganglia, which is accessible at http://localhost/~alex/ganglia/. bash cd /your/ganglia/source/directory cp -R web ~/Sites/ganglia
  3. In your new copy of the web code, edit conf.php and change this: php define("RRDTOOL", "/usr/bin/rrdtool"); to php define("RRDTOOL", "/opt/local/bin/rrdtool");

Starting It All Up

  1. I could use some help here. I have written init.d-style startup scripts on various Linux distros, but I’ve never gotten familiar with launchd. My uses for Ganglia on OSX are purely for development and testing, so the following works ok for me… bash sudo /usr/sbin/gmond sudo /usr/sbin/gmetad
  2. Start Apache. This can be done in the ‘Sharing’ pane of ‘System Preferences’. Clicking the checkbox for ‘Web Sharing’ starts up Apache.
  3. Browse to the location where you installed the Ganglia web frontend. You should see the first few minutes of your metrics flowing in.
☙ ☙ ☙