Installing Nagios / Icinga

After having installed the depencency libraries, now Nagios has to be installed.

Nagios Core

First of all, the current version of Nagios Core (ie. 3.2.0) has to be fetched and unpacked. We’ll also need to apply a patch to fix the issues shown in the Icinga Installation Troubles post.

Run the following „script“ to download, compile and install (using sudo) Nagios 3.2.0 (yes, it’s indeed one humongous line. You can paste it exactly like it is shown into a terminal):

src_url=http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz && \
patch_url=http://esisteinfehleraufgetreten.s3.amazonaws.com/nagios/fix-nagios-3.2.0.patch && \
gnu_patch=$(which gpatch) && \
src_dir=$HOME/src/$(basename $src_url .tar.gz) && \
\
mkdir -p $HOME/src && cd $HOME/src && \
(
 if [[ -r $HOME/src/$(basename $src_url) ]];
  then cat $HOME/src/$(basename $src_url)
  else wget -qO- $src_url | tee $HOME/src/$(basename $src_url)
 fi
) | gzcat | tar xf - && \
(
 if [[ -r $HOME/src/$(basename $patch_url) ]];
  then cat $HOME/src/$(basename $patch_url)
  else wget -qO- $patch_url | tee $HOME/src/$(basename $patch_url)
 fi
) | $gnu_patch -d $src_dir -p1 && \
test -L $src_dir/base/snprintf.o || ln -s ../common/snprintf.o $src_dir/base && \
\
cd $src_dir && \
\
CFLAGS="-fast -xtarget=sparc64vii -xarch=sparcima -xchip=sparc64vii -xcache=64/64/2:5120/256/10 -xautopar -fma=fused           -xipo=2 -zlazyload" \
CC=/opt/sunstudio12.1/bin/cc \
PATH=/opt/sunstudio12.1/bin:/usr/sfw/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/openwin/bin:/usr/X11/bin:/usr/bin:/usr/sbin:/usr/ucb \
LDFLAGS=-R/opt/local/lib \
    ~+/configure --prefix=/opt/local/nagios-3.2.0 \
      --enable-nanosleep --enable-statusmap --with-perlcache --enable-statuswrl \
      --with-gd-lib=/opt/local/lib --with-gd-inc=/opt/local/include \
      --with-cgiurl=/cgi-bin/nagios-3.2.0 --with-htmurl=/nagios-3.2.0 \
      --with-nagios-user=$(id -un) --with-nagios-group=$(id -gn) \
      --with-init-dir=\${prefix}/etc/init.d --with-httpd-conf=\${prefix}/etc/apache && \
\
CFLAGS="-fast -xtarget=sparc64vii -xarch=sparcima -xchip=sparc64vii -xcache=64/64/2:5120/256/10 -xautopar -fma=fused           -xipo=2 -zlazyload" \
CC=/opt/sunstudio12.1/bin/cc \
PATH=/opt/sunstudio12.1/bin:/usr/sfw/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/openwin/bin:/usr/X11/bin:/usr/bin:/usr/sbin:/usr/ucb \
LDFLAGS=-R/opt/local/lib \
    make all && \
\
    sudo sh -c '
      make install && make install-init && make install-commandmode && make install-config && make install-webconf
    '

SMF Manifest

In order to be able to manage (start, stop, control) Nagios with SMF, there needs to be a manifest for Nagios which has to be imported to the system.

url=http://esisteinfehleraufgetreten.s3.amazonaws.com/nagios/application-nagios.manifest.xml
wget -P /tmp $url && \
sudo svccfg import /tmp/$(basename $url)

Icinga

Instead of Nagios Core, it should be possible to use Icinga instead.

src_url=http://prdownloads.sourceforge.net/sourceforge/icinga/icinga-0.8.4.tar.gz && \
patch_url=http://esisteinfehleraufgetreten.s3.amazonaws.com/nagios/fix-icinga-0.8.4.patch && \
gnu_patch=$(which gpatch) && \
src_dir=$HOME/src/$(basename $src_url .tar.gz) && \
\
mkdir -p $HOME/src && cd $HOME/src && \
(
 if [[ -r $HOME/src/$(basename $src_url) ]];
  then cat $HOME/src/$(basename $src_url)
  else wget -qO- $src_url | tee $HOME/src/$(basename $src_url)
 fi
) | gzcat | tar xf - && \
(
 if [[ -r $HOME/src/$(basename $patch_url) ]];
  then cat $HOME/src/$(basename $patch_url)
  else wget -qO- $patch_url | tee $HOME/src/$(basename $patch_url)
 fi
) | $gnu_patch -d $src_dir -p1 && \
test -L $src_dir/base/snprintf.o || ln -s ../common/snprintf.o $src_dir/base && \
\
cd $src_dir && \
\
CFLAGS="-fast -xtarget=sparc64vii -xarch=sparcima -xchip=sparc64vii -xcache=64/64/2:5120/256/10 -xautopar -fma=fused           -xipo=2 -zlazyload" \
CC=/opt/sunstudio12.1/bin/cc \
PATH=/opt/sunstudio12.1/bin:/usr/sfw/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/openwin/bin:/usr/X11/bin:/usr/bin:/usr/sbin:/usr/ucb \
LDFLAGS=-R/opt/local/lib \
    ~+/configure --prefix=/opt/local/icinga-0.8.4 \
      --enable-nanosleep --enable-statusmap --with-perlcache --enable-statuswrl \
      --with-gd-lib=/opt/local/lib --with-gd-inc=/opt/local/include \
      --with-cgiurl=/cgi-bin/icinga-0.8.4 --with-htmurl=/icinga-0.8.4 \
      --with-icinga-user=$(id -un) --with-icinga-group=$(id -gn) \
      --with-init-dir=\${prefix}/etc/init.d --with-httpd-conf=\${prefix}/etc/apache && \
\
CFLAGS="-fast -xtarget=sparc64vii -xarch=sparcima -xchip=sparc64vii -xcache=64/64/2:5120/256/10 -xautopar -fma=fused           -xipo=2 -zlazyload" \
CC=/opt/sunstudio12.1/bin/cc \
PATH=/opt/sunstudio12.1/bin:/usr/sfw/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/openwin/bin:/usr/X11/bin:/usr/bin:/usr/sbin:/usr/ucb \
LDFLAGS=-R/opt/local/lib \
    make all && \
\
    sudo sh -c '
      make install && make install-init && make install-commandmode && make install-config && make install-webconf
    '

SMF Manifest

Exactly like with Nagios Core, there needs to be SMF Manifest for Icinga. Install it:

url=http://esisteinfehleraufgetreten.s3.amazonaws.com/nagios/application-icinga.manifest.xml
wget -P /tmp $url && \
sudo svccfg import /tmp/$(basename $url)

Nagios Plugins

After having installed Nagios Core, it’s now time to turn to the Nagios Plugins. At the time of this writing, v1.4.13 is the current stable version. The plugins need to be installed in the same directory, where Nagios Core is installed (an alternative might be to fix/change the supplied default configuration to point to the installation directory of Nagios Plugins).

src_url=http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz && \
gnu_patch=$(which gpatch) && \
\
mkdir -p $HOME/src && cd $HOME/src && \
(
 if [[ -r $HOME/src/$(basename $src_url) ]];
  then cat $HOME/src/$(basename $src_url)
  else wget -qO- $src_url | tee $HOME/src/$(basename $src_url)
 fi
) | gzcat | tar xf - && \
\
cd $HOME/src/$(basename $src_url .tar.gz) && \
\
CFLAGS="-fast -xtarget=sparc64vii -xarch=sparcima -xchip=sparc64vii -xcache=64/64/2:5120/256/10 -xautopar -fma=fused -xc99=all -xipo=2 -zlazyload" \
CC=/opt/sunstudio12.1/bin/cc CXX=/opt/sunstudio12.1/bin/CC \
PATH=/opt/sunstudio12.1/bin:/usr/sfw/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/openwin/bin:/usr/X11/bin:/usr/bin:/usr/sbin:/usr/ucb:/export/home/webservd/flexlm/UGS/Teamcenter2005/Visualization/bin \
LDFLAGS="-R/opt/local/lib -R/usr/sfw/lib -L/usr/sfw/lib" \
    ~+/configure --prefix=/opt/local/nagios-3.2.0 \
    --with-nagios-user=$(id -un) --with-nagios-group=$(id -gn) \
    --with-cgiurl=/cgi-bin/nagios-3.2.0 \
    --with-trusted-path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/sfw/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/openwin/bin:/usr/X11/bin:/opt/csw/bin:/opt/csw/sbin \
    \
    --with-ping-command="/usr/sbin/ping -s %s 64 %u" --without-ipv6 \
    --with-nslookup-command=/usr/sbin/nslookup --with-uptime-command=/bin/uptime \
    --with-dig-command=/usr/sbin/dig --with-ssh-command=/usr/bin/ssh \
    \
    --with-mysql=/usr/sfw --with-openssl=/usr/sfw && \
\
CFLAGS="-fast -xtarget=sparc64vii -xarch=sparcima -xchip=sparc64vii -xcache=64/64/2:5120/256/10 -xautopar -fma=fused -xc99=all -xipo=2 -zlazyload" \
CC=/opt/sunstudio12.1/bin/cc CXX=/opt/sunstudio12.1/bin/CC \
PATH=/opt/sunstudio12.1/bin:/usr/sfw/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/openwin/bin:/usr/X11/bin:/usr/bin:/usr/sbin:/usr/ucb:/export/home/webservd/flexlm/UGS/Teamcenter2005/Visualization/bin \
LDFLAGS="-R/opt/local/lib -R/usr/sfw/lib -L/usr/sfw/lib" \
    make && \
\
    sudo make install

SysAdmin’s Journey has these additional ps(1) related configure options:

    --with-ps-command="/bin/ps -eo 's uid pid ppid vsz rss pcpu etime comm args'" \
    --with-ps-format='%s %d %d %d %d %d %f %s %s %n' \
    --with-ps-cols=10 \
    --with-ps-varlist='procstat,&;procuid,&;procpid,&;procppid,&;procvsz,&;procrss,&;procpcpu,procetime,procprog,&pos'

When I add those, make ultimately fails with:

source='check_procs.c' object='check_procs.o' libtool=no \
DEPDIR=.deps depmode=none /bin/bash ../build-aux/depcomp \
/opt/sunstudio12.1/bin/cc -DLOCALEDIR=\"/opt/local/nagios-plugins-1.4.13/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I../lib -I../gl -I../intl  -I/usr/include/pgsql -I/usr/sfw/include   -I/usr/sfw/include  -fast -xtarget=sparc64vii -xarch=sparcima -xchip=sparc64vii -xcache=64/64/2:5120/256/10 -xautopar -fma=fused -xc99=all -xipo=2 -zlazyload -c check_procs.c
"check_procs.c", line 185: syntax error before or at: ;
"check_procs.c", line 185: syntax error before or at: ;
"check_procs.c", line 185: syntax error before or at: ;
"check_procs.c", line 185: syntax error before or at: ;
"check_procs.c", line 185: syntax error before or at: ;
"check_procs.c", line 185: syntax error before or at: ;
"check_procs.c", line 185: syntax error before or at: )
cc: acomp failed for check_procs.c
*** Error code 1
make: Fatal error: Command failed for target `check_procs.o'
Current working directory /export/home/webservd/src/nagios-plugins-1.4.13.failing/nagios-plugins-1.4.13/plugins

Dunno how Justin got nagios-plugins to compile with these flags; I suppose it’s because he used an older version of nagios-plugins. Anyway, he writes, that he HAD to use these flags, otherwise, make would error out on him in check_procs. For me, it’s the opposite – don’t use --with-ps-XYZ flags, and it compiles fine. Use those --with-ps-XYZ flags, and make fails.

Start

Nagios

Now, after having installed BOTH Nagios Core and Nagios Plugins, it should be possible to start application/nagios:

$ svcs application/nagios
STATE          STIME    FMRI
disabled        9:12:23 svc:/application/nagios:default

$ sudo svcadm enable -s application/nagios

$ svcs application/nagios
STATE          STIME    FMRI
maintenance     9:12:38 svc:/application/nagios:default

Reviewing the log file /var/svc/log/application-nagios:default.log shows this fault:

[...]
[ Sep 29 09:12:37 Executing start method ("/opt/local/nagios-3.2.0/etc/init.d/nagios start") ]
Starting nagios: done.
[ Sep 29 09:12:37 Method "start" exited with status 0 ]
[ Sep 29 09:12:37 Stopping because process dumped core. ]
[ Sep 29 09:12:37 Executing stop method ("/opt/local/nagios-3.2.0/etc/init.d/nagios stop") ]
Stopping nagios: done.
[ Sep 29 09:12:37 Method "stop" exited with status 0 ]
[...]

Main fault: „Stopping because process dumped core.„. Interestingly, when trying to start nagios manually (by running /opt/local/nagios-3.2.0/etc/init.d/nagios start), Nagios starts up just fine – please also see the blogpost Core Dumps when run in SMF, fine otherwise‽.

Haven’t found a reason for the core dump (and also have NOT found the core core dump file itself by running find / -type f -name core, for that matter…). Because of that, switching to the OpenCSW Nagios „Core“ and Nagios Plugins packages.😦

For the self compiled stuff, this is a:

#fail

Icinga

Try to start icinga:

$ svcs icinga
STATE          STIME    FMRI
disabled       10:21:42 svc:/application/icinga:default

$ sudo svcadm enable -s svc:/application/icinga:default
svcadm: Instanz "svc:/application/icinga:default" befindet sich im Wartungszustand.

$ svcs icinga
STATE          STIME    FMRI
maintenance    10:22:24 svc:/application/icinga:default

And just like Nagios, icinga fails as well:

[...]
[ Sep 29 10:25:30 Executing start method ("/opt/local/icinga-0.8.4/etc/init.d/icinga start") ]
-n Starting icinga:
 done.
[ Sep 29 10:25:30 Method "start" exited with status 0 ]
[ Sep 29 10:25:30 Stopping because process dumped core. ]
[ Sep 29 10:25:30 Executing stop method ("/opt/local/icinga-0.8.4/etc/init.d/icinga stop") ]
Stopping icinga: done.
[...]

Like I said:

#fail

Schreibe einen Kommentar

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s