Page 1 of 1

Nagios 3.2.0 won't start as daemon - config problems.

Posted: Wed Sep 03, 2014 8:37 am
by spoko22
Hello,
I compiled and installed Nagios according to http://nagios.sourceforge.net/docs/3_0/ ... buntu.html. There is something wrong with my config though and I hope you could help me get on track.
My Nagios 3.2.0 was installed to /etc/nagios3.

1. Nagios won't run as daemon or as service - ALREADY FIXED SEE http://support.nagios.com/forum/viewtop ... 77#p110577
Nagios will run only, when deployed like

Code: Select all

/etc/nagios3/bin/nagios /etc/nagios3/etc/nagios.cfg
or

Code: Select all

nohup /etc/nagios3/bin/nagios /etc/nagios3/etc/nagios.cfg
However, it will not run when

Code: Select all

/etc/nagios3/bin/nagios -d /etc/nagios3/etc/nagios.cfg
(After I hit "Enter" button nothing more is shown, just next command prompt. Package daemon is installed)
or

Code: Select all

/etc/init.d/nagios start
I checked /etc/init.d/nagios script and directories there seem fine.
Terminal says: "Starting nagios: done.", however no new process is created. Still, I can type /etc/init.d/nagios stop and nagios is killed (always the same PID - 229).

2. Wrong site name - ALREADY FIXED SEE http://support.nagios.com/forum/viewtop ... 05#p110425
It is defined in cgi.cfg; cgi.cfg sits in /etc/nagios3/etc, next to nagios.cfg

Code: Select all

url_html_path=/nagios3
However, my apache2 seems to ignore it, as it creates my site as localhost/nagios instead of localhost/nagios3


My nagios.conf included in apache:

Code: Select all

ScriptAlias /nagios/cgi-bin "/etc/nagios3/sbin"

<Directory "/etc/nagios3/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 /etc/nagios3/etc/htpasswd.users
   Require valid-user
</Directory>

Alias /nagios "/etc/nagios3/share"

<Directory "/etc/nagios3/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 /etc/nagios3/etc/htpasswd.users
   Require valid-user
</Directory>
Have you ever encountered problems like these?

Re: Nagios 3.2.0 won't start as daemon - config problems.

Posted: Wed Sep 03, 2014 8:52 am
by eloyd
Just curious - that is a very old version of Nagios. Is there a reason you're not using a newer version?

Re: Nagios 3.2.0 won't start as daemon - config problems.

Posted: Wed Sep 03, 2014 8:56 am
by spoko22
Yes, there is. This Nagios is going to be a backup copy for other Nagios working on different server (when this different server is down and it quite often is, I want to use this backup server for monitoring our targets). This original server's version 3.2.0, so I decided to install the same one, to make sure all configs are compatible and so on.

Re: Nagios 3.2.0 won't start as daemon - config problems.

Posted: Thu Sep 04, 2014 4:35 am
by spoko22
Okay, I fixed the wrong site address. What I needed to do was to change

Code: Select all

Alias /nagios "/etc/nagios3/share"
to

Code: Select all

Alias /nagios3 "/etc/nagios3/share"
However, I still cannot run nagios as daemon and I hope this post will bump my thread a little (please mods, don't be mad for double post, there are already two responses to this thread and I feel that's why nobody enters and reads it ;) ).

Re: Nagios 3.2.0 won't start as daemon - config problems.

Posted: Thu Sep 04, 2014 7:35 am
by eloyd
Regarding your daemon not starting, please post the output of:

Code: Select all

/etc/nagios3/bin/nagios -v -v /etc/nagios3/etc/nagios.cfg

Re: Nagios 3.2.0 won't start as daemon - config problems.

Posted: Thu Sep 04, 2014 2:04 pm
by tmcdonald
Thanks, eloyd, for taking point on this.

Re: Nagios 3.2.0 won't start as daemon - config problems.

Posted: Fri Sep 05, 2014 3:15 am
by spoko22
OK guys, thanks for your assistance, but it looks like I worked my problems out. I will update my original question, so if anyone else is gonna look for the answer, this thread may be useful.

I found the reason why didn't my nagios start - directory /var/run/nagios3 was missing, so Nagios couldn't create nagios3.pid there. After mkdir and granting permission, daemon starts. I realized that by reading /var/log/nagios3/nagios.log.

However, I still wasn't able to stop my Nagios other way than

Code: Select all

ps aux | grep nagios
kill <pid>
That was fixed, by making the line from nagios.cfg

Code: Select all

lock_file=/var/run/nagios3/nagios3.pid
and the line from script /etc/init.d/nagios

Code: Select all

NagiosRunFile=/var/run/nagios3/nagios3.pid
point at the same file.

Re: Nagios 3.2.0 won't start as daemon - config problems.

Posted: Fri Sep 05, 2014 8:15 am
by eloyd
Glad to help @tm. Glad you figured out your issue, @spoko22.