Apache_status - installation and configuration (HOW)

Just recently installed CHECK_MK and have successfully added hosts (web servers)
But upon checking the apache_status on the services list does not show up.

Based on the documentation i followed, the plugin apache_status should be in the folder /usr/lib/check_mk_agent/plugins and made executable.

But still the apache_status is not shown in the server’s SERVICES list.

Would really appreciate any help.

Many thanks.

You can run the plugin manually to see if if its autodiscovery worked and if there are any problems.

Without a config file, the plugin will check netstat to find the running apache processes and ports.

You can override the autodiscovery by using a config file (/etc/check_mk/apache_status.cfg), e.g.

servers = [
      # system apache on port 80, IPv6:
      ('http', '[::1]', 80),
      # It's the same daemon on :443 as on :80, so do not query it twice:
      #('https', '[::1]', 443),
      # site apache from a local checkmk site on port 5000, IPv4:
      ('http', '127.0.0.1', 5000),
]

Here’s the output using the above config:

$ sudo /usr/lib/check_mk_agent/plugins/apache_status
<<<apache_status:sep(124)>>>
[::1]|80||::1
[::1]|80||ServerVersion: Apache/2.4.38 (Debian) OpenSSL/1.1.1d
[::1]|80||ServerMPM: prefork
[...]
127.0.0.1|5000||127.0.0.1
127.0.0.1|5000||ServerVersion: Apache/2.4.38 (Debian) mod_wsgi/4.6.4 Python/2.7 mod_fcgid/2.3.9
127.0.0.1|5000||ServerMPM: prefork
[...]

You need to have mod_status enabled (loaded) in Apache.

Also make sure that you do permit the query to /server-status from localhost and do not rewrite/redirect it to somewhere else.

2 Likes

Hi Martin!

many thanks for replying.

The output of the sudo command is:

[root@stage ~]# sudo /usr/lib/check_mk_agent/plugins/apache_status
<<<apache_status:sep(124)>>>
Exception ([::1]:80): hostname ‘::1’ doesn’t match either of ‘*.mydomain.com’, ‘mydomain.com
Exception (127.0.0.1:5000): <urlopen error [Errno 111] Connection refused>
[root@stage ~]#

is my installation broken?

The apache_status.cfg shown above was only a example from one of my machines, a system running a checkmk site incidentally, hence the localhost:5000.

You probably do not have any apache listening on port 5000, so leave that out. In fact, try the plugin without any config at all and see what autodiscover finds.

The message about the hostname mismatch looks like there is a problem with SSL/TLS. Do you perhaps have a redirect from http to https in place? Then try to exclude /server-status from that redirect, e.g. with something like RewriteCond %{REQUEST_URI} !=/server-status before the relevant RewriteRule.
Or try a config file that sets up the correct hostname (plus protocol and port) so TLS should work.

1 Like

Hi Martin,

I tried the “apache_status” plugin without any config. Placed it on a host /usr/lib/check_mk_agent/plugins/ directory. Is there anything i should do or command to execute after this?

When I checked the server in the Hosts, WATO then clicked on the server’s “SERVICES” there is still NO apache_status under the Check plugin Row.

Can you point me excatly what to do?

Humbly,

chris

Try to run it manually and show its output.

Also, can you manually query “/server-status” on your apache server?

Hi again Martin,

When I issue sudo /usr/lib/check_mk_agent/plugins/apache_status it does not return or show anything.

Then when I try query “/server-status” on the apache server it shows:

“Not Found
The requested URL /server-status was not found on this server”

But when I enabled the server-status (as described in https://www.tecmint.com/check-apache-httpd-status-and-uptime-in-linux/) component by:

vi /etc/httpd/conf.d/server-status.conf

<Location “/server-status”>
SetHandler server-status
#Require host localhost #uncomment to only allow requests from localhost

The browser showed:

Apache Server Status for 12.34.56.78 (via 10.0.0.5)

Server Version: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips PHP/5.6.40 SVN/1.7.14
Server MPM: worker
Server Built: Jun 22 2018 01:19:25
Current Time: Tuesday, 17-Nov-2020 15:59:06 EST
Restart Time: Tuesday, 17-Nov-2020 15:58:54 EST
Parent Server Config. Generation: 1
Parent Server MPM Generation: 0
Server uptime: 11 seconds
Server load: 0.00 0.01 0.05
Total accesses: 0 - Total Traffic: 0 kB
CPU Usage: u0 s0 cu0 cs0
0 requests/sec - 0 B/second -
1 requests currently being processed, 31 idle workers
W_______________________________…

(truncated)

Still there is no “apache_status” in the list of plugins even after full scan of inventory.

The contents of my /etc/check_mk/apache_status.cfg shown below:

servers = [
# system apache on port 80, IPv6:
#(‘http’, ‘[::1]’, 80),
# It’s the same daemon on :443 as on :80, so do not query it twice:
#(‘https’, ‘[::1]’, 443),
# site apache from a local checkmk site on port 5000, IPv4:
# (‘http’, ‘127.0.0.1’, 5000),
# (‘http’, ‘stage.mydomain.com’, 80),
]

By commenting out all server entries, you have defined an empty list of servers!
Try without the config file (i.e. delete it).
Or use the config file to define a server exactly the way you can call server_status manually: protocol + hostname/address + port

No luck yet with the apache_status plugin… pls see screenshot of myserver’s
services

Hi again Martin,

All together I deleted the file /etc/check_mk/apache_status.cfg
and got this! WOW one major improvement!

But why is it PENDING?

Also when i issue again sudo /usr/lib/check_mk_agent/plugins/apache_status the result is:

[root@stage ~]# sudo /usr/lib/check_mk_agent/plugins/apache_status
<<<apache_status:sep(124)>>>
Exception ([::1]:80): hostname ‘::1’ doesn’t match either of ‘*.mydomain.com’, ‘mydomain.com
[::1]|443||Total Accesses: 23
[::1]|443||Total kBytes: 173
[::1]|443||CPULoad: .0669546
[::1]|443||Uptime: 463
[::1]|443||ReqPerSec: .049676
[::1]|443||BytesPerSec: 382.618
[::1]|443||BytesPerReq: 7702.26
[::1]|443||BusyWorkers: 2
[::1]|443||IdleWorkers: 126
[::1]|443||Scoreboard: R__________________________ W__________… …

Is it still pending? The service should get OK on the next check run.

When I go to WATO and Select HOSTS / myserver.com / SERVICES, this is what I see…
The STATE of Apache is grayed out and on PENDING state.

But when I go to WATO / HOSTS / Mydomain.com it shows that its OK

Is it normal?

Looks good! :slight_smile:

Yes, AFAIK this is normal. I guess the check does some averaging over multiple runs. So with a single run (as in the WATO service discovery), it cannot calculate an average. That’s why it “cannot be done offline”.

WOW! It means all your suggestions worked! Many many thanks Martin…
Checkmk now gets more interesting… :slight_smile:

Many thanks again for the assist! :pray: :pray:

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.