mirror of https://github.com/Icinga/icinga2.git
Compat: split cr output into (long_)output, log only output
status.dat requires output, and long_output seperated for proper representation by guis and addons (they cannot be changed for compatibility reasons, we must change). logging an ALERT requires only the output (first line of the check result output). fixes #3882 fixes #4348
This commit is contained in:
parent
6ed811cd78
commit
7c0a71bc29
|
@ -336,14 +336,25 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt
|
||||||
{
|
{
|
||||||
ASSERT(service->OwnsLock());
|
ASSERT(service->OwnsLock());
|
||||||
|
|
||||||
|
String raw_output;
|
||||||
String output;
|
String output;
|
||||||
|
String long_output;
|
||||||
String perfdata;
|
String perfdata;
|
||||||
double schedule_end = -1;
|
double schedule_end = -1;
|
||||||
|
|
||||||
Dictionary::Ptr cr = service->GetLastCheckResult();
|
Dictionary::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
output = cr->Get("output");
|
raw_output = cr->Get("output");
|
||||||
|
size_t line_end = raw_output.Find("\n");
|
||||||
|
|
||||||
|
output = raw_output.SubStr(0, line_end);
|
||||||
|
|
||||||
|
if (line_end > 0 && line_end != String::NPos) {
|
||||||
|
long_output = raw_output.SubStr(line_end+1, raw_output.GetLength());
|
||||||
|
boost::algorithm::replace_all(long_output, "\n", "\\n");
|
||||||
|
}
|
||||||
|
|
||||||
boost::algorithm::replace_all(output, "\n", "\\n");
|
boost::algorithm::replace_all(output, "\n", "\\n");
|
||||||
|
|
||||||
schedule_end = cr->Get("schedule_end");
|
schedule_end = cr->Get("schedule_end");
|
||||||
|
@ -387,6 +398,7 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt
|
||||||
<< "\t" << "current_state=" << state << "\n"
|
<< "\t" << "current_state=" << state << "\n"
|
||||||
<< "\t" << "state_type=" << service->GetStateType() << "\n"
|
<< "\t" << "state_type=" << service->GetStateType() << "\n"
|
||||||
<< "\t" << "plugin_output=" << output << "\n"
|
<< "\t" << "plugin_output=" << output << "\n"
|
||||||
|
<< "\t" << "long_plugin_output=" << long_output << "\n"
|
||||||
<< "\t" << "performance_data=" << perfdata << "\n"
|
<< "\t" << "performance_data=" << perfdata << "\n"
|
||||||
<< "\t" << "last_check=" << schedule_end << "\n"
|
<< "\t" << "last_check=" << schedule_end << "\n"
|
||||||
<< "\t" << "next_check=" << service->GetNextCheck() << "\n"
|
<< "\t" << "next_check=" << service->GetNextCheck() << "\n"
|
||||||
|
|
|
@ -147,6 +147,18 @@ void CompatLog::CheckResultRequestHandler(const RequestMessage& request)
|
||||||
return; /* Nothing changed, ignore this checkresult. */
|
return; /* Nothing changed, ignore this checkresult. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String raw_output;
|
||||||
|
String output;
|
||||||
|
|
||||||
|
if (cr) {
|
||||||
|
raw_output = cr->Get("output");
|
||||||
|
size_t line_end = raw_output.Find("\n");
|
||||||
|
|
||||||
|
output = raw_output.SubStr(0, line_end);
|
||||||
|
|
||||||
|
boost::algorithm::replace_all(output, "\n", "\\n");
|
||||||
|
}
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "SERVICE ALERT: "
|
msgbuf << "SERVICE ALERT: "
|
||||||
<< host->GetName() << ";"
|
<< host->GetName() << ";"
|
||||||
|
@ -154,6 +166,7 @@ void CompatLog::CheckResultRequestHandler(const RequestMessage& request)
|
||||||
<< Service::StateToString(static_cast<ServiceState>(state_after)) << ";"
|
<< Service::StateToString(static_cast<ServiceState>(state_after)) << ";"
|
||||||
<< Service::StateTypeToString(static_cast<StateType>(stateType_after)) << ";"
|
<< Service::StateTypeToString(static_cast<StateType>(stateType_after)) << ";"
|
||||||
<< attempt_after << ";"
|
<< attempt_after << ";"
|
||||||
|
<< output << ""
|
||||||
<< "";
|
<< "";
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -168,6 +181,7 @@ void CompatLog::CheckResultRequestHandler(const RequestMessage& request)
|
||||||
<< Host::StateToString(Host::CalculateState(static_cast<ServiceState>(state_after), host_reachable_after)) << ";"
|
<< Host::StateToString(Host::CalculateState(static_cast<ServiceState>(state_after), host_reachable_after)) << ";"
|
||||||
<< Service::StateTypeToString(static_cast<StateType>(stateType_after)) << ";"
|
<< Service::StateTypeToString(static_cast<StateType>(stateType_after)) << ";"
|
||||||
<< attempt_after << ";"
|
<< attempt_after << ";"
|
||||||
|
<< output << ""
|
||||||
<< "";
|
<< "";
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue