Problem with restart

Mike McClure mmcclure at pneservices.com
Tue Sep 2 21:54:56 CEST 2003


What those errors mean is that the "su" in the script isn't working properly.  It
looks like the home directory for the "nagios" user is invalid or missing, or the
user is locked out or disabled.

Do you get the same errors from "/etc/rc.d/init.d/nagios start"?

Try taking out the "-l" in the line:

su -l $Nagios -c "touch $NagiosVar/nagios.log $NagiosSav"

That will keep su from doing a full login.  That might get rid of the error messages
without affecting the function of the script.

The errors are not fatal, like you said, it restarts anyway.  All it's doing is
making sure that a couple of files exist before Nagios starts up.  I don't think
it's absolutely necessary to have those files anyway, is it?  Someone please correct
me if I'm wrong.

An alternative to the "su" might be this:

---
# Flavor NagiosGrp to taste
NagiosGrp=nagios
touch $NagiosVar/nagios.log $NagiosSav
chown $Nagios:$NagiosGrp $NagiosVar/nagios.log $NagiosSav
chmod 640 $NagiosVar/nagios.log $NagiosSav
---


> What operating system and version are you using?  What Nagios version?
> Red Hat Linux 9
> Nagios 1.1
>
> Did you create the "nagios" user as described in the instructions?
> Yes
>
> What userid are you executing "/etc/rc.d/init.d/nagios restart" as?  What shell?
> root
> bash
>
> What is the content of your "/etc/rc.d/init.d/nagios" file?
> I did not make any changes to the "nagios" file that was installed with 1.1.
> Here it is......
>
>
> #!/bin/sh
>
> #
>
> # chkconfig: 345 99 01
>
> # description: Nagios network monitor
>
> #
>
> # File : nagios
>
> #
>
> # Author : Jorge Sanchez Aymar (jsanchez at lanchile.cl)
>
> #
>
> # Changelog :
>
> #
>
> # 1999-07-09 Karl DeBisschop <kdebisschop at infoplease.com>
>
> # - setup for autoconf
>
> # - add reload function
>
> # 1999-08-06 Ethan Galstad <nagios at nagios.org>
>
> # - Added configuration info for use with RedHat's chkconfig tool
>
> # per Fran Boon's suggestion
>
> # 1999-08-13 Jim Popovitch <jimpop at rocketship.com>
>
> # - added variable for nagios/var directory
>
> # - cd into nagios/var directory before creating tmp files on startup
>
> # 1999-08-16 Ethan Galstad <nagios at nagios.org>
>
> # - Added test for rc.d directory as suggested by Karl DeBisschop
>
> # 2000-07-23 Karl DeBisschop <kdebisschop at users.sourceforge.net>
>
> # - Clean out redhat macros and other dependencies
>
> #
>
> # Description: Starts and stops the Nagios monitor
>
> # used to provide network services status.
>
> #
>
> status_nagios ()
>
> {
>
> if test ! -f $NagiosRun; then
>
> echo "No lock file found in $NagiosRun"
>
> return 1
>
> fi
>
> NagiosPID=`head -n 1 $NagiosRun`
>
> if test -x $NagiosCGI/daemonchk.cgi; then
>
> if $NagiosCGI/daemonchk.cgi -l $NagiosRun; then
>
> return 0
>
> else
>
> return 1
>
> fi
>
> else
>
> if ps -p $NagiosPID; then
>
> return 0
>
> else
>
> return 1
>
> fi
>
> fi
>
> return 1
>
> }
>
>
>
> killproc_nagios ()
>
> {
>
> if test ! -f $NagiosRun; then
>
> echo "No lock file found in $NagiosRun"
>
> return 1
>
> fi
>
> NagiosPID=`head -n 1 $NagiosRun`
>
> kill $2 $NagiosPID
>
> }
>
>
>
> # Source function library
>
> # Solaris doesn't have an rc.d directory, so do a test first
>
> 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
>
> fi
>
> prefix=/usr/local/nagios
>
> exec_prefix=${prefix}
>
> NagiosBin=${exec_prefix}/bin/nagios
>
> NagiosCfg=${prefix}/etc/nagios.cfg
>
> NagiosLog=${prefix}/var/status.log
>
> NagiosTmp=${prefix}/var/nagios.tmp
>
> NagiosSav=${prefix}/var/status.sav
>
> NagiosCmd=${prefix}/var/rw/nagios.cmd
>
> NagiosVar=${prefix}/var
>
> NagiosRun=${prefix}/var/nagios.lock
>
> NagiosLckDir=/var/lock/subsys
>
> NagiosLckFile=nagios
>
> NagiosCGI=${exec_prefix}/sbin
>
> Nagios=nagios
>
> # Check that nagios exists.
>
> test -f $NagiosBin || exit 0
>
> # Check that nagios.cfg exists.
>
> test -f $NagiosCfg || exit 0
>
> # See how we were called.
>
> case "$1" in
>
> start)
>
> echo "Starting network monitor: nagios"
>
> su -l $Nagios -c "touch $NagiosVar/nagios.log $NagiosSav"
>
> rm -f $NagiosCmd
>
> $NagiosBin -d $NagiosCfg
>
> if [ -d $NagiosLckDir ]; then touch $NagiosLckDir/$NagiosLckFile; fi
>
> sleep 1
>
> status_nagios nagios
>
> ;;
>
> stop)
>
> echo "Stopping network monitor: nagios"
>
> killproc_nagios nagios
>
> rm -f $NagiosLog $NagiosTmp $NagiosRun $NagiosLckDir/$NagiosLckFile $NagiosCmd
>
> ;;
>
> status)
>
> status_nagios nagios
>
> ;;
>
> restart)
>
> printf "Running configuration check..."
>
> $NagiosBin -v $NagiosCfg > /dev/null 2>&1;
>
> if [ $? -eq 0 ]; then
>
> echo "done"
>
> $0 stop
>
> $0 start
>
> else
>
> $NagiosBin -v $NagiosCfg
>
> echo "failed - aborting restart."
>
> exit 1
>
> fi
>
> ;;
>
> reload|force-reload)
>
> printf "Running configuration check..."
>
> $NagiosBin -v $NagiosCfg > /dev/null 2>&1;
>
> if [ $? -eq 0 ]; then
>
> echo "done"
>
> if test ! -f $NagiosRun; then
>
> $0 start
>
> else
>
> NagiosPID=`head -n 1 $NagiosRun`
>
> if status_nagios > /dev/null; then
>
> printf "Reloading nagios configuration..."
>
> killproc_nagios nagios -HUP
>
> echo "done"
>
> else
>
> $0 stop
>
> $0 start
>
> fi
>
> fi
>
> else
>
> $NagiosBin -v $NagiosCfg
>
> echo "failed - aborting reload."
>
> exit 1
>
> fi
>
> ;;
>
> *)
>
> echo "Usage: nagios {start|stop|restart|reload|force-reload|status}"
>
> exit 1
>
> ;;
>
> esac
>
> # End of this script
>
> Thanks for the help!
>
> -Josh
>
> 	-----Original Message-----
> 	From: Mike McClure [mailto:mmcclure at pneservices.com]
> 	Sent: Tue 9/2/2003 1:47 PM
> 	To: nagios-users at lists.sourceforge.net
> 	Cc:
> 	Subject: Re: [Nagios-users] Problem with restart
>
>
>
> 	What operating system and version are you using?  What Nagios version?
>
> 	Did you create the "nagios" user as described in the instructions?
>
> 	What userid are you executing "/etc/rc.d/init.d/nagios restart" as?  What shell?
>
> 	What is the content of your "/etc/rc.d/init.d/nagios" file?
>
> 	> If I issue the following command:
> 	>
> 	> /etc/rc.d/init.d/nagios restart
> 	>
> 	> I receive the following:
> 	>
> 	> Running configuration check...done
> 	> Stopping network monitor: nagios
> 	> Starting network monitor: nagios
> 	> su: warning: cannot change directory to : No such file or directory
> 	> This account is currently not available.
> 	>   PID TTY          TIME CMD
> 	> 27803 ?        00:00:00 nagios
> 	>
> 	>
> 	> What do these lines mean:
> 	> su: warning: cannot change directory to : No such file or directory
> 	> This account is currently not available.
> 	>
> 	>
> 	> Did I set something up incorrectly?  The service does seem to restart
> 	> correctly......
> 	>
> 	> TIA,
> 	> Josh
> 	>
>
>
> 	--
> 	Mike McClure, CCIE # 5125, CISSP # 30232
> 	PNE Services, Inc. -  http://www.pneservices.com
> 	mmcclure [at] pneservices [dot] com
> 	mobile: 913-636-5590
>
>
>
> 	-------------------------------------------------------
> 	This sf.net email is sponsored by:ThinkGeek
> 	Welcome to geek heaven.
> 	http://thinkgeek.com/sf
> 	_______________________________________________
> 	Nagios-users mailing list
> 	Nagios-users at lists.sourceforge.net
> 	https://lists.sourceforge.net/lists/listinfo/nagios-users
> 	::: Please include Nagios version, plugin version (-v) and OS when reporting any
> issue.
> 	::: Messages without supporting info will risk being sent to /dev/null
>
>
>


-- 
Mike McClure, CCIE # 5125, CISSP # 30232
PNE Services, Inc. -  http://www.pneservices.com
mmcclure [at] pneservices [dot] com
mobile: 913-636-5590



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list