Cant Launch Nagios Daemon - HELP :)

Engage with the community of users including those using the open source solutions.
Includes Nagios Core, Plugins, and NCPA

Cant Launch Nagios Daemon - HELP :)

Postby Dualsweat » Mon Oct 07, 2013 2:56 pm

Hello All,

I followed the quick start guide to install Nagios 4.0 on Ubuntu 12.04. Unfortunately I get the following error consistently. Can anyone help with this?

root@PowerEdge-1850-1:/etc/init.d# /etc/init.d/nagios start
/etc/init.d/nagios: 20: .: Can't open /etc/rc.d/init.d/functions
root@PowerEdge-1850-1:/etc/init.d#

Again, from local dir:

root@PowerEdge-1850-1:/etc/init.d# ./nagios
./nagios: 20: .: Can't open /etc/rc.d/init.d/functions


Thank You,

Matt m.------

Here is some additional information:

root@PowerEdge-1850-1:/etc/init.d# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.0.0
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 09-20-2013
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check
root@PowerEdge-1850-1:/etc/init.d#

Code: Select all
#!/bin/sh

# Nagios        Startup script for the Nagios monitoring daemon
#
# chkconfig:    - 85 15
# description:  Nagios is a service monitoring system
# processname: nagios
# config: /etc/nagios/nagios.cfg
# 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

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/subsys/$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.$$"
        /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 -ud $config
        retval=$?
        echo
        test $retval -eq 0 && touch $lockfile
        return $retval
}

stop() {
        echo -n $"Stopping $prog: "
        killproc -p ${pidfile} -d 10 $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 $prog && exit 0
                $1
        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 $prog && exit 0
                $1
                ;;
        stop)
                status $prog|| exit 0
                $1
                ;;
        restart)
                $1
                ;;
        reload)
                status $prog || exit 7
                $1
                ;;
        force-reload)
                force_reload
                ;;
        status)
                status $prog
                ;;
        condrestart|try-restart)
                status $prog|| exit 0
                restart
                ;;
        configtest)
                $nice runuser -s /bin/bash - $user -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 $?
(END)
Last edited by Dualsweat on Mon Oct 07, 2013 2:58 pm, edited 1 time in total.
Dualsweat
 
Posts: 13
Joined: Mon Oct 07, 2013 2:44 pm

Re: Cant Launch Nagios Daemon - HELP :)

Postby tmcdonald » Mon Oct 07, 2013 3:18 pm

I went ahead and combined your posts into one, and threw some code tags around your, well, code. Just makes it easier on the eyes of us poor ol' tech support folk :)
Former Nagios employee
tmcdonald
 
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Cant Launch Nagios Daemon - HELP :)

Postby slansing » Mon Oct 07, 2013 3:28 pm

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
slansing
 
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Cant Launch Nagios Daemon - HELP :)

Postby Dualsweat » Mon Oct 07, 2013 3:34 pm

Thanks Guys!

I installed the daemon and modified the file, here is the output.

root@PowerEdge-1850-1:/etc/init.d# ./nagios start
status: Unknown job: nagios
./nagios: 74: 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

root@PowerEdge-1850-1:/etc/init.d#


Here is the change:

#!/bin/sh

# Nagios Startup script for the Nagios monitoring daemon
#
# chkconfig: - 85 15
# description: Nagios is a service monitoring system
# processname: nagios
# config: /etc/nagios/nagios.cfg
# 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
Last edited by slansing on Mon Oct 07, 2013 3:50 pm, edited 2 times in total.
Reason: Do not make double posts, just edit your previous post. Thank you. Also, please use code wraps for your code.
Dualsweat
 
Posts: 13
Joined: Mon Oct 07, 2013 2:44 pm

Re: Cant Launch Nagios Daemon - HELP :)

Postby slansing » Mon Oct 07, 2013 3:51 pm

You need to change the entire script, just replace the nagios init script with "the entire" script I linked, not the first lines.
slansing
 
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Cant Launch Nagios Daemon - HELP :)

Postby Dualsweat » Mon Oct 07, 2013 3:58 pm

Oh! Dur! Thanks Guys!

I believe this is the correct outout now?


root@PowerEdge-1850-1:/etc/init.d# ./nagios start
* is running
root@PowerEdge-1850-1:/etc/init.d#



Thank You!

Matt M.------
Dualsweat
 
Posts: 13
Joined: Mon Oct 07, 2013 2:44 pm

Re: Cant Launch Nagios Daemon - HELP :)

Postby slansing » Mon Oct 07, 2013 4:02 pm

It appears to be running, please share the output from this:

Code: Select all
/etc/init.d/nagios restart


Don't call it from within init.d.

Also, can you access your web interface?
slansing
 
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Cant Launch Nagios Daemon - HELP :)

Postby Dualsweat » Mon Oct 07, 2013 4:29 pm

Hi Guys,

Here is the output. Unfirtuantely when I access the it through a web browser it asks me to download a file. The file is a link to download the same file...endless loop. Any ideas?


root@PowerEdge-1850-1:/etc/init.d# /etc/init.d/nagios restart
Stopping nagios:
Starting nagios:
root@PowerEdge-1850-1:/etc/init.d#

Thanks!

MAtt M.-----
Dualsweat
 
Posts: 13
Joined: Mon Oct 07, 2013 2:44 pm

Re: Cant Launch Nagios Daemon - HELP :)

Postby slansing » Mon Oct 07, 2013 4:32 pm

Wait wait wait, it asks you to download a file? What address are you trying to use....?? What is the file?
slansing
 
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Cant Launch Nagios Daemon - HELP :)

Postby Dualsweat » Mon Oct 07, 2013 4:38 pm

Hi All,


Yes, it asks me to download a file.

I am using the following address (both locally on the server and from a remote PC on the same local LAN). This happens in both Firefox and IE.

URL: http://172.16.xx.xx/nagios

(I login with credentials)

Then is asks me to download a file:

Here are the contents of the file (IE):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

<html>
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<title>Nagios Core</title>
<link rel="shortcut icon" href="images/favicon.ico" type="image/ico">
</head>

<?php
// allow specifying main window URL for permalinks, etc.
$corewindow="main.php";
if(isset($_GET['corewindow'])){

// default window url may have been overridden with a permalink...
$rawurl=$_GET['corewindow'];

// parse url and remove permalink option from base
$a=parse_url($rawurl);

// build base url
if(isset($a["host"]))
$windowurl=$a["scheme"]."://".$a["host"].$a["path"]."?";
else
$windowurl=$a["path"]."?";

$q="";
if(isset($a["query"]))
$q=$a["query"];

$pairs=explode("&",$q);
foreach($pairs as $pair){
$v=explode("=",$pair);
if(is_array($v))
$windowurl.="&".urlencode($v[0])."=".urlencode(isset($v[1])?$v[1]:"");
}


$corewindow=$windowurl;
}
?>


<frameset cols="180,*" style="border: 0px; framespacing: 0px">
<frame src="side.php" name="side" frameborder="0" style="">
<frame src="<?php echo $corewindow;?>" name="main" frameborder="0" style="">

<noframes>
<!-- This page requires a web browser which supports frames. -->
<h2>Nagios Core</h2>
<p align="center">
<a href="http://www.nagios.org/">www.nagios.org</a><br>
Copyright &copy; 2010-<?php echo date("Y");?> Nagios Core Development Team and Community Contributors.
Copyright &copy; 1999-2010 Ethan Galstad<br>
</p>
<p>
<i>Note: These pages require a browser which supports frames</i>
</p>
</noframes>

</frameset>

</html>


Here are the contents of Firefox:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

<html>
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<title>Nagios Core</title>
<link rel="shortcut icon" href="images/favicon.ico" type="image/ico">
</head>

<?php
// allow specifying main window URL for permalinks, etc.
$corewindow="main.php";
if(isset($_GET['corewindow'])){

// default window url may have been overridden with a permalink...
$rawurl=$_GET['corewindow'];

// parse url and remove permalink option from base
$a=parse_url($rawurl);

// build base url
if(isset($a["host"]))
$windowurl=$a["scheme"]."://".$a["host"].$a["path"]."?";
else
$windowurl=$a["path"]."?";

$q="";
if(isset($a["query"]))
$q=$a["query"];

$pairs=explode("&",$q);
foreach($pairs as $pair){
$v=explode("=",$pair);
if(is_array($v))
$windowurl.="&".urlencode($v[0])."=".urlencode(isset($v[1])?$v[1]:"");
}


$corewindow=$windowurl;
}
?>


<frameset cols="180,*" style="border: 0px; framespacing: 0px">
<frame src="side.php" name="side" frameborder="0" style="">
<frame src="<?php echo $corewindow;?>" name="main" frameborder="0" style="">

<noframes>
<!-- This page requires a web browser which supports frames. -->
<h2>Nagios Core</h2>
<p align="center">
<a href="http://www.nagios.org/">www.nagios.org</a><br>
Copyright &copy; 2010-<?php echo date("Y");?> Nagios Core Development Team and Community Contributors.
Copyright &copy; 1999-2010 Ethan Galstad<br>
</p>
<p>
<i>Note: These pages require a browser which supports frames</i>
</p>
</noframes>

</frameset>

</html>
Dualsweat
 
Posts: 13
Joined: Mon Oct 07, 2013 2:44 pm

Next

Return to Community Support

Who is online

Users browsing this forum: Google [Bot] and 30 guests