Plugin to grep command output - Not working with SSH

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
dave@vooservers
Posts: 9
Joined: Mon Mar 31, 2014 6:18 pm

Plugin to grep command output - Not working with SSH

Post by dave@vooservers »

Hi guys,

Hope someone can help, so I don't know everything about linux systems, as I've only had to interact with them for this job, but I know enough to get by. Let me explain the scenario.

We have come into a situation where we need to be able to monitor the states of degraded virtual disks within OnApp VM's within a cloud. This can be done by running a "getdegradedvdisks" command from the OnApp API on each HyperVisor within the cloud, but due to the number of Hypervisors, this is not possible to do full scale. So we set up access via SSH Keys for the Control Server in the cloud to be able to ssh into the Hypervisors. Now from the control server in each cloud we simply run:

# ssh root@10.10.21.123 getdegradedvdisks

And it returns the output for the hypervisor at that private IP.

grepping that for a specific string is simple, and the string "VDisks:" can be used to single out lines where degraded vdisks are present, so thats perfectly fine. The issue comes from getting Nagios to run that and grep the output and return exit states based on it.

I've come across the following plugin:

http://exchange.nagios.org/directory/Pl ... ut/details

Which on the face of it should work perfectly (with a little modifying of output states etc, nothing hard)... But...

It doesnt. I've tried running it locally on the HV's with a simple command, giving it /usr/bin/tail for example, and a parameter of /var/log/messages then giving it a --critical value of "snmpd" for exmaple, will return critical output state if tailing the messages log contained an snmpd error.

Now I go full prooduction on it and give it /usr/bin/ssh, a parameter of root@10.10.... etc and give it the --critical value of "VDisks:" as previously mentioned, and it does, nothing. Infact it locks my SSH session in putty, I can't brak the operation or anything, I have to close the session and make a new one, lol... Which is strange. It seems the plugin just doesnt like SSH'ing to another machine, i cant see why thsi should be an issue though, it should just work.

Any ideas? I've also tried eliminating the parameter addition, and just putting the whole ssh command into the --command variable, if i do this, the check seemingly does not execute, it just drops the console to a new line, no output from the plugin at all, no errors, no usage instructions, ntohing, just drops a line.

Help a nagios noob out? Cheers all in advance,

Dave.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Plugin to grep command output - Not working with SSH

Post by sreinhardt »

Would I be correct in thinking your command looks something like:

./check_execgrep.pl --critical=[critical string] --warning=[warning string] --command=/bin/ssh --parameter=root@10.10.21.123 getdegradedvdisks

Some basic questions to start off with.

Have you been able to execute this on the remote system with other commands than ssh, such as tail like you mentioned?
Have you tried quoting the --parameter string? Considering it contains spaces, I would not be surprised if the plugin was having issues with that alone.
Is there a reason, not that this is wrong, that you are not just writing a simple bash script to do this same functionality, that might just take the hostname that you wish to check as an argument and handles the rest internally?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
dave@vooservers
Posts: 9
Joined: Mon Mar 31, 2014 6:18 pm

Re: Plugin to grep command output - Not working with SSH

Post by dave@vooservers »

sreinhardt wrote:Would I be correct in thinking your command looks something like:

./check_execgrep.pl --critical=[critical string] --warning=[warning string] --command=/bin/ssh --parameter=root@10.10.21.123 getdegradedvdisks

Some basic questions to start off with.

Have you been able to execute this on the remote system with other commands than ssh, such as tail like you mentioned?
Have you tried quoting the --parameter string? Considering it contains spaces, I would not be surprised if the plugin was having issues with that alone.
Is there a reason, not that this is wrong, that you are not just writing a simple bash script to do this same functionality, that might just take the hostname that you wish to check as an argument and handles the rest internally?
Hi sreinhardt,

Many thanks for the reply, now I feel a little silly! Simply putting the parameter in quotes fixed it. Can't believe I didnt try that, after the hours I spent testing things. Anyway, thanks for taking the time to reply. Appreciated, it works as expected now.

Dave.
Locked