Nagios/build/Solaris

From S23Wiki
Jump to: navigation, search

Building Nagios On Solaris Sparc

Prepare

Install gcc

get the gcc package form sunfreeware

# wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/gcc-3.4.6-sol10-sparc-local.gz
# gunzip gcc-3.4.6-sol10-sparc-local.gz
# pkgadd -d gcc-3.4.6-sol10-sparc-local

you then need to set up the environment (you can add this to /etc/profile or some enlivenment =)

# export CC ; CC=gcc
# export LD_LIBRARY_PATH;  LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/ssl/lib
# export PATH ; PATH=/usr/local/bin:/usr/sfw/bin:/usr/sbin:/usr/bin:/usr/ccs/bin
install ligiconv

gcc needs libiconv

wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/libiconv-1.11-sol10-sparc-local.gz

# gunzip libiconv-1.11-sol10-sparc-local.gz
# pkgadd -d libiconv-1.11-sol10-sparc-local

Install Lib gd

Get the source form www.libgd.org

# wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
# gunzip -dc gd-2.0.35.tar.gz | tar -xf -

# cd gd-2.0.35

# ./configure --prefix=/opt/libgd
...
# make
...
# make install
...

Build Nagios server

get the nagios source from www.nagios.org

# gunzip -dc nagios-3.0.6.tar.gz | tar -xf -
# cd nagios-3.0.6
# groupadd -g 510 nagios
# useradd -u 510 -g nagios nagios

Refer to the Read Only Webaccount Patch below

# ./configure --prefix=/opt/nagios-3.0.6 --with-nagios-user=nagios --with-nagios-group=nagios --with-gd-lib=/opt/libgd/lib   --with-gd-inc=/opt/libgd/include
# gmake pkgclean
# gmake all
# gmake pkgset

checkinstall.in

#!/bin/sh
#
expected_platform="!SUN_PLATFORM!"
#
platform=`uname -p`
#
if [ ${platform} != ${expected_platform} ]; then
    echo "\n\n\n\tThis package must be installed on a ${expected_platform} architecture\n"
    echo "\tAborting installation.\n\n\n"
    exit 1
fi
exit 0

Makefile.in.diff

--- Makefile.in.orig	2010-11-02 09:20:51.257339000 +0000
+++ Makefile.in	2010-11-02 10:00:49.290644000 +0000
@@ -303,6 +303,8 @@
 # Solaris pkgmk
 PACKDIR=@PACKDIR@
 VERSION=@VERSION@
+SUN_OS_RELEASE=$(shell uname -r | cut -f2 -d. )
+SUN_PLATFORM=$(shell uname -p)
 
 Prototype:
 	if [ ! -d $(PACKDIR) ] ; then mkdir $(PACKDIR); fi
@@ -314,12 +316,17 @@
 	$(INSTALL) -m 644 sample-config/nagios.cfg $(PACKDIR)$(CFGDIR)/nagios.cfg.$(VERSION)
 	$(INSTALL) -m 644 sample-config/cgi.cfg $(PACKDIR)$(CFGDIR)/cgi.cfg.$(VERSION)
 	$(INSTALL) -m 640 sample-config/resource.cfg $(PACKDIR)$(CFGDIR)/resource.cfg.$(VERSION)
-	$(INSTALL) -m 664 sample-config/template-object/bigger.cfg $(PACKDIR)$(CFGDIR)/bigger.cfg.$(VERSION)
-	$(INSTALL) -m 664 sample-config/template-object/minimal.cfg $(PACKDIR)$(CFGDIR)/minimal.cfg.$(VERSION)
-	$(INSTALL) -m 664 sample-config/template-object/checkcommands.cfg $(PACKDIR)$(CFGDIR)/checkcommands.cfg.$(VERSION)
-	$(INSTALL) -m 664 sample-config/template-object/misccommands.cfg $(PACKDIR)$(CFGDIR)/misccommands.cfg.$(VERSION)
+	$(INSTALL) -m 664 sample-config/template-object/commands.cfg $(PACKDIR)$(CFGDIR)/commands.cfg.$(VERSION)
+	$(INSTALL) -m 664 sample-config/template-object/contacts.cfg $(PACKDIR)$(CFGDIR)/contacts.cfg.$(VERSION)
+	$(INSTALL) -m 664 sample-config/template-object/localhost.cfg $(PACKDIR)$(CFGDIR)/localhost.cfg.$(VERSION)
+	$(INSTALL) -m 664 sample-config/template-object/printer.cfg $(PACKDIR)$(CFGDIR)/printer.cfg.$(VERSION)
+	$(INSTALL) -m 664 sample-config/template-object/switch.cfg $(PACKDIR)$(CFGDIR)/switch.cfg.$(VERSION)
+	$(INSTALL) -m 664 sample-config/template-object/templates.cfg $(PACKDIR)$(CFGDIR)/templates.cfg.$(VERSION)
+	$(INSTALL) -m 664 sample-config/template-object/timeperiods.cfg $(PACKDIR)$(CFGDIR)/timeperiods.cfg.$(VERSION)
+	$(INSTALL) -m 664 sample-config/template-object/windows.cfg $(PACKDIR)$(CFGDIR)/windows.cfg.$(VERSION)
 	cd contrib; $(MAKE) all; $(MAKE) DESTDIR=$(PACKDIR) INIT_OPTS= INSTALL_OPTS= COMMAND_OPTS= nagios_grp= nagios_usr= install
 	echo i pkginfo> Prototype
+	if [ -f checkinstall.in ] ; then cat checkinstall.in | sed 's/!SUN_PLATFORM!/$(SUN_PLATFORM)/g' >checkinstall; fi
 	if [ -f checkinstall ] ; then echo i checkinstall>> Prototype; fi
 	if [ -f preinstall ] ; then echo i preinstall>> Prototype; fi
 	if [ -f postinstall ] ; then echo i postinstall>> Prototype; fi
@@ -329,10 +336,15 @@
 	mkdir $(PACKDIR)/nagios
 	pkgmk -o -r / -f Prototype -d $(PACKDIR) nagios
 
-nagios.SPARC.pkg.tar.gz: pkg/nagios/pkgmap
-	cd $(PACKDIR) && tar -cf - nagios | gzip -9 -c > ../nagios.SPARC.pkg.tar.gz
+nagios.sun.pkg.tar.gz: pkg/nagios/pkgmap
+	cd $(PACKDIR) && tar -cf - nagios | gzip -9 -c > ../nagios-$(VERSION)-Sol$(SUN_OS_RELEASE)-$(SUN_PLATFORM).pkg.tar.gz
 
-pkgset: nagios.SPARC.pkg.tar.gz
+nagios.sun.pkg: pkg/nagios/pkgmap
+	pkgtrans -s $(PACKDIR) ../nagios-$(VERSION)-Sol$(SUN_OS_RELEASE)-$(SUN_PLATFORM).pkg nagios
+
+pkgsettar: nagios.sun.pkg.tar.gz
+
+pkgset: nagios.sun.pkg
 
 pkgclean:
-	rm -rf pkg Prototype nagios.SPARC.pkg.tar.gz
+	rm -rf pkg Prototype nagios-$(VERSION)-$(SUN_PLATFORM).pkg.tar.gz

Read Only Web account patch

get the patch from http://www.nagios3book.com/

in the directory you have extracted the nagios source code:

# wget http://www.nagios3book.com/nagios-3-enm/patches/readonly.tar
# tar xvf readonly.tar


in the cgi/ dir

# patch -r cgiauth.c < cgiauth.diff
# patch -r extinfo.c < extinfo.diff

and in the include/ dir

# patch -r cgiauth.h < cgiauth.h.diff





Building Nagios On Solaris x86

Prepare

Install gcc

get the gcc package form sunfreeware

# wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/gcc-3.4.6-sol10-x86-local.gz
# gunzip gcc-3.4.6-sol10-x86-local.gz
# pkgadd -d gcc-3.4.6-sol10-x86-local

you then need to set up the enviroment (you can add this to /etc/profile or some eqilivent =)

# export CC ; CC=gcc

# export LD_LIBRARY_PATH;  LD_LIBRARY_PATH=/usr/sfw/lib:/usr/local/ssl/lib

# export PATH ; PATH=/usr/local/bin:/usr/sfw/bin:/usr/sbin:/usr/bin:/usr/ccs/bin
install ligiconv

gcc need libiconv

wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/libiconv-1.11-sol10-x86-local.gz

# gunzip libiconv-1.11-sol10-x86-local.gz 
# pkgadd -d libiconv-1.11-sol10-x86-local 


Install Lib gd

Get the source form www.libgd.org

# wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
# gunzip -dc gd-2.0.35.tar.gz | tar -xf -

# cd gd-2.0.35

# ./configure --prefix=/opt/libgd
...
# make
...
# make install
...

Build Nagios server

get the nagios source from www.nagios.org

# gunzip -dc nagios-3.0.3.tar.gz | tar -xf -
# cd nagios-3.0.3
# groupadd -g 510 nagios
# useradd -u 510 -g nagios nagios

Referee to the Read Only Webaccount Patch below

# ./configure --prefix=/opt/nagios-3.0.3 --with-nagios-user=nagios --with-nagios-group=nagios --with-gd-lib=/opt/libgd/lib   --with-gd-inc=/opt/libgd/include
# gmake 





Read Only Web account patch

get the patch from http://www.nagios3book.com/

in the directory you have extracted the nagios source code:

# wget http://www.nagios3book.com/nagios-3-enm/patches/readonly.tar
# tar xvf readonly.tar


in the cgi/ dir

# patch -r cgiauth.c < cgiauth.diff
# patch -r extinfo.c < extinfo.diff

and in the include/ dir

# patch -r cgiauth.h < cgiauth.h.diff