NSCA daemon

Central Nagios server

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nsca-2.9.2.tar.gz

tar zxfv nsca-2.9.2.tar.gz

cd nsca-2.9.2

./configure
make all 
cp src/nsca /usr/local/nagios/bin
cp sample-config/nsca.cfg /usr/local/nagios/etc
chown nagios.nagcmd /usr/local/nagios/etc/nsca.cfg
chmod g+r /usr/local/nagios/etc/nsca.cfg
scp src/send_nsca <remote_client>:/usr/local/nagios/libexec
scp sample-config/send_nsca.cfg <remote_client>:/usr/local/nagios/etc

vi /etc/init.d/nsca

Return code

0=OK
1=WARNING
2=CRITICAL
3=UNKNOWN)
#!/bin/sh
#
#  Last Modified 01-07-2003 Ethan Galstad (nagios@nagios.org)
#  Notes
#  This script takes care of starting and stopping the NSCA daemon.
#  Modeled after init script for NRPE written by jaclu@grm.se
#
# chkconfig: 2345 80 30
# description: nsca is a daemon for accepting service check results \
#              from applications running on other hosts.
# processname: nsca
# config: /usr/local/nagios/etc/nsca.cfg

# Source function library
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/functions ]; then
. /etc/rc.d/functions
fi

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

NscaBin=/usr/local/nagios/bin/nsca
NscaCfg=/usr/local/nagios/etc/nsca.cfg
LockFile=/var/lock/subsys/nsca

# See how we were called.
case "$1" in
  start)
    # Start daemons.
    echo -n "Starting nsca: "
    daemon $NscaBin -s -c $NscaCfg
    RETVAL=$?
    echo
    touch $LockFile
    ;;
  stop)
    # Stop daemons.
    echo -n "Shutting down nsca: "
    killproc nsca
    echo
    rm -f $LockFile
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  status)
    status nsca
    ;;
  *)
    echo "Usage: nsca {start|stop|restart|status}"
    exit 1
esac

exit 0

chmod +x /etc/init.d/nsca

chkconfig --add nsca

/etc/init.d/nsca start

On the client

chown nagios.nagios /usr/local/nagios/libexec/send_nsca /usr/local/nagios/etc/send_nsca.cfg