Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2.03k stars 578 forks source link

[dev.icinga.com #13195] Semicolons in plugin output are converted to colon #4785

Closed icinga-migration closed 6 years ago

icinga-migration commented 8 years ago

This issue has been migrated from Redmine: https://dev.icinga.com/issues/13195

Created by elippmann on 2016-11-15 09:30:47 +00:00

Assignee: (none) Status: New Target Version: (none) Last Update: 2016-11-15 10:10:57 +00:00 (in Redmine)

Icinga Version: 2.5.4
Backport?: Not yet backported
Include in Changelog: 1

For example one can't use HTML entities in the plugin output.

icinga-migration commented 8 years ago

Updated by gbeutner on 2016-11-15 10:10:57 +00:00

CompatUtility::GetCheckResultOutput seems to be the culprit here. According to Michael this was added to improve compatibility with how Icinga 1.x handles this. The rationale being that shell scripts would have to replace semi-colons with colon when using macro values in external commands. We should probably discuss whether to change this behavior.

String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
{
        if (!cr)
                return Empty;

        String output;

        String raw_output = cr->GetOutput();

        /*
         * replace semi-colons with colons in output
         * semi-colon is used as delimiter in various interfaces
         */
        boost::algorithm::replace_all(raw_output, ";", ":");

        size_t line_end = raw_output.Find("\n");

        return raw_output.SubStr(0, line_end);
}
dnsmichi commented 7 years ago

Guess we can only change that for DB IDO, all other interfaces might break (esp. Livestatus and statusdata)

michi@mbmif ~/coding/icinga/icinga2 (master=) $ grep -r GetCheckResultOutput lib/
lib//compat/compatlogger.cpp:       output = CompatUtility::GetCheckResultOutput(cr);
lib//compat/compatlogger.cpp:       output = CompatUtility::GetCheckResultOutput(cr);
lib//compat/compatlogger.cpp:           output = CompatUtility::GetCheckResultOutput(cr);
lib//compat/compatlogger.cpp:           output = CompatUtility::GetCheckResultOutput(cr);
lib//compat/statusdatawriter.cpp:         "\t" "plugin_output=" << CompatUtility::GetCheckResultOutput(cr) << "\n"
lib//db_ido/dbevents.cpp:       fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//db_ido/dbevents.cpp:       fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//db_ido/dbevents.cpp:       output = CompatUtility::GetCheckResultOutput(cr);
lib//db_ido/dbevents.cpp:       output = CompatUtility::GetCheckResultOutput(cr);
lib//db_ido/dbevents.cpp:   fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//db_ido/hostdbobject.cpp:       fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//db_ido/servicedbobject.cpp:        fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
lib//icinga/compatutility.cpp:String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
lib//icinga/compatutility.hpp:  static String GetCheckResultOutput(const CheckResult::Ptr& cr);
lib//livestatus/hoststable.cpp:     output = CompatUtility::GetCheckResultOutput(cr);
lib//livestatus/hoststable.cpp:         output = CompatUtility::GetCheckResultOutput(cr);
lib//livestatus/servicestable.cpp:      output = CompatUtility::GetCheckResultOutput(cr);
lib//perfdata/gelfwriter.cpp:       fields->Set("short_message", CompatUtility::GetCheckResultOutput(cr));
lib//perfdata/gelfwriter.cpp:       output = CompatUtility::GetCheckResultOutput(cr);
lib//perfdata/gelfwriter.cpp:       fields->Set("short_message", CompatUtility::GetCheckResultOutput(cr));
dnsmichi commented 7 years ago

Consider it for a new backend, and partially adopt features like GelfWriter.

dnsmichi commented 6 years ago

The only real problem lies with using the output and passing it into the command pipe again. Tools should already have a safety mechanism for user inputs with colons either. I'll fix that for 2.9.