<br><br><font size="3"><b>Forwarded Conversation</b></font><br><font size="2">Subject: <b>plugins with rsh</b></font> <br>------------------------ <br><br><font color="#808080" size="2"><b> From: dave stern - e-mail.pluribus.unum
</b> <<a href="mailto:dit.dash@gmail.com">dit.dash@gmail.com</a>> </font><font color="#808080" size="2"><div>To: <a href="mailto:nagios-users@lists.sourceforge.net">nagios-users@lists.sourceforge.net</a></div></font>
<font color="#808080" size="2"><div>Date: Wed, Jan 3, 2007 at 3:17 PM</div></font><br><div><table border="0" cellpadding="12" cellspacing="0" width="100%"><tbody><tr><td><font size="2">We have a legacy setup with tru64 hosts that are currently configured for rsh, not ssh. I've installed the latest and greatest nagios on a relatively 
<br>recent fedora host and have used plugins with ssh in the past. The problem is that rsh doesn't return status codes properly. Rather, it returns
<br>only the status code of rsh itself, not the command. A search implies you just need to echo $? with rsh.  <br><br>rsh linux to linux, I get this:<br><br>linux1> rsh linux1 'date ; echo $?'<br>Wed Jan  3 15:15:07 EST 2007
<br><br>and trying to generate an error:<br>linux1> rsh linux1 'bogus ; echo $?'<br>bogus; Command not found.<br>1<br><br>So that looks ok but first problem is when I put into nagios commands<br>define ....<br>

   rsh $HOSTADDRESS$ 'mycommand; echo $?'<br>The web page show "(No output!)<br><br>Is it possible it swallows the quotes?<br><br>Further, rsh behaves differently on tru64:<br><br>linux1> rsh tru64-host 'date;echo $?'
<br>Variable syntax.<br><br>Any ideas for these problems? <br><br>Thanks<br><br>and <br>

</font></td></tr> </tbody></table></div><br>-------- <br><font color="#808080" size="2"><b> From: Lacayo, Luis F</b> <<a href="mailto:lflacayo@cps.k12.il.us">lflacayo@cps.k12.il.us</a>> </font><font color="#808080" size="2">
<div>To: "dave stern - e-mail.pluribus.unum" <<a href="mailto:dit.dash@gmail.com">dit.dash@gmail.com</a>>, <a href="mailto:nagios-users@lists.sourceforge.net">nagios-users@lists.sourceforge.net</a></div></font>
<font color="#808080" size="2"><div>Date: Wed, Jan 3, 2007 at 3:26 PM</div></font><br><div><table border="0" cellpadding="12" cellspacing="0" width="100%"><tbody><tr><td><font size="2">













<div link="blue" vlink="purple" lang="EN-US">

<div>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;">Try adding a second $ at the end of the
command.</span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font face="Times New Roman" size="3"><span style="font-size: 12pt;">rsh $HOSTADDRESS$ 'mycommand; echo $$?'<br>
</span></font><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<p><font color="navy" face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></font></p>

<div>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;">Luis Lacayo</span></font></p>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;">Sr. UNIX Admin</span></font></p>

<p><font color="blue" face="Times New Roman" size="3"><span style="font-size: 12pt; color: blue;">C</span></font><font color="navy"><span style="color: navy;">hicago </span></font><font color="blue"><span style="color: blue;">
P</span></font><font color="navy"><span style="color: navy;">ublic
</span></font><font color="blue"><span style="color: blue;">S</span></font><font color="navy"><span style="color: navy;">chools</span></font></p>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;">Office of Technology Services</span></font></p>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;">125 S. Clark Street</span></font><font color="navy"><span style="color: navy;"> – Suite
 300</span></font></p>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;">Chicago</span></font><font color="navy"><span style="color: navy;">, IL
60603</span></font></p>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;">Direct:773-553-3835</span></font></p>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;">Office: 773-553-1300</span></font></p>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;">FAX:773-553-1363</span></font></p>

<p><font color="navy" face="Times New Roman" size="3"><span style="font-size: 12pt; color: navy;"><a href="mailto:lflacayo@cps.k12.il.us" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">lflacayo@cps.k12.il.us
</a></span></font></p>

</div>

<div>

<div style="text-align: center;" align="center"><font face="Times New Roman" size="3"><span style="font-size: 12pt;">

<hr align="center" size="2" width="100%">

</span></font></div>

<p><b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size: 10pt; font-family: Tahoma;">
<a href="mailto:nagios-users-bounces@lists.sourceforge.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">nagios-users-bounces@lists.sourceforge.net</a>
[mailto:<a href="mailto:nagios-users-bounces@lists.sourceforge.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">nagios-users-bounces@lists.sourceforge.net</a>] <b><span style="font-weight: bold;">
On Behalf Of </span></b>dave stern - e-mail.pluribus.unum<br>
<b><span style="font-weight: bold;">Sent:</span></b> Wednesday, January 03, 2007
2:17 PM<br>
<b><span style="font-weight: bold;">To:</span></b>
<a href="mailto:nagios-users@lists.sourceforge.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">nagios-users@lists.sourceforge.net</a><br>
<b><span style="font-weight: bold;">Subject:</span></b> [Nagios-users] plugins
with rsh</span></font></p>

</div><div style="padding: 5px 0pt;"><font color="#888888" size="1">[Quoted text hidden]</font></div></div>

</div>



</font></td></tr> </tbody></table></div><br>-------- <br><font color="#808080" size="2"><b> From: Darren Dunham</b> <<a href="mailto:ddunham@taos.com">ddunham@taos.com</a>> </font><font color="#808080" size="2"><div>
To: "dave stern - e-mail.pluribus.unum" <<a href="mailto:dit.dash@gmail.com">dit.dash@gmail.com</a>></div></font><font color="#808080" size="2"><div>Date: Wed, Jan 3, 2007 at 4:17 PM</div></font><br><div><table border="0" cellpadding="12" cellspacing="0" width="100%">
<tbody><tr><td><font size="2"><font color="#550055">> Further, rsh behaves differently on tru64:<br>><br>> linux1> rsh tru64-host 'date;echo $?'<br>> Variable syntax.<br><br></font>$? is a bourne-style parameter for status.  Older csh-style shells may
<br>not support it (although looking around, I was surprised to find a few<br>/bin/csh shells that did).  Specifically, "Variable syntax" appears to<br>be a csh error message to me.<br><br>Is the account you're accessing on the tru64 machine using a csh shell?
<br><font color="#888888"><br>--<br>Darren Dunham                                           <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:ddunham@taos.com">ddunham@taos.com</a><br>Senior Technical Consultant         TAOS            
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.taos.com/" target="_blank">http://www.taos.com/</a><br>Got some Dr Pepper?                           San Francisco, CA bay area<br>         < This line left intentionally blank to confuse you. >
<br></font></font></td></tr> </tbody></table></div><br>-------- <br><br>These were both great suggestions. Here's where I stand now (hopefully this can help others altho this<br>isn't yet resolved)<br><br>nagios user has a csh. I can either change that or get around it by prepending to the nagios command /usr/bin/sh 
<br>Also, rsh interprets two dollars as PID eg if I<br>Linux1> rsh hostname 'date; echo $$?'  <br>Thu Jan  4 12:38:36 EST 2007<br>12344<br><br>Turns out, it will interpret $status correctly ie<br>Linux1> rsh hostname 'date; echo $status'
<br>Thu Jan  4 12:38:36 EST 2007<br>0<br><br>>linux1> rsh hostname 'bogus; echo $status'<br>bogus; Command not found<br>1<br><br>(Hope I got that right, manufacturing this from memory as nagios network is airgapped to internet)
<br><br>The problem is still getting the info back to nagios. Putting the above command into nagios's command.cfg<br>and setting up two such services, one on a host that will report success and one on a host that will fail, I get
<br>both hosts reporting "(No output!) in the far right nagios column. If I remove everything after the semicolon,<br>the command runs and the output is correct but the status code isn't returned thus the service color isn't
<br>updated. Changing "echo $status" to "echo $$status" also makes no difference so nagios appears to be<br>choking on the two commands (ie when it hits the ";")<br><br>