Page 2 of 3

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 2:47 pm
by Bigpaddy_Irl
Ok I have now got as far as....

/etc/init.d/nagios start

But then I get an error

"/etc/init.d/nagios: 20: .: Can't open /etc/rc.d/init.d/functions"

Googled the problem, but with no result.

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 2:51 pm
by slansing
Did this error our while you were compiling? Did the compile finish?

If so, do you have:

Code: Select all

/etc/init.d/nagios

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 3:29 pm
by slansing
We have a hack-ish fix replace your nagios init script with this:

Code: Select all

# pidfile: /var/nagios/nagios.pid
#
### BEGIN INIT INFO
# Provides:      nagios
# Required-Start:   $local_fs $syslog $network
# Required-Stop:   $local_fs $syslog $network
# Short-Description:   start and stop Nagios monitoring server
# Description:      Nagios is is a service monitoring system
### END INIT INFO

# Source function library.
# . /etc/rc.d/init.d/functions
. /lib/lsb/init-functions

prefix="/usr/local/nagios"
exec_prefix="${prefix}"
exec="${exec_prefix}/bin/nagios"
prog="nagios"
config="${prefix}/etc/nagios.cfg"
pidfile="${prefix}/var/nagios.lock"
user="nagios"
group="nagios"
checkconfig="false"
ramdiskdir="/var/nagios/ramcache"

test -e /etc/sysconfig/$prog && . /etc/sysconfig/$prog

lockfile=/var/lock/$prog
USE_RAMDISK=${USE_RAMDISK:-0}

if test "$USE_RAMDISK" -ne 0 && test "$RAMDISK_SIZE"X != "X"; then
   ramdisk=`mount |grep "$ramdiskdir type tmpfs"`
   if [ "$ramdisk"X == "X" ]; then
      mkdir -p -m 0755 $ramdiskdir
      mount -t tmpfs -o size=${RAMDISK_SIZE}m tmpfs $ramdiskdir
      mkdir -p -m 0755 $ramdiskdir/checkresults
      chown -R $user:$group $ramdiskdir
   fi
fi

check_config() {
   TMPFILE="/tmp/.configtest.$$"
   /usr/sbin/service nagios configtest > "$TMPFILE"
   WARN=`grep ^"Total Warnings:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g`
   ERR=`grep ^"Total Errors:" "$TMPFILE" |awk -F: '{print \$2}' |sed s/' '//g`

   if test "$WARN" = "0" && test "${ERR}" = "0"; then
      echo "OK - Configuration check verified" > /var/run/nagios.configtest
      chmod 0644 /var/run/nagios.configtest
      /bin/rm "$TMPFILE"
   return 0
   else
      # We'll write out the errors to a file we can have a
      # script watching for
      echo "WARNING: Errors in config files - see log for details: $TMPFILE" > /var/run/nagios.configtest
      egrep -i "(^warning|^error)" "$TMPFILE" >> /var/run/nagios.configtest
      chmod 0644 /var/run/nagios.configtest
      cat "$TMPFILE"
   exit 8
   fi
}

start() {
   test -x $exec || exit 5
   test -f $config || exit 6
   if test "$checkconfig" = "false"; then
      check_config
   fi
   echo -n $"Starting $prog: "
   # We need to _make sure_ the precache is there and verified
   # Raise priority to make it run better
   daemon --user=$user -- $exec -d $config
   #touch $lockfile
   retval=$?
   echo
   test $retval -eq 0 && touch $lockfile
   return $retval
}

stop() {
   echo -n $"Stopping $prog: "
   killproc -p ${pidfile}  $exec
   retval=$?
   echo
   test $retval -eq 0 && rm -f $lockfile
   return $retval
}


restart() {
   check_config
   checkconfig="true"
   stop
   start
}

reload() {
   echo -n $"Reloading $prog: "
   killproc -p ${pidfile} $exec -HUP
   RETVAL=$?
   echo
}

force_reload() {
   restart
}

case "$1" in
   start)
      status_of_proc $prog && exit 0
      $1
      ;;
   stop)
      status_of_proc $prog|| exit 0
      $1
      ;;
   restart)
      $1
      ;;
   reload)
      status_of_proc $prog || exit 7
      $1
      ;;
   force-reload)
      force_reload
      ;;
   status)
      status_of_proc $prog
      ;;
   condrestart|try-restart)
      status_of_proc $prog|| exit 0
      restart
      ;;
   configtest)
      $nice su -s /bin/bash - nagios -c "$corelimit >/dev/null 2>&1 ; $exec -vp $config"
      RETVAL=$?
      ;;
   *)
      echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
      exit 2
esac
exit $?
And install:

Code: Select all

apt-get install daemon
Then try to start nagios:

Code: Select all

/etc/init.d/nagios start

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 4:04 pm
by Bigpaddy_Irl
/etc/init.d/nagios: 20: .: Can't open /etc/rc.d/init.d/functions tells me that there is no such directory.

I have followed your hack-ish option to the letter and when I try to start nagios I get this...



/etc/init.d/nagios start
status: Unknown job: nagios
/etc/init.d/nagios: 73: test: false: unexpected operator
$Starting nagios: Invalid --user argument: 'd' (unknown user d)
usage: daemon [options] [--] [cmd arg...]
options:

-h, --help - Print a help message then exit
-V, --version - Print a version message then exit
-v, --verbose[=level] - Set the verbosity level
-d, --debug[=level] - Set the debugging level

-C, --config=path - Specify the configuration file
-N, --noconfig - Bypass the system configuration file
-n, --name=name - Guarantee a single named instance
-X, --command=cmd - Specify the client command as an option
-P, --pidfiles=/dir - Override standard pidfile location
-F, --pidfile=/path - Override standard pidfile name and location

-u, --user=user[:group] - Run the client as user[:group]
-R, --chroot=path - Run the client with path as root
-D, --chdir=path - Run the client in directory path
-m, --umask=umask - Run the client with the given umask
-e, --env="var=val" - Set a client environment variable
-i, --inherit - Inherit environment variables
-U, --unsafe - Allow execution of unsafe executable
-S, --safe - Deny execution of unsafe executable
-c, --core - Allow core file generation

-r, --respawn - Respawn the client when it terminates
-a, --acceptable=# - Minimum acceptable client duration (seconds)
-A, --attempts=# - Respawn # times on error before delay
-L, --delay=# - Delay between spawn attempt bursts (seconds)
-M, --limit=# - Maximum number of spawn attempt bursts
--idiot - Idiot mode (trust root with the above)

-f, --foreground - Run the client in the foreground
-p, --pty[=noecho] - Allocate a pseudo terminal for the client

-l, --errlog=spec - Send daemon's error output to syslog or file
-b, --dbglog=spec - Send daemon's debug output to syslog or file
-o, --output=spec - Send client's output to syslog or file
-O, --stdout=spec - Send client's stdout to syslog or file
-E, --stderr=spec - Send client's stderr to syslog or file

--running - Check if a named daemon is running
--restart - Restart a named daemon client
--stop - Terminate a named daemon process

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 4:05 pm
by Bigpaddy_Irl
The compile completed perfectly with no errors.

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 4:19 pm
by slansing
Did you copy the entire script from above? You need to replace the entire nagios init script with the above code section and it should work fine, this solved the same issue minutes ago here:

http://support.nagios.com/forum/viewtop ... =7&t=21578

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 4:29 pm
by Bigpaddy_Irl
Apologies, I did not see the rest of the script.

nagios is now running, so I will continue with the rest of the installation.

BTW what actually is going wrong here?

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 4:35 pm
by slansing
I do not know the whole background on this issue but I believe the init script was trying to reference things that did not exist in the 4.0 installation of Nagios Core on debian based systems.

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 4:47 pm
by Bigpaddy_Irl
Unfortunatly im stuck again.

Got as far as

chkconfig --add nagios

But getting the error...


The program 'chkconfig' is currently not installed. You can install it by typing:
apt-get install chkconfig
A quick googling tells me that chkconfig is no longer available for Ubuntu?

Re: New Installation - can not find .cfg file

Posted: Mon Oct 07, 2013 4:51 pm
by tmcdonald
Take a look at the replacement for chkconfig, update-rc.d

http://askubuntu.com/questions/2263/chk ... ntu-server

You want to run

Code: Select all

update-rc.d nagios defaults