Install Xymon on NetBSD

These are my notes on compiling and installing Xymon (Hobbitmon renamed) on NetBSD.

Compilation

The compilation won’t take place on the production machine.

Grab and untar the Xymon 4.2.3 archive.

Install the dependencies:

# pkg_add gmake
# pkg_add fping
# pkg_add rrdtool
# pkg_add fontconfig

Be sure to have xbase.tgz and xfont.tgz installed (required by rrdtool).

Configure and compile Xymon:

# mkdir -p /home/xymon
# chown xymon:xymon /home/xymon
# MAKE=gmake ./configure
...
  Where do you want the Xymon installation? /home/xymon
...
# gmake
# gmake install
...
Installation complete.

You must configure your webserver for the Hobbit webpages and CGI-scripts.
A sample Apache configuration is in /home/xymon/server/etc/hobbit-apache.conf
If you have your Administration CGI scripts in a separate directory,
then you must also setup the password-file with the htpasswd command.

To start Hobbit, as the xymon user run ' '
To view the Hobbit webpages, go to http://tumfatig.net/xymon

Installation

These steps will take place on the production machine.

Install xbase.tgz and xfont.tgz (required by rrdtool).

Install the dependencies:

# pkg_add fping
# pkg_add rrdtool
# pkg_add fontconfig

Configure famd.

Solve a Pango issue:

#  sh -c 'pango-querymodules > "/usr/pkg/libdata/pango/pango.modules"'

Copy the /home/xymon from the build machine to the production machine.

Configure the HTTP server:

# vi /etc/inetd.conf
http  stream  tcp  nowait:600  _httpd  /usr/libexec/httpd  httpd -C .sh /bin/sh /home/xymon/server/www

Tune the directories:

# cd /home/xymon/server/www
# sudo -u xymon ln -s . xymon
# sudo -u xymon ln -s /home/xymon/cgi-bin xymon-cgi
# sudo -u xymon ln -s /home/xymon/cgi-secure xymon-seccgi

Configure the autostart process:

# vi /etc/rc.local
/usr/pkg/bin/sudo -u xymon /home/xymon/server/bin/hobbit.sh start

Configure xymon

Correct the installation

The compilation process write some default configuration files. As the files were generated on another machine, some contains references that have to be tuned to the new destination.

Replace the BBSERVERHOSTNAME value in the server/etc/hobbitserver.cfg file.

Remove the compilation machine reference from server/etc/bb-hosts.

Delete the compilation host from the test database:

# sudo -u xymon /home/xymon/server/bin/bb 127.0.0.1 “drop pak.tumfatig.net”

Set up the standard monitoring

Add the new monitoring tests:

192.168.0.2 mini # noconn dns=NS:tumfatig.net,MX:carnat.net,A:www.google.fr http://www.tumfatig.net/ https://www.tumfatig.net/mail/ ldap smtp snmp_cpu snmp_net ssh
192.168.0.3 sup # bbd noconn http://akela.tumfatig.net/xymon/ snmp_cpu snmp_net ssh

Set up custom tests

Xymon defines some generic testings: DNS, SSH, SMTP, HTTP… But there are a few missing things, like Load, Network traffic… Those will be configured to use SNMP.

First of all, configure SNMP on the server side ; the one you want the info from, not the monitoring server 😉

Create the Xymon custom script:

# vi server/ext/snmp_cpu.sh
#!/bin/ksh
#
# This script will return cpu load from SNMP.
#

## environment variables
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin"

BBHTAG="snmp_cpu"
COLUMN=$BBHTAG

$BBHOME/bin/bbhostgrep $BBHTAG | while read L
do
        set $L

        HOSTIP="$1"
        MACHINEDOTS="$2"
        MACHINE=`echo $2 | $SED -e's/./,/g'`

        COLOR="green"
        MSG="$BBHTAG status for host $MACHINEDOTS"

# do the stuff here
        # create the results file
        SNMP_LOG="/tmp/snmp_cpu.$HOSTIP.log"

        # fill-in the results file with cpu load informations
        echo "" > $SNMP_LOG
        `snmpget -v 2c -Oq -c public $HOSTIP 
        UCD-SNMP-MIB::ssCpuRawUser.0 
        UCD-SNMP-MIB::ssCpuRawNice.0 
        UCD-SNMP-MIB::ssCpuRawSystem.0 
        UCD-SNMP-MIB::ssCpuRawIdle.0 
        UCD-SNMP-MIB::laLoad.1 
        UCD-SNMP-MIB::laLoad.2 
        UCD-SNMP-MIB::laLoad.3 
        >> $SNMP_LOG 2>&1`

        # get the status from the snmp error result
        [[ `snmpget -v 2c -c public -Oeqv $HOSTIP UCD-SNMP-MIB::laErrorFlag.1` -ne 0 ]] && COLOR="red"

# end of stuff

        $BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date`

        `sed -e 's/(^.*::..)([a-zA-Z]*)(.)/2/' -e 's/ / : /' $SNMP_LOG`
        "
#       rm $SNMP_LOG
done

exit 0

Let Xymon know about the new test by modifying the server/etc/hobbitlaunch.cfg file:

# check cpu load from snmp
#
[snmp_cpu.sh]
        ENVFILE /home/xymon/server/etc/hobbitserver.cfg
        NEEDS hobbitd
        CMD $BBHOME/ext/snmp_cpu.sh
        LOGFILE $BBSERVERLOGS/snmp_cpu.log
        INTERVAL 5m

Activate the new test by modifying the TEST2RRD variable from the server/etc/hobbitserver.cfg file:

TEST2RRD=”cpu=la,disk,…,snmp_cpu=ncv,snmp_net=ncv”

Define the data type of the graphics from server/etc/hobbitserver.cfg:

NCV_snmp_cpu=”CpuRawUser0:GAUGE,CpuRawNice0:GAUGE,CpuRawSystem0:GAUGE,CpuRawIdle0:GAUGE,Load1:GAUGE,Load2:GAUGE,Load3:GAUGE”

Add the graphics definition to the server/etc/hobbitgraph.cfg:

[snmp_cpu]
        TITLE CPU Load Average
        YAXIS CPU Load (%)
        DEF:user=snmp_cpu.rrd:CpuRawUser0:AVERAGE
        DEF:nice=snmp_cpu.rrd:CpuRawNice0:AVERAGE
        DEF:system=snmp_cpu.rrd:CpuRawSystem0:AVERAGE
        DEF:idle=snmp_cpu.rrd:CpuRawIdle0:AVERAGE
        DEF:load1=snmp_cpu.rrd:Load1:AVERAGE
        DEF:load2=snmp_cpu.rrd:Load2:AVERAGE
        DEF:load3=snmp_cpu.rrd:Load3:AVERAGE
        CDEF:cload1=load1,100,*
        CDEF:tot=user,nice,+,system,+,idle,+,100,/
        CDEF:cuser=user,tot,/
        CDEF:cnice=nice,tot,/
        CDEF:csystem=system,tot,/
        CDEF:cidle=idle,tot,/
        COMMENT: n
        AREA:cuser#99FF66:User
        GPRINT:cuser:LAST:%3.0lf%% (cur)
        GPRINT:cuser:AVERAGE:%3.0lf%% (avg)
        GPRINT:cuser:MIN:%3.0lf%% (min)
        GPRINT:cuser:MAX:%3.0lf%% (max)n
        STACK:cnice#6699FF:Nice
        GPRINT:cnice:LAST:%3.0lf%% (cur)
        GPRINT:cnice:AVERAGE:%3.0lf%% (avg)
        GPRINT:cnice:MIN:%3.0lf%% (min)
        GPRINT:cnice:MAX:%3.0lf%% (max)n
        STACK:csystem#FF6699:System
        GPRINT:csystem:LAST:%3.0lf%% (cur)
        GPRINT:csystem:AVERAGE:%3.0lf%% (avg)
        GPRINT:csystem:MIN:%3.0lf%% (min)
        GPRINT:csystem:MAX:%3.0lf%% (max)n
        STACK:cidle#DDDDDD:Idle
        GPRINT:cidle:LAST:%3.0lf%% (cur)
        GPRINT:cidle:AVERAGE:%3.0lf%% (avg)
        GPRINT:cidle:MIN:%3.0lf%% (min)
        GPRINT:cidle:MAX:%3.0lf%% (max)n
        COMMENT: n
        LINE1:cload1#636363:Load Average
        GPRINT:cload1:LAST:%3.0lf%% (cur)
        GPRINT:cload1:AVERAGE:%3.0lf%% (avg)
        GPRINT:cload1:MIN:%3.0lf%% (min)
        GPRINT:cload1:MAX:%3.0lf%% (max)n
        COMMENT: n

Adding tests definition will require Xymon to be restarted.

Bibliography

1 Comment

  • Joel Carnat Wed, 28 Mar 2012 16:37:50 +0000 Reply

    Using NetBSD 5.0.2/i386 and Xymon 4.3.7, there is a few modifications to apply to sources (stolen from pkgsrc):

    --- client/netbsd-meminfo.c.orig        2011-07-31 23:01:52.000000000 +0200
    +++ client/netbsd-meminfo.c     2012-03-28 16:35:05.000000000 +0200
    @@ -23,5 +23,5 @@
     {
            int hw_physmem[] = { CTL_HW, HW_PHYSMEM64 };
    -       int64 physmem;
    +       int64_t physmem;
     
            int hw_pagesize[] = { CTL_HW, HW_PAGESIZE };
    --- build/Makefile.NetBSD.orig  2011-03-08 18:20:28.000000000 +0100
    +++ build/Makefile.NetBSD       2012-03-28 16:36:18.000000000 +0200
    @@ -2,5 +2,5 @@
     # From Emmanuel Dreyfus.
     #
    -OSDEF = -DBSD
    +OSDEF = -DBSD -DHAVE_STDINT_H
     
     # NETLIBS: None needed
    @@ -11,5 +11,5 @@
     PKGDIR?=/usr/pkg
     CFLAGS = -g -O2 -Wall -Wno-unused -D_REENTRANT $(LFSDEF) $(OSDEF) \
    -       -I${PKGDIR}/include -L${PKGDIR}/lib, -Wl,--rpath=${PKGDIR}/lib
    +       -I${PKGDIR}/include -L${PKGDIR}/lib -Wl,--rpath=${PKGDIR}/lib
     RPATH = "-Wl,--rpath,"
    

Leave a Reply

%d bloggers like this: