last one, I promise.  using it now in prod and it's working great.  ok i'm gone (btw i'm not on this list, send comments, hate mail etc to me directly)<br><br>--- check_by_ssh.c.orig 2007-09-23 05:26:03.000000000
 -0700<br>+++ check_by_ssh.c      2008-01-08 13:39:49.000000000 -0800<br>@@ -100,7 +100,7 @@ main (int argc, char **argv)<br>                skip_stderr = chld_err.lines;<br><br>        /* UNKNOWN if (non-skipped) output found on stderr */
<br>-       if(chld_err.lines > skip_stderr) {<br>+       if(!passive && chld_err.lines > skip_stderr) {<br>                printf (_("Remote command execution failed: %s\n"),<br>                        chld_err.line[skip_stderr]);
<br>                return STATE_UNKNOWN;<br>@@ -133,16 +133,14 @@ main (int argc, char **argv)<br>        commands = 0;<br>        for(i = skip_stdout; i < chld_out.lines; i++) {<br>                status_text = strstr (chld_out.line[i], "STATUS CODE: ");
<br>-               if (status_text == NULL) {<br>-                       printf ("%s", chld_out.line[i]);<br>-                       return result;<br>-               }<br>                if (service[commands] && status_text
<br>                        && sscanf (status_text, "STATUS CODE: %d", &cresult) == 1)<br>                {<br>-                       fprintf (fp, "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;%s\n",
<br>-                                (int) local_time, host_shortname, service[commands++],<br>-                                cresult, chld_out.line[i]);<br>+                       fprintf (fp, "[%d] PROCESS_SERVICE_CHECK_RESULT;%s;%s;%d;",
<br>+                                (int) local_time, host_shortname, service[commands++], cresult);<br>+                       if (i > 0 && strstr (chld_out.line[i-1], "STATUS CODE: ") == 0) fprintf (fp, "%s\n", chld_out.line[i-1]);
<br>+                       else fprintf (fp, "%s - Remote command exit status %d\n",<br>+                                        state_text(cresult), cresult);<br>                }<br>        }<br><br>@@ -307,7 +305,7 @@ process_arguments (int argc, char **argv
<br>                                asprintf (&remotecmd, "%s", argv[c]);<br>        }<br><br>-       if (commands > 1)<br>+       if (passive)<br>                asprintf (&remotecmd, "%s;echo STATUS CODE: $?;", remotecmd);
<br><br>        if (remotecmd == NULL || strlen (remotecmd) <= 1)<br><br><br><br><div><span class="gmail_quote">On 1/7/08, <b class="gmail_sendername">mike</b> <<a href="mailto:mike@primaledge.ca">mike@primaledge.ca
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">The current one doesn't really work.  It basically did nothing if there was a \n anywhere in the command output (most commands return a \n at the end :)  This makes it better by writing the last output line (up to the \n) in the log, and doesn't abort if one of the commands has an error.  Still isn't perfect but it's usable.
<br>Enjoy,<br>Mike<br></blockquote></div><br>