Upgrading from 3.5.1 to 4.0.0

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Re: Upgrading from 3.5.1 to 4.0.0

Postby mistie710 » Sat Dec 28, 2013 9:20 am

magna.vis wrote:Looks like this guy may have some input as well: http://roger.steneteg.org/492/installing-nagios-from-source/

I'm also thinking about cloning my current setup, and upgrading without doing the make install-init command and seeing if it still works. If I get around to it in the next couple of days, I'll post my results.

And here it is in code brackets:
Code: Select all
#! /bin/sh
### BEGIN INIT INFO
# Provides:          nagios
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: start and stop Nagios monitoring server
# Description:       Nagios is a service monitoring system
### END INIT INFO

# Author: Foo Bar <roger@steneteg.org>
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Nagios monitoring system"
NAME=nagios
PREFIX=/srv/nagios
STATEDIR=/var/nagios
CONFIGDIR=/etc/nagios
CONFIGFILE="$CONFIGDIR/nagios.cfg"
DAEMON="${PREFIX}/bin/${NAME}"
DAEMON_ARGS="-d $CONFIGFILE"
SCRIPTNAME=/etc/init.d/$NAME
PIDFILE=/var/run/$NAME.pid
USER="nagios"
GROUP="nagios"

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

check_config() {
   RESULTFILE="$STATEDIR/configcheck$$"
   CHECKRESULT=`$DAEMON -v $CONFIGFILE > $RESULTFILE`
   WARN=`grep ^"Total Warnings:" $RESULTFILE | awk -F: '{print $2}' |sed s/' '//g`
   ERR=`grep ^"Total Errors:" $RESULTFILE | awk -F: '{print $2}' |sed s/' '//g`

   if test "${WARN}" = "0" && test "${ERR}" = "0"; then
      echo "OK - Configuration check verified"
      return 0
   else
      cat $RESULTFILE
      exit 8
   fi
}

#
# Function that starts the daemon/service
#
do_start()
{
   # Return
   #   0 if daemon has been started
   #   1 if daemon was already running
   #   2 if daemon could not be started

   test -x $DAEMON || exit 2
   test -f $CONFIGGILE || exit 2
   if test "$1" = "checkconfig"; then
      check_config
   fi
   echo -n "Starting $NAME .."
   start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1
   start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 2
   echo ". $NAME started"
}

#
# Function that stops the daemon/service
#
do_stop()
{
   # Return
   #   0 if daemon has been stopped
   #   1 if daemon was already stopped
   #   2 if daemon could not be stopped
   #   other if a failure occurred
   echo -n "Stopping $NAME .."
#   start-stop-daemon --stop --quiet --retry=5 --pidfile $PIDFILE --name $NAME
#   RETVAL="$?"
#   [ "$RETVAL" = 2 ] && return 2
   # Wait for children to finish too if this is a daemon that forks
   # and if the daemon is only ever run from this initscript.
   # If the above conditions are not satisfied then add some other code
   # that waits for the process to drop all resources that could be
   # needed by services started subsequently.  A last resort is to
   # sleep for some time.
   start-stop-daemon --stop --quiet --oknodo --retry=5 --exec $DAEMON
   RETVAL="$?"
   [ "$RETVAL" = 2 ] && return 2
   # Many daemons don't delete their pidfiles when they exit.
   rm -f $PIDFILE
   echo ". $NAME stopped"
   return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
   #
   # If the daemon can reload its configuration without
   # restarting (for example, when it is sent a SIGHUP),
   # then implement that here.
   #
   check_config
   # This does not seem to be working
   #start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE --name $NAME
   echo "There is something wrong with the reload function, use restart instead"
   return 0
}

case "$1" in
  start)
   [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
   do_start "checkconfig"
   case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   esac
   ;;
  stop)
   [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
   do_stop
   case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
   esac
   ;;
  status)
   status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
   ;;
  reload)
   #
   # If do_reload() is not implemented then leave this commented out
   # and leave 'force-reload' as an alias for 'restart'.
   #
   log_daemon_msg "Reloading $DESC" "$NAME"
   do_reload
   log_end_msg $?
   ;;
  restart)
   #
   # If the "reload" option is implemented then remove the
   # 'force-reload' alias
   #
   log_daemon_msg "Restarting $DESC" "$NAME"
   check_config
   do_stop
   case "$?" in
     0|1)
      do_start
      case "$?" in
         0) log_end_msg 0 ;;
         1) log_end_msg 1 ;; # Old process is still running
         *) log_end_msg 1 ;; # Failed to start
      esac
      ;;
     *)
      # Failed to stop
      log_end_msg 1
      ;;
   esac
   ;;
  *)
   echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
   exit 3
   ;;
esac


Am in the middle of constructing a test setup of Nagios 4 on openSUSE 13.1 ahead of my retool of the works system on 3.2.3 under openSUSE 11.4. As has been mentioned above, the /etc/init.d/nagios file that is generated fails miserably but I found this post, which was a start. The two problems I have with is are that I have no "daemon" command available and I have no "status_of_proc" command available. The latter of these isn't so much of a bother as it doesn't appear to affect the running of the Nagios daemon once you can.

The change I made, however, to actually get it started was to whip out the "daemon" command at line 82 and replace it with
Code: Select all
startproc -u $user -- $exec -d $config


The result is a running daemon but you get the error "./nagios: line 120: status_of_proc: command not found". Any ideas?
mistie710
 
Posts: 4
Joined: Sat Dec 28, 2013 9:04 am

Re: Upgrading from 3.5.1 to 4.0.0

Postby slansing » Mon Dec 30, 2013 10:28 am

Locking as this is almost identical to your other thread.
slansing
 
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Upgrading from 3.5.1 to 4.0.0

Postby abrist » Mon Dec 30, 2013 10:29 am

Interesting. I though status_of_proc was a default LSB functions. Maybe it is a debianism. Can you post the previous init script that was working for suse?

EDIT: Possible resolution in the thread: viewtopic.php?t=24470#83870
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
abrist
Red Shirt
 
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Previous

Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 8 guests