PLINK does not return value inside plugin shell script


Hi there,

I’ve written a shell script to use as a plugin. Inside the script, I run “plink” to a device to retrieve it’s temperatures. When running the script manually from the command like it works. When nagios executes it, I do not get any values returned from plink

(plink is a command line interface from putty)

Now I know the script runs because I see the “plink” process appear in “top” AND a tcpdump shows that ssh packets are sent/received but my script still doesn’t return any values.

I’m running Nagios Version 3.0rc1 on a Fedora Core 8 box.

Here’s a copy of my script:
#! /bin/sh


Check the various temperature values of a LifeSize unit

help() {

echo "Usage: "
echo “Example: ./”



if -z “$thehost” ]
echo "No IP Address"
exit 3

thetemps=$plink -2 -l user -pw password $thehost get system temp | $head -n 1

here the variable the temp should contain 4 comma seperated values


if -z “$thetemps” ]
echo "No values retrieved from $thehost"
exit 3

This is where nagios gets to and spews out the results because thetemps is empty


board=echo "$thetemps" | awk -F, '{print $1}'
video_in=echo "$thetemps" | awk -F, '{print $2}'
video_out=echo "$thetemps" | awk -F, '{print $3}'
ambient=echo "$thetemps" | awk -F, '{print $4}'

if $board -gt 84 ] || $video_in -gt 84 ] || $video_out -gt 84 ] || $ambient -gt 84 ]
echo -n "CRITICAL : Board:$board Video-in:$video_in Video-out:$video_out Ambient:$ambient"
exit 2
elif $board -gt 82 ] || $video_in -gt 82 ] || $video_out -gt 82 ] || $ambient -gt 82 ]
echo -n "WARNING : Board:$board Video-in:$video_in Video-out:$video_out Ambient:$ambient"
exit 1
echo -n "OKAY: Board:$board Video-in:$video_in Video-out:$video_out Ambient:$ambient"
exit 0

echo -n "Unknown values or other problem"
exit 3

Here’s my command and service definitions:
define command{
command_name check_ls_temp
command_line $USER1$/ $HOSTADDRESS$

define service{
use generic-service
host_name clinic_lifesize
service_description TEMPERATURES
check_command check_ls_temp

Please help.


Okay I’ve figured it out.
I redirected stderr to a file and noticed that plink was prompting for a y/n to store the key file. I had done this manually by logging on as the nagios user but I guess it did not work.

What I did was generete a key pair using ssh-keygen and copied the .pub key to the device and now I use ssh instead of plink.

Thanks anyways …