LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Nagios Help (https://www.linuxquestions.org/questions/linux-newbie-8/nagios-help-870577/)

rajesh22 03-23-2011 04:27 PM

Nagios Help
 
Hi,

I have configured nagios on my local VM machine and i got no error

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check


But when i am unable to start nagios
# service nagios start
nagios: unrecognized service

Can anybody help me to fix this issue ?

Thanks in advance

corp769 03-23-2011 04:29 PM

Can you show me the output of the following:
Code:

ls -al /etc/rc.d/init.d/nagios*


---------- Post added 03-23-11 at 10:29 PM ----------

And what distro are you using?

rajesh22 03-23-2011 04:38 PM

# ls -al /etc/rc.d/init.d/nagios*
ls: /etc/rc.d/init.d/nagios*: No such file or directory

corp769 03-23-2011 04:52 PM

Create a new file called nagios in /etc/rc.d/init.d/ with the following command and chmod it to 755:
Code:

touch /etc/rc.d/init.d/nagios
chmod /etc/rc.d/init.d/nagios 755

Then use gedit or any program to edit the file, and paste the following contents into it and save it:
Code:

#!/bin/sh
#
# chkconfig: - 99 01
# description: Nagios network monitor
#
# File : nagios
#
# Author : Jorge Sanchez Aymar (jsanchez@lanchile.cl)
#
# Changelog :
#
# 1999-07-09 Karl DeBisschop <kdebisschop@infoplease.com>
#  - setup for autoconf
#  - add reload function
# 1999-08-06 Ethan Galstad <egalstad@nagios.org>
#  - Added configuration info for use with RedHat's chkconfig tool
#    per Fran Boon's suggestion
# 1999-08-13 Jim Popovitch <jimpop@rocketship.com>
#  - added variable for nagios/var directory
#  - cd into nagios/var directory before creating tmp files on startup
# 1999-08-16 Ethan Galstad <egalstad@nagios.org>
#  - Added test for rc.d directory as suggested by Karl DeBisschop
# 2000-07-23 Karl DeBisschop <kdebisschop@users.sourceforge.net>
#  - Clean out redhat macros and other dependencies
# 2003-01-11 Ethan Galstad <egalstad@nagios.org>
#  - Updated su syntax (Gary Miller)
#
# Description: Starts and stops the Nagios monitor
#              used to provide network services status.
#
 
status_nagios ()
{

        if test -x $NagiosCGI/daemonchk.cgi; then
                if $NagiosCGI/daemonchk.cgi -l $NagiosRunFile; then
                        return 0
                else
                        return 1
                fi
        else
                if ps -p $NagiosPID > /dev/null 2>&1; then
                        return 0
                else
                        return 1
                fi
        fi

        return 1
}


printstatus_nagios()
{
        status_nagios $1 $2
        RETVAL=$?
        if [ $RETVAL = 0 ]; then
                echo "nagios (pid $NagiosPID) is running..."
        else
                echo "nagios is not running"
        fi
        return $RETVAL
}


killproc_nagios ()
{

        kill $2 $NagiosPID

}


pid_nagios ()
{

        if test ! -f $NagiosRunFile; then
                echo "No lock file found in $NagiosRunFile"
                exit 1
        fi

        NagiosPID=`head -n 1 $NagiosRunFile`
}


# 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/share/nagios
exec_prefix=/var/lib/nagios
NagiosBin=/usr/sbin/nagios
NagiosCfgFile=/etc/nagios/nagios.cfg
NagiosStatusFile=/var/log/nagios/status.dat
NagiosRetentionFile=/var/log/nagios/retention.dat
NagiosCommandFile=/var/log/nagios/rw/nagios.cmd
NagiosVarDir=/var/log/nagios
NagiosRunFile=/var/run/nagios.pid
NagiosLockDir=/var/lock/subsys
NagiosLockFile=nagios
NagiosCGIDir=/usr/sbin
NagiosUser=nagios
NagiosGroup=nagios
         

# Check that nagios exists.
if [ ! -f $NagiosBin ]; then
    echo "Executable file $NagiosBin not found.  Exiting."
    exit 1
fi

# Check that nagios.cfg exists.
if [ ! -f $NagiosCfgFile ]; then
    echo "Configuration file $NagiosCfgFile not found.  Exiting."
    exit 1
fi
         
# See how we were called.
case "$1" in

        start)
                echo -n "Starting nagios:"
                $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
                if [ $? -eq 0 ]; then
                        touch $NagiosVarDir/nagios.log $NagiosRetentionFile
                        chown $NagiosUser:$NagiosGroup $NagiosVarDir/nagios.log $NagiosRetentionFile
                        rm -f $NagiosCommandFile
                        touch $NagiosRunFile
                        chown $NagiosUser:$NagiosGroup $NagiosRunFile
                        [ -x /sbin/restorecon ] && /sbin/restorecon $NagiosRunFile
                        $NagiosBin -d $NagiosCfgFile
                        pidof nagios > $NagiosRunFile
                        if [ -d $NagiosLockDir ]; then touch $NagiosLockDir/$NagiosLockFile; fi
                        echo " done."
                        exit 0
                else
                        echo "CONFIG ERROR!  Start aborted.  Check your Nagios configuration."
                        exit 1
                fi
                ;;

        stop)
                echo -n "Stopping nagios: "

                pid_nagios
                killproc_nagios nagios

                # now we have to wait for nagios to exit and remove its
                # own NagiosRunFile, otherwise a following "start" could
                # happen, and then the exiting nagios will remove the
                # new NagiosRunFile, allowing multiple nagios daemons
                # to (sooner or later) run - John Sellens
                #echo -n 'Waiting for nagios to exit .'
                for i in 1 2 3 4 5 6 7 8 9 10 ; do
                    if status_nagios > /dev/null; then
                        echo -n '.'
                        sleep 1
                    else
                        break
                    fi
                done
                if status_nagios > /dev/null; then
                    echo ''
                    echo 'Warning - nagios did not exit in a timely manner'
                else
                    echo 'done.'
                fi

                rm -f $NagiosStatusFile $NagiosRunFile $NagiosLockDir/$NagiosLockFile $NagiosCommandFile
                ;;

        status)
                pid_nagios
                printstatus_nagios nagios
                exit $?
                ;;

        checkconfig)
                printf "Running configuration check..."
                $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
                if [ $? -eq 0 ]; then
                        echo " OK."
                else
                        echo " CONFIG ERROR!  Check your Nagios configuration."
                        exit 1
                fi
                ;;

        restart)
                printf "Running configuration check..."
                $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
                if [ $? -eq 0 ]; then
                        echo "done."
                        $0 stop
                        $0 start
                else
                        echo " CONFIG ERROR!  Restart aborted.  Check your Nagios configuration."
                        exit 1
                fi
                ;;

        reload|force-reload)
                printf "Running configuration check..."
                $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
                if [ $? -eq 0 ]; then
                        echo "done."
                        if test ! -f $NagiosRunFile; then
                                $0 start
                        else
                                pid_nagios
                                if status_nagios > /dev/null; then
                                        printf "Reloading nagios configuration..."
                                        killproc_nagios nagios -HUP
                                        echo "done"
                                else
                                        $0 stop
                                        $0 start
                                fi
                        fi
                else
                        echo " CONFIG ERROR!  Reload aborted.  Check your Nagios configuration."
                        exit 1
                fi
                ;;

        *)
                echo "Usage: nagios {start|stop|restart|reload|force-reload|status|checkconfig}"
                exit 2
                ;;

esac
 
# End of this script


rajesh22 03-23-2011 05:02 PM

# /etc/init.d/nagios start
/etc/init.d/nagios: line 1: kconfig:: command not found
Executable file /usr/sbin/nagios not found. Exiting.

arunpmenon 03-23-2011 05:18 PM

Change these variable in init script according to your installation.

"NagiosBin="
"NagiosCfgFile="

anishkumarv 03-23-2011 06:37 PM

Hi rajesh,

I think you forget this step while compiling nagios

Quote:

make install-init
once you install init you got that init config file so then you can able to start the nagios.!!!

rajesh22 03-24-2011 03:20 AM

Quote:

Originally Posted by anishkumarv (Post 4301151)
Hi rajesh,

I think you forget this step while compiling nagios



once you install init you got that init config file so then you can able to start the nagios.!!!

Thanks for your reply.I can able to start nagios service.But when i try to browse http://localhost/nagios. I am getting error as

Not Found

The requested URL /nagios was not found on this server.
Apache/2.2.3 (CentOS) Server at localhost Port 80

Any idea ?


I found both apache and nagios are running now.

Thanks

EricTRA 03-24-2011 03:23 AM

Hello,

You need to configure Apache in order to be able to access Nagios. Have a look at this documentation.

Kind regards,

Eric

anishkumarv 03-24-2011 03:59 AM

Hi rajesh,


Please while compiling do with complete documents, for nagios in nagios forums itself most of the details available, so please go through documents first

http://www.ziddu.com/download/143199...agios.doc.html

Download this doc, i hope its really useful for you, with out entry in Apache also its work fine, please disable the SELINUX context and try.

rajesh22 03-24-2011 10:32 AM

I have a doubt whether need to do nagios installation on /etc or we can do any location like / ?

---------- Post added 03-24-11 at 10:33 AM ----------

Quote:

Originally Posted by EricTRA (Post 4301424)
Hello,

You need to configure Apache in order to be able to access Nagios. Have a look at this documentation.

Kind regards,

Eric

I am getting error by adding the above in httpd.conf

anishkumarv 03-24-2011 12:42 PM

Hi rajesh,

Its your wish only u can install anywhere!!!

rajesh22 03-24-2011 12:47 PM

Quote:

Originally Posted by anishkumarv (Post 4301446)
Hi rajesh,


Please while compiling do with complete documents, for nagios in nagios forums itself most of the details available, so please go through documents first

http://www.ziddu.com/download/143199...agios.doc.html

Download this doc, i hope its really useful for you, with out entry in Apache also its work fine, please disable the SELINUX context and try.



I have tried the steps mentioed in the wordfile and i get no error too.But i am not getting nagios page.I have disable setenforce 0 and tried but no lucky whether you have anyother idea ?

anishkumarv 03-24-2011 01:06 PM

Hi,

still its showing ??

Total Warnings: 0
Total Errors: 0

or any other error messages!!! please post the logs

rajesh22 03-24-2011 01:11 PM

Nagios Core 3.2.3
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-03-2010
License: GPL

Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
Checked 8 services.
Checking hosts...
Checked 1 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
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


All times are GMT -5. The time now is 06:53 AM.