Procházet zdrojové kódy

Merge branch 'master' of git://github.com/Renater/nagios-plugins into Renater-master

madlohe před 4 roky
rodič
revize
c74ff31ba0
1 změnil soubory, kde provedl 8 přidání a 4 odebrání
  1. 8 4
      plugins/check_by_ssh.c

+ 8 - 4
plugins/check_by_ssh.c

@@ -107,21 +107,25 @@ main (int argc, char **argv)
 
 
 	/* UNKNOWN or worse if (non-skipped) output found on stderr */
 	/* UNKNOWN or worse if (non-skipped) output found on stderr */
 	if(chld_err.lines > skip_stderr) {
 	if(chld_err.lines > skip_stderr) {
-		printf (_("Remote command execution failed: %s\n"),
-		        chld_err.line[skip_stderr]);
-		return max_state_alt(result, STATE_UNKNOWN);
+		result = max_state_alt(result, STATE_UNKNOWN);
+		printf (_("%s - check_by_ssh: Remote command execution failed: %s\n"),
+		        state_text(result), chld_err.line[skip_stderr]);
+		return result;
 	}
 	}
 
 
 	/* this is simple if we're not supposed to be passive.
 	/* this is simple if we're not supposed to be passive.
 	 * Wrap up quickly and keep the tricks below */
 	 * Wrap up quickly and keep the tricks below */
 	if(!passive) {
 	if(!passive) {
+		/* UNKNOWN if result exceed nagios plugins conventions,
+		 * such as ssh or other remote execution error */
+		result = min(result, STATE_UNKNOWN);
 		if (chld_out.lines > skip_stdout)
 		if (chld_out.lines > skip_stdout)
 			for (i = skip_stdout; i < chld_out.lines; i++)
 			for (i = skip_stdout; i < chld_out.lines; i++)
 				puts (chld_out.line[i]);
 				puts (chld_out.line[i]);
 		else
 		else
 			printf (_("%s - check_by_ssh: Remote command '%s' returned status %d\n"),
 			printf (_("%s - check_by_ssh: Remote command '%s' returned status %d\n"),
 			        state_text(result), remotecmd, result);
 			        state_text(result), remotecmd, result);
-		return result; 	/* return error status from remote command */
+		return result;
 	}
 	}