Page 1 of 1

Remote process check on linux server

Posted: Tue Apr 15, 2014 9:57 am
by kgopiramesh
Hi Team,

We have a requirement to monitor the process remotely with out NRPE agent and linux monitoring wizard, We can do with the command 'ssh username@ipaddress ps -ef|grep -i process name | wc -l.

It results 1 or 2 as output but is there any way we can achieve in nagios nagios if it returns 1 the critcal status should come up along with the output.

Re: Remote process check on linux server

Posted: Tue Apr 15, 2014 10:04 am
by tmcdonald
kgopiramesh wrote:It results 1 or 2 as output but is there any way we can achieve in nagios nagios if it returns 1 the critcal status should come up along with the output.
A 1 in Nagios is always going to be a warning, a 2 will always be critical, and 0 is always OK. There is no way to change this in nagios itself. You would have to write a wrapper script that would called your ssh check, then set its own exit code based on the ssh exit code.

Re: Remote process check on linux server

Posted: Wed Apr 16, 2014 12:58 am
by Box293
checy_by_ssh is a great script for executing commands on remote hosts. It is included in the Nagios Plugins http://www.nagios.org/download/plugins.

Re: Remote process check on linux server

Posted: Wed Apr 16, 2014 10:29 am
by slansing
I agree with Box293, you can grab any custom plugins you may need, or those from the nagios plugins package, place them on the remote server and then call them using check_by_ssh.

http://assets.nagios.com/downloads/nagi ... ng_SSH.pdf

This eliminates the need to install a agent on the remote host for actively checking it.

Re: Remote process check on linux server

Posted: Thu Apr 17, 2014 7:09 am
by kgopiramesh
Thank you so much for your replies.

I have achieved it with the help of the below script


Process_Count=`ssh username@servername ps -ef | grep -i $1 | grep -v grep | wc -l`
if [ $Process_Count -ge 1 ]
then
echo "the process is running on the server"
exit 0
else
echo "the process is not running on the server"
exit 2
fi

Re: Remote process check on linux server

Posted: Thu Apr 17, 2014 9:29 am
by tmcdonald
Good to see it is working! I'll be closing this thread now, but feel free to open another if you need anything in the future!