check_apachestatus_auto.pl v1.2 released

Tuesday, July 14th, 2009 | Nagios

A Nagios plugin that parses the status page of an apache or lighttpd server, the plugin returns the response time, the amount of idle, busy, open (apache only) and total slots. The perfdata returns the status of all slots including Requests/sec, Bytes/Request and Bytes/sec. Optionally you can specify how much slots should be available. Use http(s) and basic user authentication with non standard server-status urls. This is an enhanced version of an enhanced version of Lieven De Bodt’s check_apachestatus.pl.

Detailed info at http://blog.spreendigital.de/nagios/?#check_apachestatus_auto

Whats new
v1.1 Works with lighttpd server-status as well, added accesses perfdata (Lighttpd v1.4.19 tested)
v1.2 Updated perf data to be PNP compliant, added proxy option

Download
check_apachestatus_auto.tgz
v1.2
check_apachestatus_auto.php.tgz
(PNP template)

Tags: , , , ,

15 Comments to check_apachestatus_auto.pl v1.2 released

magu
May 14, 2010

Hi there, I’ve been trying to set this up to monitor Lighttpd but I’ve been experiencing this weird issue where if I run the command locally as one user, I get the correct output. Any subsequent runs by other users get no output. What’s worse, trying to get the results through NRPE yields a “NRPE: Unable to read output” from check_nrpe.

Do you run this check locally or remotely?

Christian
July 27, 2010

Hi There,
I’ve tried to use the check_apachestatus_auto.pl Plugin, but it always fails.
The Check is:
./check_apachestatus_auto.pl –hostname “hostname” –url http://“hostname”/server-status?auto
If I tried it with user root and user nagios out of the bash, all works fine.

If i tried to check it via nrpe or online via nagios, I always becomes a failure:

(Service check did not exit properly)

My output in the bash is:
qsargos01:/opt/nagios/libexec # ./check_apachestatus_auto.pl –hostname qsargos01.total.hosting –url http://argos-test.total.hosting/server-status?auto
APACHE OK – 0.028 sec. response time, Busy/Idle 1/74, open 949/1024, ReqPerSec 0.1, BytesPerReq 1289, BytesPerSec 111|Idle=74 Busy=1 OpenSlots=949 Slots=1024 Starting=0 Reading=0 Sending=1 Keepalive=0 DNS=0 Closing=0 Logging=0 Finishing=0 ReqPerSec=0.086761 BytesPerReq=1289 BytesPerSec=111.918873 Accesses=154qsargos01:/opt/nagios/libexec #

It looks like there is a Problem with the output data. Why there is always this line “qsargos01:/opt/nagios/libexec #” directly behind the output?

Thanks in advance

Cjeanneret
August 5, 2010

Hello,

Thank you for this update. May I suggest a new change ?

*** mine.pl 2010-08-05 15:34:54.374819435 +0200
— check_apachestatus_auto.pl 2009-07-14 13:04:30.000000000 +0200
*************** use Digest::MD5 qw(md5 md5_hex);
*** 30,36 ****
# Nagios specific

use lib “/usr/local/nagios/libexec”;
- use lib “/usr/lib/nagios/plugins”;
use utils qw(%ERRORS $TIMEOUT);
#my %ERRORS=(‘OK’=>0,’WARNING’=>1,’CRITICAL’=>2,’UNKNOWN’=>3,’DEPENDENT’=>4);

— 30,35 —-

This patch allow your script to work on a debian installation, using debian packages.

Cjeanneret
August 6, 2010

Hello again,

For the lib, it’s not a problem – perl -I is a good friend.

But I checked how you get Server type… and, well, I think it can be done in a smarter way:

diff -u check_apachestatus_auto.pl check_webserver.pl
— check_apachestatus_auto.pl 2009-07-14 13:04:30.000000000 +0200
+++ check_webserver.pl 2010-08-06 08:58:17.000000000 +0200
@@ -190,6 +190,9 @@
my $webcontent = undef;
if ($response->is_success) {
$webcontent=$response->content;
+ my @t = split(‘/’, $response->header(‘server’)) ;
+ $httpserver = $t[0];
+

my $Uptime = 0;
if($webcontent =~ m/Uptime: (.*?)\n/) {
@@ -212,11 +215,8 @@
}

my $BusyWorkers= 0;
- if($webcontent =~ m/(BusyWorkers|BusyServers): (.*?)\n/) {
- $BusyWorkers = $2;
- if ($1 eq ‘BusyServers’) {
- $httpserver = ‘LIGHTTPD’;
- }
+ if($webcontent =~ m/(:?BusyWorkers|BusyServers): (.*?)\n/) {
+ $BusyWorkers = $1;
}

my $IdleWorkers=0;

eschoeller
October 5, 2010

I’m curious if you have any interest in expanding the functionalities of this plugin. We’re looking to monitor the activity of threads on a more detailed level. We have some situations where after an incident we’re stuck with tons of threads in the ‘Sending Reply’ or ‘Graceful Finishing’ state. I’m curious if you would consider adding in functionality to watch thread types and allow for warning and critical thresholds to be applied to them.

Thanks!!

Dennis
October 21, 2010

sorry, overlooked your comment – those thread infos are hard to retrieve (you need to write an extra apache module).. I am not aware of any existing modules to use – do you know any?

Scott
December 4, 2010

I am getting a error with the PNP file.

templates/check_apachestatus.php [30]:

Undefined index: Slots

And I really have no clue how to fix this.

Scott
December 4, 2010

never mind — helps if I name the file right.

Dennis
December 7, 2010

You’re welcome.

Eric Schoeller
April 29, 2011

Sorry just saw that you replied. There are no extras needed to provide the thread scoreboard. It’s part of server status. All this plugin would need to do is parse the scoreboard and generate notifications based on the number of threads in a certain state.

gebi
December 14, 2011

Thx for your really helpfull apache check.

we have added 2 additional features:
– once added the path to make your check work on debian
– changed the warn/critical from absolut values to percent (as many apache are configured in a way to have a different slot count after the first apache master process generation)

Both formatted as nice and seperated patches:
https://github.com/gebi/nagios_checks/commit/c7519cc7e00ba54a489d043984ef3ae102527287

https://github.com/gebi/nagios_checks/commit/a2fd9f4f05bca68881a8e67ba1c939c025865098

what do you think about them?

Charles Tassell
April 14, 2012

A note to people who get the “NRPE: Unable to read output” error. The script leaves a tempfile in /tmp that is owned by the user who runs it. So if you run it as a user other than that which runs your NRPE it will die because it can’t create a new dropfile.

To fix this, delete the file (it’s called /tmp/_check_apachestatus_auto. and then add the line “unlink($TempFile); to line 289 of the script, right before the “http://www.tcomm.es/joomla/index.php/en/downloads-menu/finish/19-unix/11-checkunixmemusage/0.html” line.

Andrea
September 6, 2012

Thx Charles, fixed my problem.
Propesed change to the script

# my $TempFile = $TempPath.$o_host.’_check_apachestatus_auto’.md5_hex($url);
#The $ is the effective user id.
my $name=getpwuid($<);
my $TempFile = $TempPath.$o_host.'_check_apachestatus_auto'.'_'.$name.'_'.md5_hex($url);

Christian S
November 7, 2013

Hi,
When im trying to do a combined graph i get a error from your template that something is wrong.
This is the output.

Undefined variable: DS

file [line]:

templates.special/check_apachestatus_auto.php [21]:

im trying to do it in op5 that uses pnp4nagios

Leave a comment

About Dennis D. Spreen

I'm an avid programmer working on a variety of platforms in a variety of languages with a wide technical interest.

QR Code

Search

Categories