Page 1 of 2
Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 5:32 pm
by dgatlas
I've written a plugin in php which I can run at the command line fine.
When run against time, here are the values. It takes less than 5 seconds to run:
Code: Select all
real 0m2.144s
user 0m0.099s
sys 0m0.015s
But... in the XI interface I get: (Service check timed out after 60.04 seconds). When I increase the nagios service_check_timeout to 120 i get: (Service check timed out after 120.05 seconds)
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 5:34 pm
by Box293
dgatlas wrote:I've written a plugin in php which I can run at the command line fine.
Are you running the plugin as the nagios user?
Code: Select all
su nagios
./my_plugin --arguements blah
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 5:39 pm
by dgatlas
Are you running the plugin as the nagios user?
Code: Select all
su nagios
./my_plugin --arguements blah
Yes. Running the script as the nagios user also produces the desired output:
Code: Select all
# su nagios
$ ./my_plugin -H 192.168.100.100 -S
Running
$
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 5:41 pm
by Box293
At this point I suggest commenting out chunks of code in your plugin and then forcing a check from Nagios. Kind of like drawing a line in the sand.
This will help diagnose if a part of the plugin is causing the issue.
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 7:52 pm
by dgatlas
Box293 wrote:At this point I suggest commenting out chunks of code in your plugin and then forcing a check from Nagios. Kind of like drawing a line in the sand.
This will help diagnose if a part of the plugin is causing the issue.
It's throwing the error at:
Here's the entire method. I don't see anything that could be causing this. I have the same line in another method in the same script that does not cause this issue.
Code: Select all
function getSystem($url, $cookiejar) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_ENCODING => "",
CURLOPT_USERAGENT => 'spider',
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_TIMEOUT => 30,
CURLOPT_MAXREDIRS => 10,
CURLOPT_COOKIEFILE => $cookiejar,
CURLOPT_COOKIEJAR => $cookiejar,
CURLOPT_URL => $url
));
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 9:39 pm
by dgatlas
Now the plugin seems to run but shows
Also when defining the service, there is a "Test Check Command" button, which also outputs correctly.
Code: Select all
COMMAND: /usr/local/nagios/libexec/my_plugin.php -H 192.168.100.100 -S
OUTPUT: Running
The plugin was uploaded through the XI Admin page > Manage Plugins
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 9:40 pm
by Box293
I'm not familiar with curl but I've been looking online at some examples.
I know this is probably not going to make a difference, but perhaps define the array first.
Code: Select all
function getSystem($url, $cookiejar) {
$options_array = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_ENCODING => "",
CURLOPT_USERAGENT => 'spider',
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_TIMEOUT => 30,
CURLOPT_MAXREDIRS => 10,
CURLOPT_COOKIEFILE => $cookiejar,
CURLOPT_COOKIEJAR => $cookiejar,
CURLOPT_URL => $url
);
$curl = curl_init();
curl_setopt_array($curl, $options_array);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
Is there a specific error that is being returned?
Also, are CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR supposed to be using the same variable $cookiejar?
Code: Select all
CURLOPT_COOKIEFILE => $cookiejar,
CURLOPT_COOKIEJAR => $cookiejar,
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 9:46 pm
by Box293
dgatlas wrote:Also when defining the service, there is a "Test Check Command" button, which also outputs correctly.
Be wary of using the Test Check Command button as those commands are executed as the user apache instead of nagios and some funny character escaping can occur. Use the "force an immediate check" on the service screen for a true test.
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 9:55 pm
by dgatlas
I've removed
already, that was just for debug. The script seems to pass all that after I changed:
Code: Select all
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_TIMEOUT => 30,
to
Code: Select all
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 10,
Now it doesn't display any output:
If I change the exit code to
That change is reflected on the dashboard with a "Warning" status but still no output.
Re: Service check timed out after 60.04 seconds
Posted: Tue Feb 03, 2015 10:00 pm
by dgatlas
Be wary of using the Test Check Command button as those commands are executed as the user apache instead of nagios and some funny character escaping can occur. Use the "force an immediate check" on the service screen for a true test.
Running as "nagios" still outputs correctly. Both using
and
and yes I'm using "Schedule a forced immediate check".