Hi,
I have the following problem. If I run a plugin from cli as nagios, it is working as expected:
nagios@monitor:/usr/local/nagios/libexec$ ./check_generic -e "/bin/sh /usr/local/nagios/libexec/checkipsload.sh" -w ">5" -c ">70" -n "IPS Inspection Load"
IPS Inspection Load WARNING - result:11 match:>5 severities:warning
But if i tell nagios to run the same plugin as a service, will return something like this:
IPS Inspection Load OK - result: match:none
I use check_generic with other personal writen scripts and is working as expected.
Can someone help me troubleshoot this problem, because i do not understand why running this plugin behaves different when invoked from cli and when invoked from nagios.
Thank you
The relevand config below:
define command{
command_name check_generic
command_line $USER1$/check_generic $ARG1$
}
define service {
use TemplateService
host_name ips1
service_description InspectionLOAD
check_command check_generic! -e "/bin/sh /usr/local/nagios/libexec/checkipsload.sh" -w ">5" -c ">70" -n "IPS Inspection Load"
}
Plugin ok from CLI, not ok when executed by nagios
-
- Posts: 3
- Joined: Mon Apr 14, 2014 11:00 am
-
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Plugin ok from CLI, not ok when executed by nagios
I would run the test again OUTSIDE the libexec directory
e.g.
If this works, we would need to take a look at the check_generic plugin code to test it...
e.g.
Code: Select all
cd /tmp
/usr/local/nagios/libexec/check_generic -e "/bin/sh /usr/local/nagios/libexec/checkipsload.sh" -w ">5" -c ">70" -n "IPS Inspection Load"
-
- Posts: 3
- Joined: Mon Apr 14, 2014 11:00 am
Re: Plugin ok from CLI, not ok when executed by nagios
Strange, you are right, if i run it outside the libexec it shows me the same output as the one showed by nagios.
So what could be the difference between running the plugin fon libexec folder and outside the folder?
nagios@monitor:/tmp$ ls -ld /usr/local/nagios/libexec/
drwxrwxr-x 3 nagios nagios 4096 Apr 14 16:15 /usr/local/nagios/libexec/
nagios@monitor:/tmp$ /usr/local/nagios/libexec/check_generic -e "/bin/sh /usr/local/nagios/libexec/checkipsload.sh" -w ">5" -c ">70" -n "IPS Inspection Load"
Argument "" isn't numeric in numeric gt (>) at (eval 3) line 1.
Argument "" isn't numeric in numeric gt (>) at (eval 4) line 1.
IPS Inspection Load OK - result: match:none
nagios@monitor:/usr/local/nagios/libexec$ /usr/local/nagios/libexec/check_generic -e "/bin/sh /usr/local/nagios/libexec/checkipsload.sh" -w ">5" -c ">70" -n "IPS Inspection Load"
IPS Inspection Load WARNING - result:17 match:>5 severities:warning
So what could be the difference between running the plugin fon libexec folder and outside the folder?
nagios@monitor:/tmp$ ls -ld /usr/local/nagios/libexec/
drwxrwxr-x 3 nagios nagios 4096 Apr 14 16:15 /usr/local/nagios/libexec/
nagios@monitor:/tmp$ /usr/local/nagios/libexec/check_generic -e "/bin/sh /usr/local/nagios/libexec/checkipsload.sh" -w ">5" -c ">70" -n "IPS Inspection Load"
Argument "" isn't numeric in numeric gt (>) at (eval 3) line 1.
Argument "" isn't numeric in numeric gt (>) at (eval 4) line 1.
IPS Inspection Load OK - result: match:none
nagios@monitor:/usr/local/nagios/libexec$ /usr/local/nagios/libexec/check_generic -e "/bin/sh /usr/local/nagios/libexec/checkipsload.sh" -w ">5" -c ">70" -n "IPS Inspection Load"
IPS Inspection Load WARNING - result:17 match:>5 severities:warning
-
- Posts: 3
- Joined: Mon Apr 14, 2014 11:00 am
Re: Plugin ok from CLI, not ok when executed by nagios
Hi,
I found the problem, it was the fact that in checkipsload.sh, was a relative path defined instead of full path
#!/bin/bash
/usr/bin/expect -f expectips | sed -E 's/\r//g' | grep "Inspection Load" | tr -d '\n' | awk '{print $4}'
After i change the script will full path, everithing was ok
#!/bin/bash
/usr/bin/expect -f /usr/local/nagios/libexec/expectips | sed -E 's/\r//g' | grep "Inspection Load" | tr -d '\n' | awk '{print $4}'
I found the problem, it was the fact that in checkipsload.sh, was a relative path defined instead of full path
#!/bin/bash
/usr/bin/expect -f expectips | sed -E 's/\r//g' | grep "Inspection Load" | tr -d '\n' | awk '{print $4}'
After i change the script will full path, everithing was ok
#!/bin/bash
/usr/bin/expect -f /usr/local/nagios/libexec/expectips | sed -E 's/\r//g' | grep "Inspection Load" | tr -d '\n' | awk '{print $4}'
Re: Plugin ok from CLI, not ok when executed by nagios
Good catch! expectips most likely was not in the nagios $PATH.cosmin.neagu wrote:I found the problem, it was the fact that in checkipsload.sh, was a relative path defined instead of full path
Cheers.
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.
"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.