Page 1 of 1

Nagios 3.2.0 apache critical status

Posted: Tue Feb 17, 2015 4:32 am
by mike-stokkel
hi,

At the moment im working with Nagios 3.2.0 and i have check_apache plugin running on several servers. But there is something weird going on, nagios is telling me that the apache is running but it is in critical state. I get this problem on the servers that are working on Ubuntu 12.04/14.04, the only server that has not got this problem are the servers that are running on Ubuntu 10.4. Personally, I think it's a bug in nagios, because on both the server running 12.04/14.04 & 10.4 are running the same plugin. Is this a common problem that an older Nagios version display Critical errors while it's running?

Does anyone knows what is going on?

Here is the code I use for the plugin:

Code: Select all

#!/bin/bash


#Check if apache2 is running
running="Apache is running"
apache=$(service apache2 status)


if [ "${apache::17}" == "$running" ];then
	echo "$apache"
	exit 0
else
	echo "$apache"
	exit 2
fi

Re: Nagios 3.2.0 apache critical status

Posted: Tue Feb 17, 2015 11:34 am
by abrist
My guess is that it is not matching the string. Case issues maybe?
Can you post the output of:

Code: Select all

service apache2 status

Re: Nagios 3.2.0 apache critical status

Posted: Wed Feb 18, 2015 5:49 am
by mike-stokkel
abrist wrote:My guess is that it is not matching the string. Case issues maybe?
Can you post the output of:

Code: Select all

service apache2 status
* apache2 is running

Re: Nagios 3.2.0 apache critical status

Posted: Wed Feb 18, 2015 11:32 am
by abrist
That would be the issue. The string your script is checking for is:

Code: Select all

Apache is running
Yet the command it runs outputs the following:

Code: Select all

apache2 is running
Change you script, specifically the $running variable:

Code: Select all

running="apache2 is running"
Save out and try running the check again.

Re: Nagios 3.2.0 apache critical status

Posted: Thu Feb 19, 2015 3:52 am
by mike-stokkel
abrist wrote:That would be the issue. The string your script is checking for is:

Code: Select all

Apache is running
Yet the command it runs outputs the following:

Code: Select all

apache2 is running
Change you script, specifically the $running variable:

Code: Select all

running="apache2 is running"
Save out and try running the check again.

Nope, it still doesn't work

Re: Nagios 3.2.0 apache critical status

Posted: Thu Feb 19, 2015 1:35 pm
by tgriep
How about changing the script to the following?

Code: Select all

#!/bin/bash

#Check if apache2 is running
apache=$(service apache2 status)

if [[ $apache == *"running"* ]];then                                                                                                                                                                                   
   echo "$apache"
   exit 0
else
   echo "$apache"
   exit 2
fi

Re: Nagios 3.2.0 apache critical status

Posted: Thu Feb 19, 2015 1:44 pm
by jdalrymple
Alternatively if you want to have a more future-proof solution that won't require your custom script to be moved with your installation you could use official plugins. Something like this should work for you:

Code: Select all

[jdalrymple@localhost libexec]$ ./negate -c OK -s ./check_procs -a httpd -c 1
PROCS OK: 11 processes with args 'httpd' | procs=11;;1;0;

Re: Nagios 3.2.0 apache critical status

Posted: Fri Feb 20, 2015 3:47 am
by mike-stokkel
tgriep wrote:How about changing the script to the following?

Code: Select all

#!/bin/bash

#Check if apache2 is running
apache=$(service apache2 status)

if [[ $apache == *"running"* ]];then                                                                                                                                                                                   
   echo "$apache"
   exit 0
else
   echo "$apache"
   exit 2
fi
im getting the same error
apache CRITICAL 2015-02-20 09:39:31 31d 0h 30m 43s 4/4 Apache2 is running (pid 4186).
EDIT: OWH WAIT!! IT DOES WORK!!! WASNT LOOKING AT THE RIGHT SERVER :D THANKS!

Re: Nagios 3.2.0 apache critical status

Posted: Fri Feb 20, 2015 1:43 pm
by ssax
mike-stokkel, that's great news, is it ok if we mark this as resolved and lock the topic?

Re: Nagios 3.2.0 apache critical status

Posted: Mon Feb 23, 2015 5:19 am
by mike-stokkel
ssax wrote:mike-stokkel, that's great news, is it ok if we mark this as resolved and lock the topic?
sure!