Nagios is active on CLI but not running on Web Interface - nagios

Good morning,
I have a problem with my Nagios configuration. This is the response of service nagios status :
root#SRV-SUPERVISION-BT:~# service nagios status
● nagios.service - LSB: Starts and stops the Nagios monitoring server
Loaded: loaded (/etc/init.d/nagios)
Active: active (running) since ven. 2016-06-17 09:47:46 CEST; 41min ago
Process: 458 ExecStart=/etc/init.d/nagios start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nagios.service
├─533 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios...
├─553 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/...
├─555 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/...
├─556 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/...
├─558 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/...
├─559 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/...
├─560 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/...
└─623 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios...
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: nerd: Channel opathchecks r...y
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: nerd: Fully initialized and...!
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: wproc: Successfully registe...r
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: wproc: Registry request: na...3
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: wproc: Registry request: na...8
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: wproc: Registry request: na...9
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: wproc: Registry request: na...6
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: wproc: Registry request: na...0
juin 17 09:47:46 SRV-SUPERVISION-BT nagios[533]: wproc: Registry request: na...5
juin 17 09:47:48 SRV-SUPERVISION-BT nagios[533]: Successfully launched comma...3
Hint: Some lines were ellipsized, use -l to show in full.
But when I'm going on the web interface, Nagios Core is not running.
The configtest command is also right :
root#SRV-SUPERVISION-BT:~# service nagios configtest
Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL
Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
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
Object precache file created:
/usr/local/nagios/var/objects.precache
Also, this is the right of my /usr/local/nagios/var:
root#SRV-SUPERVISION-BT:/usr/local/nagios/bin# ls /usr/local/nagios/var -l
total 88
drwxrwsr-x 2 nagios nagios 4096 juin 16 23:59 archives
-rw-r--r-- 1 nagios nagios 34 juin 17 11:00 nagios.configtest
-rw-r--r-- 1 nagios nagios 4 juin 17 09:47 nagios.lock
-rw-r--r-- 1 nagios nagios 3007 juin 17 10:47 nagios.log
-rw-r--r-- 1 nagios nagios 12665 juin 17 09:47 objects.cache
-rw-r--r-- 1 nagios nagios 12665 juin 17 11:00 objects.precache
-rw------- 1 nagios nagios 13062 juin 17 10:47 retention.dat
drwxrwsr-x 2 nagios nagcmd 4096 juin 17 09:47 rw
drwxr-sr-x 3 root nagios 4096 juin 3 08:28 spool
-rw-rw-r-- 1 nagios nagios 13485 juin 17 11:26 status.dat
I'm on Debian :
root#SRV-SUPERVISION-BT:~# uname -a
Linux SRV-SUPERVISION-BT 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux
I do not understand the problem. If anyone can help me, thanks in advance.

First you must install fcgiwrap:
Depending on your distribution you should use your package manager.
Then, you should enable cgi module in your Web Server, for examle, in apache:
Finally, restart apache and it´s should be work.

You must install/run fcgiwrap and use it in your web-server apache/nginx/..

Related

apache2 restart problem on ubuntu 20.04 LTS

I had installed nginx but now i uninstalled the nginx facing this problem
when i run command "system start apache2"
it through the massage run "journalctl -xeu apache2.service" to check error massage when i run the above command it give following massage
Oct 29 17:37:32 localhost apachectl[37192]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Oct 29 17:37:32 localhost apachectl[37192]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
Oct 29 17:37:32 localhost apachectl[37192]: no listening sockets available, shutting down
Oct 29 17:37:32 localhost apachectl[37192]: AH00015: Unable to open logs
Oct 29 17:37:32 localhost apachectl[37189]: Action 'start' failed.
Oct 29 17:37:32 localhost apachectl[37189]: The Apache error log may have more information.
Oct 29 17:37:32 localhost systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
I am not able to start my apache2 server

Apache2 server not wotking

For some reason my apache2 has stopped working.
I have tried uninstalling it, the problem still remains the same.
Here's some commands and their results that I have tried which might help you:-
"sudo systemctl status apache2":-
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset:
Active: failed (Result: exit-code) since Sun 2020-06-21 12:56:28 IST; 7min ag
Docs: https://httpd.apache.org/docs/2.4/
Jun 21 12:56:21 kabir systemd[1]: Starting The Apache HTTP Server...
Jun 21 12:56:28 kabir apachectl[1086]: AH00558: apache2: Could not reliably dete
Jun 21 12:56:28 kabir apachectl[1086]: (98)Address already in use: AH00072: make
Jun 21 12:56:28 kabir apachectl[1086]: no listening sockets available, shutting
Jun 21 12:56:28 kabir apachectl[1086]: AH00015: Unable to open logs
Jun 21 12:56:28 kabir apachectl[1086]: Action 'start' failed.
Jun 21 12:56:28 kabir apachectl[1086]: The Apache error log may have more inform
Jun 21 12:56:28 kabir systemd[1]: apache2.service: Control process exited, code=
Jun 21 12:56:28 kabir systemd[1]: apache2.service: Failed with result 'exit-code
Jun 21 12:56:28 kabir systemd[1]: Failed to start The Apache HTTP Server.
"sudo systemctl restart apache2":-
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
netstat -an | grep ":80"
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 192.168.43.128:33944 117.18.237.29:80 TIME_WAIT
tcp 0 0 192.168.43.128:33864 117.18.237.29:80 ESTABLISHED
tcp 0 0 192.168.43.128:34524 23.217.53.84:80 ESTABLISHED
tcp 0 0 192.168.43.128:54364 172.217.166.163:80 ESTABLISHED
tcp 0 0 192.168.43.128:54206 172.217.166.163:80 TIME_WAIT
tcp 0 0 192.168.43.128:33946 117.18.237.29:80 ESTABLISHED
tcp 0 0 192.168.43.128:34522 23.217.53.84:80 ESTABLISHED
tcp6 0 0 :::80 :::* LISTEN
"sudo apachectl start":-
Invoking 'systemctl start apache2'.
Use 'systemctl status apache2' for more info.
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
Action 'start' failed.
The Apache error log may have more information.
Check your configuration as the error would indicate that you already have a listen directive to the same port.
sudo vim /etc/apache2/ports.conf [On Debian/Ubuntu]
sudo vim /etc/httpd/conf/httpd.conf [On RHEL/CentOS]
Check that you don't have a listen on the port you need.

Apache 2 configtest failed: File name too long

I run an apache2 webserver locally on a raspberry-pi with raspbian distro.
It worked without a problem until suddenly it can't be started anymore with
sudo /etc/init.d/apache2 start, which yields the following error:
[....] Starting apache2 (via systemctl): apache2.serviceJob for
apache2.service failed. See 'systemctl status apache2.service' and
'journalctl -xn' for details. failed!
Removing and reinstalling with apt-get doesn't solve it.systemctl status shows the following entries:
> Apr 22 11:27:16 raspberrypi apache2[18234]: [344B blob data] Apr 22
> 11:27:16 raspberrypi apache2[18234]: [293B blob data] Apr 22 11:27:16
> raspberrypi apache2[18234]: [293B blob data] Apr 22 11:27:16
> raspberrypi apache2[18234]: [293B blob data] Apr 22 11:27:16
> raspberrypi apache2[18234]: [293B blob data] Apr 22 11:27:16
> raspberrypi apache2[18234]: Action 'configtest' failed. Apr 22
> 11:27:16 raspberrypi apache2[18234]: The Apache error log may have
> more information. Apr 22 11:27:16 raspberrypi systemd[1]:
> apache2.service: control process exited, code=exited status=1 Apr 22
> 11:27:16 raspberrypi systemd[1]: Failed to start LSB: Apache2 web
> server. Apr 22 11:27:16 raspberrypi systemd[1]: Unit apache2.service
> entered failed state.
journalctl -xn yields:
> -- Logs begin at Sun 2017-04-23 07:06:12 UTC, end at Sun 2017-04-23 12:38:48 UTC. -- Apr 23 12:38:30 raspberrypi apache2[3292]: [2.0K blob
> data] Apr 23 12:38:30 raspberrypi apache2[3292]: [1.7K blob data] Apr
> 23 12:38:30 raspberrypi apache2[3292]: Action 'configtest' failed. Apr
> 23 12:38:30 raspberrypi apache2[3292]: The Apache error log may have
> more information. Apr 23 12:38:31 raspberrypi systemd[1]:
> apache2.service: control process exited, code=exited status=1 Apr 23
> 12:38:31 raspberrypi systemd[1]: Failed to start LSB: Apache2 web
> server.
> -- Subject: Unit apache2.service has failed
> -- Defined-By: systemd
> -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
> --
> -- Unit apache2.service has failed.
> --
> -- The result is failed. Apr 23 12:38:31 raspberrypi systemd[1]: Unit apache2.service entered failed state. Apr 23 12:38:31 raspberrypi
> sudo[3278]: pam_unix(sudo:session): session closed for user root Apr
> 23 12:38:48 raspberrypi sudo[3345]: pi : TTY=pts/0 ;
> PWD=/etc/apache2/conf-enabled ; USER=root ; COMMAND=/bin/journalctl
> -xn Apr 23 12:38:48 raspberrypi sudo[3345]: pam_unix(sudo:session): session opened for user root by pi(uid=0)
Unfortunately the apache error.log contains no useful information whatsoever. But if i run apache2 configtest I get a "File name too long" error.
Strangely even after formatting my sdcard and putting a fresh copy of the distribution image on it and reinstalling apache2 the error remains.
What can I do?

Apache2 is not starting after apt upgrade

I updated Apache2 on my Rapsberry Pi (using: apt install apache2 --only-upgrade) and now it is not starting:
root#pi:/etc/apache2 # service apache2 start
Job for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.
root#pi:/etc/apache2 # systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled)
Active: failed (Result: resources) since Sun 2017-02-05 16:19:48 CET; 28min ago
Feb 05 16:47:44 pi systemd[1]: Starting The Apache HTTP Server...
Feb 05 16:47:44 pi systemd[1]: apache2.service failed to run 'start' task: No such file or directory
Feb 05 16:47:44 pi systemd[1]: Failed to start The Apache HTTP Server.
Version of apache2:
Server version: Apache/2.4.25 (Raspbian)
Server built: 2017-01-25T22:59:26
apache2ctl -t shows:
Syntax OK
I tried disabling all virtual hosts (only default left) but it didn't change anything.
Output of just apache2:
[Mon Feb 06 01:25:09.079790 2017] [core:warn] [pid 2954] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot
I had the same issue after upgrading a Dockerfile from 14.04 to 17.04.
The solution for me was to manually add the apache directory in /var/run
So the fix was:
mkdir /var/run/apache2
The DefaultRuntimeDir was set to /var/run/apache2 but the folder was missing.

Error accessing cgi script inside Docker container, Operation not permitted: Couldn't bind unix domain socket

I'm using Apache::Test to test an Apache handler that I'm writing. My build environment is a Docker container, created from this Dockerfile:
FROM google/debian:wheezy
RUN apt-get -y install make gcc build-essential
RUN apt-get -y install sudo
RUN apt-get -y install apache2-threaded-dev
RUN apt-get -y install libapache2-mod-perl2 libgd-gd2-perl libgd-tools
RUN apt-get -y install libtest-harness-perl
RUN apt-get -y install libtap-formatter-junit-perl libjson-perl
I build the container and run it via:
docker run -i -t --rm -v $PWD:/opt/51d device-detection:latest /opt/51d/entry.sh
Apache::Test doesn't allow the httpd server to start as root and my container is running as root, so the entry.sh script creates a user for the test to use by doing:
#!/bin/bash
adduser --disabled-password --gecos '' r
adduser r sudo
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
su -m r -c /opt/51d/build
And build looks like:
perl Makefile.PL && make && make test && sudo make install
Apache::Test provides a test harness called t/TEST. I can start the Apache server just fine with:
t/TEST -start-httpd
And I can access the index.html page just fine with:
wget http://localhost:8529/index.html
However, when I attempt to access a CGI script, I get:
[Thu Apr 02 23:12:11 2015] [error] (1)Operation not permitted: Couldn't bind unix domain socket /opt/51d/CDK-51DegreesFilter/t/logs/cgisock.267
[Thu Apr 02 23:12:11 2015] [notice] Apache/2.2.22 (Debian) mod_perl/2.0.7 Perl/v5.14.2 configured -- resuming normal operations
[Thu Apr 02 23:12:11 2015] [info] Server built: Dec 23 2014 22:48:32
[Thu Apr 02 23:12:11 2015] [debug] worker.c(1757): AcceptMutex: sysvsem (default: sysvsem)
[Thu Apr 02 23:12:11 2015] [crit] cgid daemon failed to initialize
[Thu Apr 02 23:12:30 2015] [error] [client 127.0.0.1] (2)No such file or directory: unable to connect to cgi daemon after multiple tries: /opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi
The /opt/51d/CDK-51DegreesFilter/t/logs/ directory is wide open:
ls -ld t/logs/
drwxrwxrwx 1 r staff 136 Apr 2 23:24 t/logs/
=====
Made some progress by moving the location of the ScriptSock directory
<IfModule mod_cgid.c>
ScriptSock /tmp/cgisock
</IfModule>
New error message is:
[Sat Apr 04 04:04:23 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Sat Apr 04 04:04:23 2015] [notice] Apache/2.2.22 (Debian) mod_perl/2.0.7 Perl/v5.14.2 configured -- resuming normal operations
[Sat Apr 04 04:04:23 2015] [info] Server built: Dec 23 2014 22:48:32
[Sat Apr 04 04:04:23 2015] [debug] worker.c(1757): AcceptMutex: sysvsem (default: sysvsem)
[Sat Apr 04 04:04:49 2015] [error] (2)No such file or directory: exec of '/opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi' failed
[Sat Apr 04 04:04:49 2015] [error] [client 127.0.0.1] Premature end of script headers: index.cgi
[Sat Apr 04 04:06:14 2015] [error] (2)No such file or directory: exec of '/opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi' failed
[Sat Apr 04 04:06:14 2015] [error] [client 127.0.0.1] Premature end of script headers: index.cgi
=====
Fixed the exec error as the location of the perl binary is different. Updated that and all is well.
t/TEST
[warning] setting ulimit to allow core files ulimit -c unlimited; /usr/bin/perl /opt/51d/CDK-51DegreesFilter/t/TEST
/usr/sbin/apache2 -d /opt/51d/CDK-51DegreesFilter/t -f /opt/51d/CDK-51DegreesFilter/t/conf/httpd.conf -D APACHE2 -D PERL_USEITHREADS
using Apache/2.2.22 (worker MPM)
waiting 60 seconds for server to start: ..
waiting 60 seconds for server to start: ok (waited 1 secs)
server localhost:8529 started
t/CDK-51DegreesFilter.t .. ok
All tests successful.
Files=1, Tests=6, 0 wallclock secs ( 0.02 usr 0.02 sys + 0.34 cusr 0.08 csys = 0.46 CPU)
Result: PASS
[warning] server localhost:8529 shutdown
[warning] port 8529 still in use...
done
I had similar issue today.. Using valid scriptsock resolved my issue..
<IfModule cgid_module>
#
# ScriptSock: On threaded servers, designate the path to the UNIX
# socket used to communicate with the CGI daemon of mod_cgid.
#
Scriptsock /usr/local/apache2/cgisock
</IfModule>

Resources