Wednesday, April 25, 2007

Compiling Nagios 3.0a3 (and plugins) for OpenSolaris 64bit

Wrestling with the "native" cc in OpenSolaris is not my favorite thing to do, and I really wish the whole project would drop "cc" in favor of gcc.

Nagios is a good example of a "common" application that "just compiles" on Linux, and has to be thoughtfully compiled on OpenSolaris.

By default, Nagios will choose gcc as the compiler, but it links in 32bit libraries (specifically libopenssl.so and libcrypto.so). The native compiler chokes on the plugins (mostly the check_dhcp plugin, but also check_mysql, etc).

But enough of that, here's how to compile Nagios for OpenSolaris in 64bit mode.

Step 1: Download Source
Get GD from here
Get Nagios from here
Get Nagios Plugins from here

Step 2: Create nagios user and group
#groupadd nagios
#useradd -g nagios nagios

Step 3: Build GD
Note: having to dynamically link this in is the default, and preferably there would be a method to just statically link in this library, but for this doc, we'll install GD somewhere common and pass in the search path.

Extract the source:
#gtar xfz gd-2.0.34.tar.gz

Setup Environment:
#export CFLAGS=-m64
#export PATH=$PATH:/usr/ccs/bin

Configure:
#./configure --prefix=/usr/local/gd-2.0.34

Compile:
#make

Install:
#make install

Step 4: Build Nagios

Extract the source:
#gtar xfz nagios-3.0a3.tar.gz

Setup Environment:
#export CFLAGS=-m64
#export LDFLAGS="-L/usr/local/src/gd-2.0.34/lib -R/usr/local/src/gd-2.0.34/lib"

Configure:
#./configure --prefix=/usr/local/nagios-3.0a3 --with-gd-lib=/usr/local/gd-2.0.34/lib \
--with-gd-inc=/usr/local/gd-2.0.34/include \
--with-init-dir=/usr/local/nagios-3.0a3/init.d

Compile:
#make all

Install:
#make install
#make install-init
#make install-commandmode
#make install-config

Step 5: Build Nagios Plugins
Extract the plugins:
#gtar xfz nagios-plugins-1.4.8.tar.gz

Setup Environment:
#export PATH=$PATH:/usr/ccs/bin
#export CFLAGS=-m64
#export LDFLAGS="-Xlinker -64 -L/usr/sfw/lib/amd64 -R/usr/sfw/lib/amd64"

Configure:
#./configure --prefix=/usr/local/nagios-3.0a3

Compile:
#make

Install:
#make install

Step 6: Setup Nagios Configuration
# cd /usr/local/nagios-3.0a3/etc
# cp -p cgi.cfg-sample cgi.cfg
# cp -p commands.cfg-sample commands.cfg
# cp -p localhost.cfg-sample localhost.cfg
# cp -p nagios.cfg-sample nagios.cfg
# cp -p resource.cfg-sample resource.cfg

Step 7: Install SMF package for Nagios
See this post for the SMF package

Cheers

Brian

1 comment:

Der letzte Mann said...

Hi, thanks for great post! Unfortunatelly SMF is not available and some important thing I need to discover myself :), so my pingback with Osol 06.2009 there http://www.eject.name/2009/07/installing-nagios-on-opensolaris-062009.html