Install Xymon on NetBSD

       700 words, 4 minutes

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/xymoni

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