<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Send to nagios-users@lists.sourceforge.net<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Greetings, all. I’ve googled the subject above and evaluated the answers I’ve found but haven’t yet found info that pinpoints my issue.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m running Nagios Core 3.2.1 on RedHat 5.8. This installation has been running for a few years, I just inherited it’s care and maintenance recently. On one of my monitored servers I write a script “checkRAID.sh” that calls another piece
of code, looks at the results, and returns either a 0 or a 2 (the result will always be either good or critical, depending on whether the RAID controller is unhappy).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Nagios runs as user “nagios”. The remote machine is configured to allow user “nagios” to log in without a password, using a key pair. This works.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In /usr/local/nagios/etc/checkcommands.cfg I have :<o:p></o:p></p>
<p class="MsoNormal">define command{<o:p></o:p></p>
<p class="MsoNormal"> command_name check_raid<o:p></o:p></p>
<p class="MsoNormal"> command_line /usr/local/nagios/libexec/check_by_ssh -H $HOSTNAME -l nagios -i /home/nagios/.ssh/id_rsa -E -o StrictHostKeyChecking=no -C /home/nagios/checkRAID.sh<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">When I become nagios (“su – nagios”) and run that script, I get:<o:p></o:p></p>
<p class="MsoNormal">[nagios@nagios ~]$ /usr/local/nagios/libexec/check_by_ssh -H <remote server IP> -l nagios -i /home/nagios/.ssh/id_rsa -E -o StrictHostKeyChecking=no -C /home/nagios/checkRAID.sh<o:p></o:p></p>
<p class="MsoNormal">Check failed<o:p></o:p></p>
<p class="MsoNormal">[nagios@nagios ~]$ echo $?<o:p></o:p></p>
<p class="MsoNormal">2<o:p></o:p></p>
<p class="MsoNormal">[nagios@nagios ~]$<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">That “Check failed” line is what’s written to stdout just before returning an exit code of 2. This shows me that the remote script is working fine, and that the local nagios user is able to execute it with no problems. However, once I
add an entry to services.cfg to tie this service check to my remote host and give it time to run the command, when I look at nagios’ “Services” page it shows :<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">check_raid CRITICAL 06-10-2013 21:17:25 0d 6h 14m 29s 3/3 (Return code of 127 is out of bounds - plugin may be missing)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This has me baffled. The return code is quite clearly 2. <o:p>
</o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I recently set debug_level to -1 and restarted. I’m hoping that the debug log will
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Daniel Mahoney<o:p></o:p></p>
<p class="MsoNormal">Dm572j@att.com<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>