Module: check_mk
Branch: master
Commit: 18aa4a14a5d8053b15b9af9978fc50b9d8803b39
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=18aa4a14a5d805…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Jun 20 15:38:25 2017 +0200
4693 FIX Catch communication errors with the event console when the Nagios core is used.
When issuing commands to the event console via Livestatus, communication
errors could result in termination of Nagios. This has been fixed, the
error is logged now.
Change-Id: I818b32ef12d3369a5489245f9e205d10150107ce
---
.werks/4693 | 12 ++++++++++++
livestatus/src/Store.cc | 11 ++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/.werks/4693 b/.werks/4693
new file mode 100644
index 0000000..bef8a96
--- /dev/null
+++ b/.werks/4693
@@ -0,0 +1,12 @@
+Title: Catch communication errors with the event console when the Nagios core is used.
+Level: 1
+Component: livestatus
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1497965745
+Class: fix
+
+When issuing commands to the event console via Livestatus, communication
+errors could result in termination of Nagios. This has been fixed, the
+error is logged now.
diff --git a/livestatus/src/Store.cc b/livestatus/src/Store.cc
index 7b65c24..b6bafc7 100644
--- a/livestatus/src/Store.cc
+++ b/livestatus/src/Store.cc
@@ -28,6 +28,7 @@
#include <cstring>
#include <ctime>
#include <ostream>
+#include <stdexcept>
#include <utility>
#include <vector>
#include "DowntimeOrComment.h" // IWYU pragma: keep
@@ -251,9 +252,13 @@ bool Store::handleCommand(const string &command) {
Notice(logger()) << "event console disabled, ignoring command
'"
<< command << "'";
} else {
- ECTableConnection(logger(), _mc->mkeventdSocketPath(),
- "COMMAND " + command.substr(3))
- .run();
+ try {
+ ECTableConnection(logger(), _mc->mkeventdSocketPath(),
+ "COMMAND " + command.substr(3))
+ .run();
+ } catch (const std::runtime_error &err) {
+ Alert(logger()) << err.what();
+ }
}
return true;
}