Re: Nagios invoked oom-killer
Posted: Tue Mar 05, 2013 1:59 pm
We don't use xinet:
With init.d I make this file:
With init.d I make this file:
Code: Select all
# Changelog: Taken from Debian Project package nsca in squeeze of architecture i386
# Modified for Nagios 3.3.1
# Esteban Monge [email protected]
#!/bin/sh
### BEGIN INIT INFO
# Provides: nsca
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# simple debian init script for nsca
# by sean finney <[email protected]>
DAEMON=/usr/local/nagios/bin/nsca
NAME=nsca
DESC="Nagios Service Check Acceptor"
CONF=/usr/local/nagios/etc/nsca.cfg
OPTS="--daemon -c $CONF"
PIDFILE="/var/run/nsca.pid"
###
test -f $DAEMON || exit 0
# grab an arbitrary config setting from nsca.cfg
get_config(){
grep "^[[:space:]]*$1=" $CONF 2>/dev/null | tail | cut -d= -f2-
}
# if the pid_file is specified in the configuration file, nsca will
# take care of the pid handling for us. if it isn't we should continue
# as we have before
PIDFILE=`get_config pid_file`
# if pidfile isn't set
if [ -z "$PIDFILE" ]; then
# then this is the default PIDFILE
PIDFILE="/var/run/nsca.pid"
# run nsca in the foreground, and have s-s-d fork it for us
OPTS="-f $OPTS"
# and then this is how we call SSD
SSD_STARTOPTS="--background --pidfile $PIDFILE --make-pidfile"
SSD_STOPOPTS="--pidfile $PIDFILE"
else
# but if pid_file is set, we don't have to do anything
SSD_STARTOPTS="--pidfile $PIDFILE"
SSD_STOPOPTS="--pidfile $PIDFILE"
fi
SSD_START="start-stop-daemon --start --oknodo -S $SSD_STARTOPTS --exec $DAEMON"
SSD_STOP="start-stop-daemon --stop --oknodo -K $SSD_STOPOPTS --exec $DAEMON"
die(){
echo $@
exit 1
}
case "$1" in
start)
echo -n "Starting $DESC: "
if [ ! -d "/var/run/nagios" ]; then
mkdir -p /var/run/nagios || die "ERROR: couldn't create /var/run/nagios"
fi
$SSD_START -- $OPTS || die "ERROR: could not start $NAME."
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
$SSD_STOP -- $OPTS || die "ERROR: could not stop $NAME."
rm -f $PIDFILE
echo "$NAME."
;;
reload|force-reload)
echo -n "Reloading $DESC: "
$SSD_STOP --signal HUP -- $OPTS || die "ERROR: could not reload $NAME."
echo "$NAME."
;;
restart)
$0 stop
$0 start
;;
esac