From: Michael Friedrich Date: Thu, 14 Aug 2014 14:15:01 +0000 (+0200) Subject: Fix external command pipe: Too many open files X-Git-Tag: v2.1.0~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a3f7d774c2dce7750103913b2864c3c588b386f;p=icinga2 Fix external command pipe: Too many open files fixes #6916 --- diff --git a/components/compat/externalcommandlistener.cpp b/components/compat/externalcommandlistener.cpp index 64ec44dfa..fe25bc4c3 100644 --- a/components/compat/externalcommandlistener.cpp +++ b/components/compat/externalcommandlistener.cpp @@ -111,9 +111,7 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath) return; } - - - Log(LogNotice, "ExternalCommandListener", "Client connected"); + Log(LogDebug, "ExternalCommandListener", "Client connected"); Utility::QueueAsyncCallback(boost::bind(&ExternalCommandListener::ClientHandler, this, commandPath, fd)); } catch (std::exception&) { Log(LogCritical, "ExternalCommandListener", "Cannot accept new connection."); @@ -144,6 +142,19 @@ void ExternalCommandListener::ClientHandler(const String& commandPath, int fd) String command = line; + if (command.IsEmpty()) { + fclose(fp); + return; + } + + /* check if line contains [$unixts] */ + if (line[0] != '[' || line[11] != ']') { + Log(LogDebug, "ExternalCommandListener", "Cannot find timestamp prefix in external command '" + command + "'. Bailing out."); + delete line; + fclose(fp); + return; + } + try { Log(LogInformation, "ExternalCommandListener", "Executing external command: " + command); @@ -152,7 +163,6 @@ void ExternalCommandListener::ClientHandler(const String& commandPath, int fd) std::ostringstream msgbuf; msgbuf << "External command failed."; Log(LogWarning, "ExternalCommandListener", msgbuf.str()); - return; } delete line; diff --git a/tools/scripts/process_check_result b/tools/scripts/process_check_result index 6d01ace0c..c329c0554 100755 --- a/tools/scripts/process_check_result +++ b/tools/scripts/process_check_result @@ -89,6 +89,6 @@ else fi echo "Sending '$ECHO $CMDLINE >> $CMDFILE'" -`$ECHO $CMDLINE >> $CMDFILE` +`$ECHO "$CMDLINE" >> $CMDFILE` exit 0