November 11, 2013

Compiling Ganglia on AIX

I would like to share with my experience of compiling Ganglia v3.5.0 (and its dependencies) on AIX 6100-08-01.

Getting official help

If you are a new user, deploying ganglia for the first time, take a look at the

Let’s begin!

We will create and work in the /usr/local/src/ and /usr/local/src/deps/ directories.

Ganglia packages we will use are:

  • ganglia-3.5.0.tar.gz – ganglia monitor core (gmond, gmetad, PHP web frontend, gmetric, gstat, libganglia)
  • ganglia-web-3.5.7.tar.gz – Ganglia Web 2 (gweb2) is a refresh of the Ganglia PHP UI. Support

You can download them from Ganglia Download Page

Space requirements
  • Less than 1.5 GB of available space needed on the FS you are compiling the Ganglia.
Dependencies
  • C/C++ Compiler will be installed from the AIX Toolbox for Linux Applications

  • Ganglia (gmond & gmetad) dependencies are: PCRE, APR, APR-util, APR iconv, libConfuse, expat

  • RRDtool dependencies are: pkg-config, zlib, libpng, pixman, GNU make, FreeType2, fontconfig, cairo, gettext, glib, pangocairo, libxml2

COMPILING DEPENDENCIES

Dependencies will be kept in the /usr/local/src/deps directory.

C/C++ Compiler

Install GCC

[aixtest01:root:/usr/local/src/deps:] rpm -Uvh gcc-4.2.0-3.aix6.1.ppc.rpm gcc-cplusplus-4.2.0-3.aix6.1.ppc.rpm libstdcplusplus-devel-4.2.0-3.aix6.1.ppc.rpm libstdcplusplus-4.2.0-3.aix6.1.ppc.rpm libgcc-4.2.0-3.aix6.1.ppc.rpm

Packages you can obtain from AIX Toolbox for Linux Applications

NOTE: When compiling the dependencies, we will not specify –prefix directory, thus the default one will be used – /usr/local/.

Compile and install Ganglia (gmond & gmetad) dependencies

PCRE http://www.pcre.org ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.zip

[aixtest01:root:/usr/local/src/deps:] unzip pcre-8.32.zip && cd pcre-8.32/
[aixtest01:root:/usr/local/src/deps/pcre-8.32:] ./configure
[aixtest01:root:/usr/local/src/deps/pcre-8.32:] make && make install

APR

http://apr.apache.org/download.cgi

http://apache.claz.org//apr/apr-1.4.6.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c apr-1.4.6.tar.gz | tar xvf - && cd apr-1.4.6/
[aixtest01:root:/usr/local/src/deps/apr-1.4.6:] ./configure
[aixtest01:root:/usr/local/src/deps/apr-1.4.6:] make && make install

APR-util

http://apr.apache.org/download.cgi

http://apache.claz.org//apr/apr-util-1.5.1.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c apr-util-1.5.1.tar.gz | tar xvf - && cd apr-util-1.5.1
[aixtest01:root:/usr/local/src/deps/apr-util-1.5.1:] ./configure --with-apr=../apr-1.4.6
[aixtest01:root:/usr/local/src/deps/apr-util-1.5.1:] make && make install

APR iconv

http://apr.apache.org/download.cgi

http://apache.claz.org//apr/apr-iconv-1.2.1.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c apr-iconv-1.2.1.tar.gz | tar xvf - && cd apr-iconv-1.2.1
[aixtest01:root:/usr/local/src/deps/apr-iconv-1.2.1:] ./configure --with-apr=../apr-1.4.6
[aixtest01:root:/usr/local/src/deps/apr-iconv-1.2.1:] make && make install

libConfuse

http://www.nongnu.org/confuse/

http://download.savannah.gnu.org/releases/confuse/confuse-2.7.zip

[aixtest01:root:/usr/local/src/deps:] unzip confuse-2.7.zip && cd confuse-2.7
[aixtest01:root:/usr/local/src/deps/confuse-2.7:] ./configure
[aixtest01:root:/usr/local/src/deps/confuse-2.7:] make && make install

expat (The Expat XML Parser)

http://expat.sourceforge.net/

http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/download

[aixtest01:root:/usr/local/src/deps:] gunzip -c expat-2.1.0.tar.gz | tar xvf - && cd expat-2.1.0/
[aixtest01:root:/usr/local/src/deps/expat-2.1.0:] ./configure
[aixtest01:root:/usr/local/src/deps/expat-2.1.0:] make && make install

Compile and install RRDtool dependencies

pkg-config

http://pkgconfig.freedesktop.org/

http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c pkg-config-0.28.tar.gz | tar xvf - && cd pkg-config-0.28/
[aixtest01:root:/usr/local/src/deps/pkg-config-0.28:] ./configure --with-internal-glib
[aixtest01:root:/usr/local/src/deps/pkg-config-0.28:] make && make install

zlib

http://www.zlib.net/

http://zlib.net/zlib-1.2.7.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c zlib-1.2.7.tar.gz | tar xvf - && cd zlib-1.2.7/
[aixtest01:root:/usr/local/src/deps/zlib-1.2.7:] ./configure
[aixtest01:root:/usr/local/src/deps/zlib-1.2.7:] make
[aixtest01:root:/usr/local/src/deps/zlib-1.2.7:] ar -v -r libz.a libz.so.1
[aixtest01:root:/usr/local/src/deps/zlib-1.2.7:] make install
[aixtest01:root:/usr/local/src/deps/zlib-1.2.7:] ar -v -t /usr/local/lib/libz.a |grep libz
rwxr-xr-x     0/0     117629 Mar 16 15:11 2013 libz.so.1

libpng

http://www.libpng.org/pub/png/pngcode.html

http://www.libpng.org/pub/png/libpng.html

ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng15/libpng-1.5.14.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c libpng-1.5.14.tar.gz | tar xvf - && cd libpng-1.5.14
[aixtest01:root:/usr/local/src/deps/libpng-1.5.14:] ./configure
[aixtest01:root:/usr/local/src/deps/libpng-1.5.14:] make && make install

pixman

http://cairographics.org/releases/

http://cairographics.org/releases/pixman-0.28.2.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c pixman-0.28.2.tar.gz | tar xvf - && cd pixman-0.28.2/
[aixtest01:root:/usr/local/src/deps/pixman-0.28.2:] cp -p config.h.in config.h.in.orig
[aixtest01:root:/usr/local/src/deps/pixman-0.28.2:] vi config.h.in
[aixtest01:root:/usr/local/src/deps/pixman-0.28.2:] diff config.h.in.orig config.h.in
114a115,116
> #define PIXMAN_NO_TLS
>
[aixtest01:root:/usr/local/src/deps/pixman-0.28.2:] ./configure
[aixtest01:root:/usr/local/src/deps/pixman-0.28.2:] make && make install

GNU make (necessary to compile pangocairo)

http://www.gnu.org/software/make/

http://ftp.gnu.org/gnu/make/make-3.82.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c make-3.82.tar.gz | tar xvf - && cd make-3.82/
[aixtest01:root:/usr/local/src/deps/make-3.82:] ./configure
[aixtest01:root:/usr/local/src/deps/make-3.82:] make && make install

FreeType2 (Necessary for enabling cairo font backend while compiling cairo. Needed to build pangocairo later)

http://www.freetype.org/download.html

http://download.savannah.gnu.org/releases/freetype/freetype-2.4.11.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c freetype-2.4.11.tar.gz | tar xvf - && cd freetype-2.4.11/
[aixtest01:root:/usr/local/src/deps/freetype-2.4.11:] cp -p builds/unix/configure builds/unix/configure.orig
[aixtest01:root:/usr/local/src/deps/freetype-2.4.11:] sed -e 's/-pedantic -ansi/-pedantic -std=c99/g' builds/unix/configure.orig > builds/unix/configure
[aixtest01:root:/usr/local/src/deps/freetype-2.4.11:] diff builds/unix/configure.orig builds/unix/configure
4586c4586
<   for a in -pedantic -ansi --- >   for a in -pedantic -std=c99
[aixtest01:root:/usr/local/src/deps/freetype-2.4.11:] GNUMAKE=/usr/local/bin/make ./configure
[aixtest01:root:/usr/local/src/deps/freetype-2.4.11:] /usr/local/bin/make && /usr/local/bin/make install

fontconfig (Necessary for enabling cairo font backend while compiling cairo. Needed to build pangocairo later)

http://www.freedesktop.org/wiki/Software/fontconfig

http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.10.1.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c fontconfig-2.10.1.tar.gz | tar xvf - && cd fontconfig-2.10.1/
[aixtest01:root:/usr/local/src/deps/fontconfig-2.10.1:] cp -p config.h.in config.h.in.orig
[aixtest01:root:/usr/local/src/deps/fontconfig-2.10.1:] vi config.h.in
[aixtest01:root:/usr/local/src/deps/fontconfig-2.10.1:] diff config.h.in.orig config.h.in
49,51d48
< /* Define to 1 if you have the `fstatvfs' function. */
< #undef HAVE_FSTATVFS
<
126,128d122
<
< /* Define to 1 if you have the `random_r' function. */
< #undef HAVE_RANDOM_R
[aixtest01:root:/usr/local/src/deps/fontconfig-2.10.1:] export PATH=$PATH:/usr/local/bin
[aixtest01:root:/usr/local/src/deps/fontconfig-2.10.1:] ./configure
[aixtest01:root:/usr/local/src/deps/fontconfig-2.10.1:] make && make install

cairo [also will include cairo-png cairo-svg cairo-pdf cairo-ps during compilation]

http://cairographics.org/releases/

http://cairographics.org/releases/cairo-1.12.14.tar.xz

#xz -c -d cairo-1.12.14.tar.xz | gzip -9 > cairo-1.12.14.tar.gz

Several modifications are required in order to compile cairo 1.12.14 on AIX 6.1.

1. Change every “sync” to “_wrap_sync” in src/cairo-surface-observer.c and src/cairo-xlib-surface-shm.c files

[aixtest01:root:/usr/local/src/deps:] gunzip -c cairo-1.12.14.tar.gz | tar xvf - && cd cairo-1.12.14/
cp -p src/cairo-surface-observer.c src/cairo-surface-observer.c.orig
cp -p src/cairo-xlib-surface-shm.c src/cairo-xlib-surface-shm.c.orig
sed 's/sync/_wrap_sync/g' src/cairo-surface-observer.c.orig > src/cairo-surface-observer.c
sed 's/ sync/ _wrap_sync/g' src/cairo-xlib-surface-shm.c.orig > src/cairo-xlib-surface-shm.c

2. The same do for jmpbuf.

cp -p ./util/cairo-script/cairo-script-private.h ./util/cairo-script/cairo-script-private.h.orig
cp -p ./util/cairo-script/cairo-script-scanner.c ./util/cairo-script/cairo-script-scanner.c.orig
cat ./util/cairo-script/cairo-script-scanner.c.orig |sed 's/jmpbuf/_wrap_jmpbuf/g' > ./util/cairo-script/cairo-script-scanner.c
cat ./util/cairo-script/cairo-script-private.h.orig |sed 's/jmpbuf/_wrap_jmpbuf/g' > ./util/cairo-script/cairo-script-private.h

3. Remove useless blocking includes


grep -l math.h test/*.c |xargs -n1 -I'{}' cp -p '{}' '{}.autoback1'
grep -l math.h test/*.c |xargs -n1 -I'{}' sh -c "sed 's/#include <math.h>//g' '{}.autoback1' > '{}'"

grep -l stdlib.h test/*.c |xargs -n1 -I'{}' cp -p '{}' '{}.autoback2'
grep -l stdlib.h test/*.c |xargs -n1 -I'{}' sh -c "sed 's/#include <stdlib.h>//g' '{}.autoback2' > '{}'"

4. Remove ‘#undef HAVE_GETLINE’ line from the config.h.in

[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] cp -p config.h.in config.h.in.orig
[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] vi config.h.in
[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] diff -u config.h.in.orig config.h.in
--- config.h.in.orig    2013-02-10 14:39:46.000000000 +0100
+++ config.h.in 2013-03-15 15:03:24.000000000 +0100
@@ -128,9 +128,6 @@
  /* Whether you have gcov */
  #undef HAVE_GCOV

- /* Define to 1 if you have the `getline' function. */
- #undef HAVE_GETLINE
-
  /* Enable if your compiler supports the Intel __sync_* atomic primitives */
  #undef HAVE_INTEL_ATOMIC_PRIMITIVES

5. Add ‘#include < stdlib.h >‘ line right after ‘#include < stdio.h >‘

[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] cp -p ./test/any2ppm.c ./test/any2ppm.c.orig
[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] vi ./test/any2ppm.c
[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] diff -u ./test/any2ppm.c.orig ./test/any2ppm.c
--- ./test/any2ppm.c.orig       2013-03-15 15:03:12.000000000 +0100
+++ ./test/any2ppm.c    2013-03-15 15:04:14.000000000 +0100
@@ -58,7 +58,7 @@
  #include <unistd.h>
  #endif
  #include <stdio.h>
-
  + #include <stdlib.h>
  #include <string.h>

  #include <cairo.h>

6. Move ‘#include “cairo-perf.h”‘ before ‘#include < time.h >‘

[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] cp -p ./perf/micro/pattern_create_radial.c ./perf/micro/pattern_create_radial.c.orig
[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] vi ./perf/micro/pattern_create_radial.c
[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] diff -u ./perf/micro/pattern_create_radial.c.orig ./perf/micro/pattern_create_radial.c
--- ./perf/micro/pattern_create_radial.c.orig   2012-02-02 01:48:14.000000000 +0100
+++ ./perf/micro/pattern_create_radial.c        2013-03-15 15:04:57.000000000 +0100
@@ -28,8 +28,8 @@
   * presents a somewhat realistic use-case (although the RADIALS_COUNT
   * isn't very realistic).
   */
- #include <time.h>
  #include "cairo-perf.h"
+ #include <time.h>

  #define RADIALS_COUNT (10000)
[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] ./configure
[aixtest01:root:/usr/local/src/deps/cairo-1.12.14:] make && make install

At the configure phase, make sure that you have the following font backends enabled. (Necessary for pangocairo)

The following font backends:

User: yes (always builtin)

FreeType: yes

Fontconfig: yes

gettext

http://www.gnu.org/software/gettext/gettext.html

http://ftp.gnu.org/gnu/gettext/gettext-0.18.1.1.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c gettext-0.18.1.1.tar.gz |tar xvf - && cd gettext-0.18.1.1/
[aixtest01:root:/usr/local/src/deps/gettext-0.18.1.1:] ./configure
[aixtest01:root:/usr/local/src/deps/gettext-0.18.1.1:] make && make install

glib

ftp://ftp.gtk.org/pub/glib/2.28/

ftp://ftp.gtk.org/pub/glib/2.28/glib-2.28.8.tar.xz

#xz -c -d glib-2.28.8.tar.xz | gzip -9 > glib-2.28.8.tar.gz
[aixtest01:root:/usr/local/src/deps:] gunzip -c glib-2.28.8.tar.gz | tar xvf - && cd glib-2.28.8/
[aixtest01:root:/usr/local/src/deps/glib-2.28.8:] ./configure

Modifiy configure script and replace nameser_compat.h with nameser.h

[aixtest01:root:/usr/local/src/deps/glib-2.28.8:] cp -p ./gio/libasyncns/g-asyncns.h ./gio/libasyncns/g-asyncns.h.orig
[aixtest01:root:/usr/local/src/deps/glib-2.28.8:] sed 's/nameser_compat/nameser/g' ./gio/libasyncns/g-asyncns.h.orig > ./gio/libasyncns/g-asyncns.h
[aixtest01:root:/usr/local/src/deps/glib-2.28.8:] diff ./gio/libasyncns/g-asyncns.h.orig ./gio/libasyncns/g-asyncns.h
30c30
< #include <arpa nameser_compat.h="None">
---
> #include <arpa nameser.h="None">

Due to HAVE_SPLICE being incorrectly defined by autoconf configure improperly detects a splice() routine when there is none. To remedy, edit gio/gfile.c and manually remove all the stuff between #ifdef HAVE_SPLICE blocks .. or add #undef HAVE_SPLICE to config.h

[aixtest01:root:/usr/local/src/deps/glib-2.28.8:] cp -p config.h config.h.orig
[aixtest01:root:/usr/local/src/deps/glib-2.28.8:] vi config.h
[aixtest01:root:/usr/local/src/deps/glib-2.28.8:] diff config.h.orig config.h
394,396d393
< /* Define to 1 if you have the `splice' function. */
< #define HAVE_SPLICE 1
<
[aixtest01:root:/usr/local/src/deps/glib-2.28.8:] make && make install

pangocairo

http://ftp.gnome.org/pub/GNOME/sources/pango/1.28

http://ftp.acc.umu.se/pub/GNOME/sources/pango/1.28/pango-1.28.4.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c pango-1.28.4.tar.gz | tar xvf - && cd pango-1.28.4/
[aixtest01:root:/usr/local/src/deps/pango-1.28.4:] ./configure
[aixtest01:root:/usr/local/src/deps/pango-1.28.4:] /usr/local/bin/make && /usr/local/bin/make install

At the configure step, make sure you see:

checking which cairo font backends could be used… freetype

libxml2

http://xmlsoft.org/downloads.html

ftp://xmlsoft.org/libxml2/libxml2-2.7.8.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c libxml2-2.7.8.tar.gz |tar xvf - && cd libxml2-2.7.8/
[aixtest01:root:/usr/local/src/deps/libxml2-2.7.8:] ./configure
[aixtest01:root:/usr/local/src/deps/libxml2-2.7.8:] make && make install

RRDtool

http://www.rrdtool.org/

http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz

[aixtest01:root:/usr/local/src/deps:] gunzip -c rrdtool-1.4.7.tar.gz | tar xvf - && cd rrdtool-1.4.7/
[aixtest01:root:/usr/local/src/deps/rrdtool-1.4.7:] ./configure --disable-nls --disable-tcl
[aixtest01:root:/usr/local/src/deps/rrdtool-1.4.7:] make && make install

GANGLIA

[aixtest01:root:/usr/local/src:] gunzip -c ganglia-3.5.0.tar.gz |tar xvf - && cd ganglia-3.5.0/
export CC=gcc
export CFLAGS="-DSYSV -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_ALL_SOURCE -DFUNCPROTO=15 -O -I/opt/freeware/include"
export LD=ld
export LDFLAGS="-L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000 -Wl,-brtl"

export PATH=$PATH:/usr/local/apr/bin
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/apr/lib/pkgconfig:/opt/rrdtool-1.4.7/lib/pkgconfig

[aixtest01:root:/usr/local/src/ganglia-3.5.0:] cp -p libmetrics/config.h.in libmetrics/config.h.in.orig
[aixtest01:root:/usr/local/src/ganglia-3.5.0:] sed 's/#undef malloc//g' libmetrics/config.h.in.orig > libmetrics/config.h.in
[aixtest01:root:/usr/local/src/ganglia-3.5.0:] diff libmetrics/config.h.in.orig libmetrics/config.h.in
282c282
< #undef malloc --- >

[aixtest01:root:/usr/local/src/ganglia-3.5.0:] ./configure --with-gmetad --disable-python --with-librrd=/opt/rrdtool-1.4.7/ --with-libconfuse=/usr/local
[aixtest01:root:/usr/local/src/ganglia-3.5.0:] make && make install

I would like to Thank Guy Kastenbaum for several solutions found in his blog to the compilation problems on AIX.

After installation, you should have following Ganglia files

/usr/local/bin/gstat
/usr/local/bin/gmetric
/usr/local/bin/ganglia-config
/usr/local/sbin/gmetad
/usr/local/sbin/gmond

And Ganglia modules

/usr/local/lib/ganglia/modcpu.so
/usr/local/lib/ganglia/moddisk.so
/usr/local/lib/ganglia/modload.so
/usr/local/lib/ganglia/modmem.so
/usr/local/lib/ganglia/modmulticpu.so
/usr/local/lib/ganglia/modnet.so
/usr/local/lib/ganglia/modproc.so
/usr/local/lib/ganglia/modsys.so
Basic Ganglia configuration
[aixtest01:root:/home/root:] mkdir -p /var/lib/ganglia/rrds
[aixtest01:root:/home/root:] chown -Rh nobody:nobody /var/lib/ganglia
[aixtest01:root:/home/root:] /usr/local/sbin/gmond --default_config > /usr/local/etc/gmond.conf
[aixtest01:root:/home/root:] cat /usr/local/etc/gmetad.conf |grep -v ^\# |sed '/^$/d'
data_source "my cluster" localhost
case_sensitive_hostnames 0
Running Ganglia
[aixtest01:root:/home/root:] ln -s /opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/libgcc_s.a /opt/freeware/lib/
[aixtest01:root:/home/root:] /usr/local/sbin/gmond
[aixtest01:root:/home/root:] /usr/local/sbin/gmetad
[aixtest01:root:/home/root:] ps -ef|grep gm
  nobody 3866876       1   0 21:20:21      -  0:00 /usr/local/sbin/gmetad
  nobody 8716422       1   2 21:17:28      -  0:01 /usr/local/sbin/gmond

Voila! The Ganglia is Up & Running on AIX !

You can also try running gmetad with -d2 argument in order to make sure it is writing rrd files as expected.

The only remaining part now is to install HTTP server (it is up to you which one you would like to use) and deploy the ganglia-web-3.5.7.tar.gz in order to get the Ganglia Web. This step is quite easy and I will leave it for you.

P.S.

If you will meet the following message while running gmond:

Cannot load /usr/local/lib/ganglia/modcpu.so metric module: rtld: 0712-001 Symbol cpu_steal_func was referenced

from module /usr/local/lib/ganglia/modcpu.so(), but a runtime definition

of the symbol was not found.

Basically you can ignore it. However, if you would like to avoid it, simply revert the 28f9b619275678e66c4d1fbae3df45bd76350b92 commit!

If you will encounter any problem during compilation, please let me know and I will try to help you as much as I can.

All programs compiled are at their latest stable version on the moment of writing this article (March 2013)

The only older versions (the RRDtool dependencies) were: gettext, glib, pangocairo, libxml2. If you will have success with compiling newer version, please add a comment.