Просмотр исходного кода

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

madlohe 4 лет назад
Родитель
Сommit
c74ff31ba0
1 измененных файлов с 8 добавлено и 4 удалено
  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 */
 	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.
 	 * Wrap up quickly and keep the tricks below */
 	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)
 			for (i = skip_stdout; i < chld_out.lines; i++)
 				puts (chld_out.line[i]);
 		else
 			printf (_("%s - check_by_ssh: Remote command '%s' returned status %d\n"),
 			        state_text(result), remotecmd, result);
-		return result; 	/* return error status from remote command */
+		return result;
 	}