diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp index 3a2d2f509..e87395a42 100644 --- a/components/compat/compatcomponent.cpp +++ b/components/compat/compatcomponent.cpp @@ -336,14 +336,25 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt { ASSERT(service->OwnsLock()); + String raw_output; String output; + String long_output; String perfdata; double schedule_end = -1; Dictionary::Ptr cr = service->GetLastCheckResult(); 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"); 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" << "state_type=" << service->GetStateType() << "\n" << "\t" << "plugin_output=" << output << "\n" + << "\t" << "long_plugin_output=" << long_output << "\n" << "\t" << "performance_data=" << perfdata << "\n" << "\t" << "last_check=" << schedule_end << "\n" << "\t" << "next_check=" << service->GetNextCheck() << "\n" diff --git a/components/compat/compatlog.cpp b/components/compat/compatlog.cpp index e7d93dc12..7d74fefe9 100644 --- a/components/compat/compatlog.cpp +++ b/components/compat/compatlog.cpp @@ -147,6 +147,18 @@ void CompatLog::CheckResultRequestHandler(const RequestMessage& request) 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; msgbuf << "SERVICE ALERT: " << host->GetName() << ";" @@ -154,6 +166,7 @@ void CompatLog::CheckResultRequestHandler(const RequestMessage& request) << Service::StateToString(static_cast(state_after)) << ";" << Service::StateTypeToString(static_cast(stateType_after)) << ";" << attempt_after << ";" + << output << "" << ""; { @@ -168,6 +181,7 @@ void CompatLog::CheckResultRequestHandler(const RequestMessage& request) << Host::StateToString(Host::CalculateState(static_cast(state_after), host_reachable_after)) << ";" << Service::StateTypeToString(static_cast(stateType_after)) << ";" << attempt_after << ";" + << output << "" << ""; {