Nagios 3.2.0 apache critical status

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mike-stokkel
Posts: 5
Joined: Tue Feb 17, 2015 3:40 am

Nagios 3.2.0 apache critical status

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios 3.2.0 apache critical status

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mike-stokkel
Posts: 5
Joined: Tue Feb 17, 2015 3:40 am

Re: Nagios 3.2.0 apache critical status

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios 3.2.0 apache critical status

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mike-stokkel
Posts: 5
Joined: Tue Feb 17, 2015 3:40 am

Re: Nagios 3.2.0 apache critical status

Post 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
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios 3.2.0 apache critical status

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios 3.2.0 apache critical status

Post 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;
mike-stokkel
Posts: 5
Joined: Tue Feb 17, 2015 3:40 am

Re: Nagios 3.2.0 apache critical status

Post 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!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios 3.2.0 apache critical status

Post by ssax »

mike-stokkel, that's great news, is it ok if we mark this as resolved and lock the topic?
mike-stokkel
Posts: 5
Joined: Tue Feb 17, 2015 3:40 am

Re: Nagios 3.2.0 apache critical status

Post 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!
Locked