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

anishkumarv 03-24-2011 01:20 PM

Hi,

While restarting the nagios service it shows any error???

rajesh22 03-24-2011 01:26 PM

# service nagios start
Starting nagios: done.
# service nagios status
nagios (pid 709) is running...
# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

anishkumarv 03-24-2011 06:13 PM

Hi,

http://localhost/nagios/


while giving this url what error its showing in whether page not found or anything else..and plese check the /var/log/messages and post the error messages...i didnt know in which step you are exactly struggling that why i asked to post the messages...

rajesh22 03-25-2011 08:46 AM

Anish really thanks for your effort in helping me

http://localhost/nagios
Not Found

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


Mar 25 06:44:03 localhost nagios: Successfully shutdown... (PID=11442)
Mar 25 06:44:04 localhost nagios: Nagios 3.2.3 starting... (PID=23955)
Mar 25 06:44:04 localhost nagios: Local time is Fri Mar 25 06:44:04 PDT 2011
Mar 25 06:44:04 localhost nagios: LOG VERSION: 2.0
Mar 25 06:44:04 localhost nagios: Finished daemonizing... (New PID=23956)
Mar 25 06:44:24 localhost nagios: SERVICE ALERT: localhost;HTTP;CRITICAL;HARD;4;HTTP CRITICAL - No data received from host

anishkumarv 03-25-2011 01:11 PM

Quote:

# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
# Last Modified: 11-26-2005
#
# This file contains examples of entries that need
# to be incorporated into your Apache web server
# configuration file. Customize the paths, etc. as
# needed to fit your system.

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>
While compiling nagios its default nagios httpd entry comes under /etc/http/conf.d/nagios.conf
but i think you doing some mistake while compiling so please put this entry in that path manually. i installed nagios in /usr/local/ so i mention in the above file that path please change according to your installation. and restart the httpd and nagios service...and try..i hope it works..

rajesh22 03-25-2011 01:58 PM

/etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [Fri Mar 25 11:57:07 2011] [warn] The ScriptAlias directive in /etc/httpd/conf/httpd.conf at line 298 will probably never match because it overlaps an earlier ScriptAlias.
[Fri Mar 25 11:57:07 2011] [warn] The Alias directive in /etc/httpd/conf/httpd.conf at line 315 will probably never match because it overlaps an earlier Alias.
[ OK ]

I am getting error when restarting httpd

rajesh22 03-25-2011 02:01 PM

I can able to see the nagios.conf in the following location: /etc/http/conf.d/nagios.conf

rajesh22 03-25-2011 02:05 PM

Thanks for your great effort Anish i got the nagios page now.If i need any help i will get in touch with you

rajesh22 03-25-2011 02:15 PM

What is the default username and password of nagios ? can i know how to reset nagios default username and password please

anishkumarv 03-25-2011 02:46 PM

5. Configure the web interface.
[root@localhost]# make install-webconf
[root@localhost# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin


Please follow the steps numb 5 in the doc which i posted before this password only we'll give while accessing URL.

Read The document properly and configure , go through the nagios documentation in nagios.org website.

anishkumarv 03-25-2011 06:36 PM

Hi rajesh,

Mark your thread as [SOLVED] if your questions are answered, and give reputation if you feel like it.

corp769 03-25-2011 06:37 PM

Hey anishkumarv, way to copy part of my signature into your own. At least edit it a bit to change it up next time.

Josh

anishkumarv 03-25-2011 06:42 PM

Hi corp,

Ha Ha Ha!!!!!! :-) ;-) :-)

corp769 03-25-2011 06:44 PM

You really thought that I wouldn't see that? :D LOL

anishkumarv 03-25-2011 06:50 PM

Quote:

Hey anishkumarv, way to copy part of my signature into your own. At least edit it a bit to change it up next time.

Josh
Mark your thread as [SOLVED] if your questions are answered, and give reputation if you feel like it.

If you're motivated by money you'll stay chasing it. If you're motivated by passion you'll stay living it.


Compare your signature!!! with me..lot of difference in that, don't argue for this like childish!!! we have lot of things in linux to discuss here....even if you thought i copied from yours mean also..i dont care..and i wont change!!! my signature for any reason..dont make me laugh lot..!!lolz!!

corp769 03-25-2011 06:52 PM

Quote:

Originally Posted by anishkumarv (Post 4303617)
Mark your thread as [SOLVED] if your questions are answered, and give reputation if you feel like it.

If you're motivated by money you'll stay chasing it. If you're motivated by passion you'll stay living it.


Compare your signature!!! with me..lot of difference in that, don't argue for this like childish!!! we have lot of things in linux to discuss here....even if you thought i copied from yours mean also..i dont care..and i wont change!!! my signature for any reason..dont make me laugh lot..!!lolz!!

Exactly why I said something LOL.... I don't care at all, I just wanted to point it out :p

anishkumarv 03-25-2011 06:54 PM

Hi rajesh!!!


If your problem solved means..regarding nagios....Mark your thread as [SOLVED] if your questions are answered, and give reputation if you feel like it........:-)

repo 03-26-2011 03:31 AM

Please stay on topic.

Kind regards

corp769 03-26-2011 03:37 AM

Quote:

Originally Posted by repo (Post 4303883)
Please stay on topic.

Kind regards

I was killing some time before because the forums were dead, and I am waiting on a reply from the OP. Technically speaking, I am being productive. You are too by "yelling" at me. :)

But to the OP - I just want to know if you have it all figured out.

rajesh22 03-26-2011 11:36 AM

Forbidden

You don't have permission to access /nagios/ on this server.
Apache/2.2.3 (CentOS) Server at localhost Port 80


I cant able to login even i try to reset the password of nagiosadmin

Can you please help me on this ?

anishkumarv 03-27-2011 08:48 PM

Hi rajesh !!!

http://www.linuxquestions.org/questi...server-738536/

check out this link!!! It may helpful to u!!!

rajesh22 03-28-2011 11:48 AM

Anish thanks.But still the problem presist i can see the nagios home page now .But when i click menus it prompt for username and password again.When i give the same username and password which i used for http://localhost/nagios is not working. do you have any idea about this ?

rajesh22 03-28-2011 03:01 PM

I am getting the following error in httpd error log

[Mon Mar 28 12:46:14 2011] [error] [client 127.0.0.1] access to /nagios/cgi-bin/status.cgi failed, reason: verification of user id 'nagiosadmin' not configured, referer: http://localhost/nagios/side.php
[Mon Mar 28 12:46:15 2011] [error] [client 127.0.0.1] (2)No such file or directory: Could not open password file: /url/local/nagios/etc/htpasswd.users, referer: http://localhost/nagios/side.php
[Mon Mar 28 12:46:15 2011] [error] [client 127.0.0.1] access to /nagios/cgi-bin/status.cgi failed, reason: verification of user id 'nagiosadmin' not configured, referer: http://localhost/nagios/side.php
[Mon Mar 28 12:46:22 2011] [error] [client 127.0.0.1] (2)No such file or directory: Could not open password file: /url/local/nagios/etc/htpasswd.users, referer: http://localhost/nagios/side.php
[Mon Mar 28 12:46:22 2011] [error] [client 127.0.0.1] access to /nagios/cgi-bin/status.cgi failed, reason: verification of user id 'admin' not configured, referer: http://localhost/nagios/side.php
[Mon Mar 28 12:46:27 2011] [error] [client 127.0.0.1] (2)No such file or directory: Could not open password file: /url/local/nagios/etc/htpasswd.users, referer: http://localhost/nagios/side.php
[Mon Mar 28 12:46:27 2011] [error] [client 127.0.0.1] access to /nagios/cgi-bin/status.cgi failed, reason: verification of user id 'nagios' not configured, referer: http://localhost/nagios/side.php
[Mon Mar 28 12:47:52 2011] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
[Mon Mar 28 12:52:52 2011] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
[Mon Mar 28 12:57:52 2011] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/

rajesh22 04-03-2011 12:35 PM

anybody to help me to fix this issue ?

rajesh22 04-18-2011 04:51 PM

Hi,

Issue has been fixed by disable SELINUX


All times are GMT -5. The time now is 11:25 AM.