Page 1 of 1

Top output is not send to check_nrpe

Posted: Wed Mar 30, 2016 4:05 am
by DanielRo
Hello guys. After 10 years of windows I've come back to configure some linux servers.
I've installed Nagios 4 on a server, nagios-nrpe-service on another server and used check_ps.sh from https://exchange.nagios.org/directory/P ... sh/details.
The check_ps.sh is using ps aux to get data about a running service. Because %CPU is not the actual %CPU I've changed ps aux to top -bcn 1.
The problem is that running the service locally gives an output, but when running from the nagios server gives an error that the service is not running, and the output is empty.
If instead of using top -bcn 1 I use top -bn 1 the output is received on the nagios server. I need top -bcn 1 because I need to identify a service command, not only the service.

Re: Top output is not send to check_nrpe

Posted: Wed Mar 30, 2016 10:36 am
by rkennedy
Can you post the modified script, and the full input / output you're seeing with the various results? I'll try to replicate this on my end and help find a solution.

Also, for reference, would a ps -ef work as well? This will give you the corresponding command running.

Re: Top output is not send to check_nrpe

Posted: Thu Mar 31, 2016 3:07 am
by DanielRo
I've modified this line: tmp_output=`ps aux | grep "$process" | grep -v $0` with tmp_output=`top -bcn 1 | grep "$process" | grep -v $0`.
If I have a process like: php runPhp test1 and input the test1 string I'll get an empty output on nagios server.
If I input only php it will work.
If I change the line to tmp_output=`top -bn 1 | grep "$process" | grep -v $0` it will work for input like php, but I need to monitor a specific php child.

Re: Top output is not send to check_nrpe

Posted: Thu Mar 31, 2016 12:18 pm
by tmcdonald
DanielRo wrote:The problem is that running the service locally gives an output, but when running from the nagios server gives an error that the service is not running, and the output is empty.
When you are running this on the remote server, what user are you logged in as? If you are running it as root, you might see different output.

Also, can you please post the full command you are using to test this from the Nagios server? There might be issues with the way you are having it run remotely.