mirror of https://github.com/Icinga/icinga2.git
Merge pull request #10021 from Icinga/output-exit-code-52294
Mention plugin exit codes outside [0..3] in the plugin output and warning log
This commit is contained in:
commit
62512bbe2d
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "base/i2-base.hpp"
|
#include "base/i2-base.hpp"
|
||||||
#include "base/dictionary.hpp"
|
#include "base/dictionary.hpp"
|
||||||
|
#include <cstdint>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -25,7 +26,7 @@ struct ProcessResult
|
||||||
pid_t PID;
|
pid_t PID;
|
||||||
double ExecutionStart;
|
double ExecutionStart;
|
||||||
double ExecutionEnd;
|
double ExecutionEnd;
|
||||||
long ExitStatus;
|
int_fast64_t ExitStatus;
|
||||||
String Output;
|
String Output;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
library icinga;
|
library icinga;
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
@ -50,7 +52,7 @@ class CheckResult
|
||||||
[state] Timestamp execution_end;
|
[state] Timestamp execution_end;
|
||||||
|
|
||||||
[state] Value command;
|
[state] Value command;
|
||||||
[state] int exit_status;
|
[state] int_fast64_t exit_status;
|
||||||
|
|
||||||
[state, enum] ServiceState "state";
|
[state, enum] ServiceState "state";
|
||||||
[state, enum] ServiceState previous_hard_state;
|
[state, enum] ServiceState previous_hard_state;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include "base/process.hpp"
|
#include "base/process.hpp"
|
||||||
#include "base/convert.hpp"
|
#include "base/convert.hpp"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -66,15 +67,22 @@ void PluginCheckTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, co
|
||||||
Checkable::CurrentConcurrentChecks.fetch_sub(1);
|
Checkable::CurrentConcurrentChecks.fetch_sub(1);
|
||||||
Checkable::DecreasePendingChecks();
|
Checkable::DecreasePendingChecks();
|
||||||
|
|
||||||
|
String output = pr.Output.Trim();
|
||||||
|
|
||||||
if (pr.ExitStatus > 3) {
|
if (pr.ExitStatus > 3) {
|
||||||
Process::Arguments parguments = Process::PrepareCommand(commandLine);
|
Process::Arguments parguments = Process::PrepareCommand(commandLine);
|
||||||
Log(LogWarning, "PluginCheckTask")
|
Log(LogWarning, "PluginCheckTask")
|
||||||
<< "Check command for object '" << checkable->GetName() << "' (PID: " << pr.PID
|
<< "Check command for object '" << checkable->GetName() << "' (PID: " << pr.PID
|
||||||
<< ", arguments: " << Process::PrettyPrintArguments(parguments) << ") terminated with exit code "
|
<< ", arguments: " << Process::PrettyPrintArguments(parguments) << ") terminated with exit code "
|
||||||
<< pr.ExitStatus << ", output: " << pr.Output;
|
<< pr.ExitStatus << ", output: " << pr.Output;
|
||||||
}
|
|
||||||
|
|
||||||
String output = pr.Output.Trim();
|
std::stringstream crOutput;
|
||||||
|
|
||||||
|
crOutput << "<Terminated with exit code " << pr.ExitStatus
|
||||||
|
<< " (0x" << std::noshowbase << std::hex << std::uppercase << pr.ExitStatus << ").>";
|
||||||
|
|
||||||
|
output += crOutput.str();
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<String, String> co = PluginUtility::ParseCheckOutput(output);
|
std::pair<String, String> co = PluginUtility::ParseCheckOutput(output);
|
||||||
cr->SetCommand(commandLine);
|
cr->SetCommand(commandLine);
|
||||||
|
|
Loading…
Reference in New Issue