Page 1 of 2

nagios 4 core website does not work

Posted: Fri Dec 06, 2013 6:33 am
by averlon
Hi,
I have installed nagios 4.0.2 from source on my ubuntu maschine.

Installation directory is "/usr/local/nagios/...".

I would like to have all webpages under "/var/www/..."

I know, this makes things a little bit more complicated but it should work. It worked for nagios 3, but installed via ubuntu package.

I have copied the files from /usr/local/nagios/share" to /var/www/av_nagios" - my website directory.

I have modified the config file:

Code: Select all

<?php
//


$cfg['cgi_config_file']='/etc/nagios/cgi.cfg';  // location of the CGI config file

$cfg['cgi_base_url']='/cgi-bin';


// FILE LOCATION DEFAULTS
$cfg['main_config_file']='/etc/nagios/nagios.cfg';  // default location of the main Nagios config file
$cfg['status_file']='/var/cache/nagios/status.dat'; // default location of Nagios status file
$cfg['state_retention_file']='/var/cache/nagios/retention.dat'; // default location of Nagios retention file



// utilities
require_once(dirname(__FILE__).'/includes/utils.inc.php');

?>
Since I work with virtual hosts, I have created the following apache configuration:

Code: Select all

<VirtualHost *:80>
        DocumentRoot "/var/www/av_nagios"
        ServerName nagios.av.loc
        ServerAlias event.av.loc
        RewriteLog "/var/log/apache2/rewrite.log"
        RewriteLogLevel 4
        LogLevel debug
        <Directory "/var/www/av_nagios">
                RewriteEngine On
                AllowOverride All
                Options +Indexes FollowSymLinks +ExecCGI
                DirectoryIndex index.php index.html index.cgi
                Order Allow,Deny
                allow from all
                RewriteRule (.*)av_nagios/(.*) $1$2
        </Directory>
        ScriptAlias /cgi-bin /usr/local/nagios/sbin
</VirtualHost>
I now can access the website via "nagios.av.loc", my local domain.

The screen has a white background. This indicates to me the stylesheets are not used - but I am not sure.

When pushing e.g. "hosts" I get the message:

Code: Select all

Whoops!

Error: Could not open CGI config file '/usr/local/nagios/etc/cgi.cfg' for reading!
......
I do not know why that is the case.

The logfile reports:

Code: Select all

[Fri Dec 06 12:31:22 2013] [debug] mod_deflate.c(615): [client 192.168.110.165] Zlib: Compressed 1588 to 835 : URL /cgi-bin/status.c
gi
[Fri Dec 06 12:31:22 2013] [error] [client 192.168.110.165] (8)Exec format error: exec of '/usr/local/nagios/sbin/jquery-1.7.1.min.j
s' failed, referer: http://nagios.av.loc/cgi-bin/status.cgi?hostgroup=all&style=hostdetail
[Fri Dec 06 12:31:22 2013] [error] [client 192.168.110.165] Premature end of script headers: jquery-1.7.1.min.js, referer: http://na
gios.av.loc/cgi-bin/status.cgi?hostgroup=all&style=hostdetail
[Fri Dec 06 12:31:22 2013] [debug] mod_deflate.c(615): [client 192.168.110.165] Zlib: Compressed 617 to 379 : URL /cgi-bin/jquery-1.
7.1.min.js, referer: http://nagios.av.loc/cgi-bin/status.cgi?hostgroup=all&style=hostdetail
This seems to be some access issues for the webserver. But I do not see the forest.

Probably some better experts on webservers see the hint.
Thanks

Re: nagios 4 core website does not work

Posted: Fri Dec 06, 2013 11:21 am
by sreinhardt
Does the apache user, or a group that apache is in have permissions to /usr/local/nagios and sub-directories?

ls -lv /usr/local/nagios
ls -lv /usr/local/nagios/etc

Re: nagios 4 core website does not work

Posted: Fri Dec 06, 2013 11:40 am
by averlon
Hi,
yes.

Code: Select all

ls -lv /usr/local/nagios
insgesamt 32
drwxrwxr-x  2 nagios nagios   4096 Dez  6 10:44 bin
drwxr-xr-x  2 root   root     4096 Dez  6 10:40 bin_org
drwxrwxr-x  3 nagios nagios   4096 Dez  1 18:34 etc_org
drwxr-xr-x  2 nagios nagios   4096 Dez  1 10:41 include
drwxrwxr-x  3 nagios nagios   4096 Dez  1 10:41 libexec
drwxrwxr-x  2 nagios www-data 4096 Dez  2 09:49 sbin
drwxrwxr-x 11 nagios nagios   4096 Dez  5 18:16 share_org
drwxrwxr-x  5 nagios nagios   4096 Dez  1 18:35 var_org
the only directory from the original install I use is "bin" and "sbin" where "bin" is only used by nagios itself and "sbin" contains the .cgi files needed for the website.

The config files for nagios are at /etc/nagios/

Code: Select all

ls -lv /etc/nagios
insgesamt 188
-rw-r--r-- 1 nagios www-data 12606 Dez  1 18:58 cgi.cfg
-rw-r--r-- 1 nagios www-data  2487 Dez  1 11:30 commands.cfg
-rwxr-xr-x 1 nagios www-data  7423 Dez  6 17:29 functions.sh
-rw-r--r-- 1 nagios www-data    50 Dez  1 18:07 htpasswd.users
-rw-r--r-- 1 nagios www-data 44558 Dez  6 16:34 nagios.cfg
-rw-r--r-- 1 nagios www-data  4480 Dez  1 16:02 ndo2db.cfg
-rw-r--r-- 1 nagios www-data  5122 Dez  1 12:42 ndomod.cfg
-rw-r--r-- 1 nagios www-data   759 Dez  1 11:30 notifications.cfg
-rw-r--r-- 1 nagios www-data  7921 Feb  2  2013 nrpe.cfg
drwxr-xr-x 2 nagios www-data  4096 Mai  3  2012 nrpe.d
-rw-r--r-- 1 nagios www-data   348 Feb 10  2013 nrpe_local.cfg
-rw-r--r-- 1 nagios www-data  1328 Dez  1 19:00 resource.cfg

Re: nagios 4 core website does not work

Posted: Fri Dec 06, 2013 1:53 pm
by abrist
averlon wrote:Error: Could not open CGI config file '/usr/local/nagios/etc/cgi.cfg' for reading!
It looks like your php script cgi setting is not getting picked up.
What config is nagios loading with?

Code: Select all

ps -aef | grep nagios.cfg

Re: nagios 4 core website does not work

Posted: Sat Dec 07, 2013 5:58 am
by averlon
ps -aef | grep nagios.cfg
nagios 13121 1 0 09:39 ? 00:00:03 /usr/local/nagios/bin/nagios -d /etc/nagios/nagios.cfg
nagios 13126 13121 0 09:39 ? 00:00:00 /usr/local/nagios/bin/nagios -d /etc/nagios/nagios.cfg

But I think, nagios and nagios website are two different things.

Nagios seems to run fine.

Nagios Core website does not find the .cfg file, although the config in the website is set correct.

There must be some access issues with the jquery.....js file.

Re: nagios 4 core website does not work

Posted: Sat Dec 07, 2013 6:54 am
by averlon
Hi all,
when I rename the jquery javascript file I get the error in the logfile:

Code: Select all

[Sat Dec 07 12:50:42 2013] [error] [client 192.168.110.165] script not found or unable to stat: /usr/local/nagios/sbin/jquery-1.7.1.
min.js, referer: http://nagios.av.loc/av_nagios/cgi-bin/status.cgi?hostgroup=all&style=hostdetail
means: test successfull. Nagios Core Website looksup the file at the correct path.

The standard message is:

Code: Select all

[Sat Dec 07 12:50:15 2013] [error] [client 192.168.110.165] (8)Exec format error: exec of '/usr/local/nagios/sbin/jquery-1.7.1.min.j
s' failed, referer: http://nagios.av.loc/av_nagios/cgi-bin/status.cgi?host=all
[Sat Dec 07 12:50:15 2013] [error] [client 192.168.110.165] Premature end of script headers: jquery-1.7.1.min.js, referer: http://na
gios.av.loc/av_nagios/cgi-bin/status.cgi?host=all
which means to me it finds the file but cannot process it.

The reason behind is not clear to me. Is there any possibility to lift the level of verbosity?

Re: nagios 4 core website does not work

Posted: Sat Dec 07, 2013 11:29 am
by averlon
can anyone confirm, the file

Code: Select all

js/jquery-1.7.1.min.js
did not exist in nagios 3 ?

I havn't found it there and I am more or less sure, to include this correct in the apache environment is the key for success.

Re: nagios 4 core website does not work

Posted: Sat Dec 07, 2013 12:15 pm
by averlon
by downloading older nagios sources I was able to find out

nagios 3.0.x the jquery file did not exist

nagios 3.5.x it already existed.

The sample configurations for httpd are the same.

To be honest - I am lost!

Re: nagios 4 core website does not work

Posted: Sun Dec 08, 2013 4:03 am
by averlon
Hi,
anyone running a Nagios Core Website either on 3.5.x or better on 4.0.x and could post
  • the directory the file "jquery-1.7.1.min.js" is in and
  • probably his apache conf

Re: nagios 4 core website does not work

Posted: Sun Dec 08, 2013 12:14 pm
by averlon
Hi all,
issue solved.

I compiled nagios new with additional parameters to adjust the various destination directories I wanted to have different then standard.

This helped.

To be honest - I don't know why. My understanding was, erverything is set by .cfg-files. But it looks like it is not completely that way.

Anyhow. It now works.

Comment: the parameter "--with-mail=" does not work in .configure. This might be the reason no mail alerts show up.