Module: check_mk
Branch: master
Commit: 9f976aab568b4680d5bee7306dc7fd60353cdef5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9f976aab568b46…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Jun 8 11:31:15 2016 +0200
3643 FIX Fixed check_mkevents active check.
check_mkevents didn't make sure that the whole request was sent. Furthermore,
it didn't shutdown the socket after sending the request. This (or sending an
empty line) is necessary in recent versions of mkeventd.
---
.werks/3643 | 11 +++++++++++
ChangeLog | 1 +
doc/treasures/active_checks/check_mkevents.cc | 21 +++++++++++++++++++--
doc/treasures/active_checks/check_mkevents.py | 3 ++-
4 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/.werks/3643 b/.werks/3643
new file mode 100644
index 0000000..a5ae21b
--- /dev/null
+++ b/.werks/3643
@@ -0,0 +1,11 @@
+Title: Fixed check_mkevents active check.
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1465378101
+Class: fix
+
+check_mkevents didn't make sure that the whole request was sent. Furthermore,
+it didn't shutdown the socket after sending the request. This (or sending an
+empty line) is necessary in recent versions of mkeventd.
diff --git a/ChangeLog b/ChangeLog
index e3233eb..2c78140 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -262,6 +262,7 @@
* 3540 FIX: Fixed exception on reading cachefiles...
* 3541 FIX: esx_vsphere_hostsystem.state: no longer crashes when data is missing...
* 3590 FIX: mssql.vbs: Completely removed plugin timeout...
+ * 3643 FIX: Fixed check_mkevents active check....
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/doc/treasures/active_checks/check_mkevents.cc
b/doc/treasures/active_checks/check_mkevents.cc
index 848d81a..6506a84 100644
--- a/doc/treasures/active_checks/check_mkevents.cc
+++ b/doc/treasures/active_checks/check_mkevents.cc
@@ -214,8 +214,25 @@ int main(int argc, char** argv)
}
// Send message
- ssize_t length = write(sock, query_message.c_str(), query_message.length());
- (void)length; // Make GCC happy
+ {
+ const char *buffer = query_message.c_str();
+ size_t bytes_to_write = query_message.size();
+ while (bytes_to_write > 0) {
+ ssize_t bytes_written = write(sock, buffer, bytes_to_write);
+ if (bytes_written == -1) {
+ printf("UNKNOWN - Cannot send query to event daemon via TCP %s:%d
(%s)\n",
+ remote_hostipaddress, remote_port, strerror(errno));
+ exit(3);
+ }
+ buffer += bytes_written;
+ bytes_to_write -= bytes_written;
+ }
+ if (shutdown(sock, SHUT_WR) == -1) {
+ printf("UNKNOWN - Cannot shutdown socket to event daemon via TCP %s:%d
(%s)\n",
+ remote_hostipaddress, remote_port, strerror(errno));
+ exit(3);
+ }
+ }
// Get response
char response_chunk[4096];
diff --git a/doc/treasures/active_checks/check_mkevents.py
b/doc/treasures/active_checks/check_mkevents.py
index c28bf5e..ad1d540 100755
--- a/doc/treasures/active_checks/check_mkevents.py
+++ b/doc/treasures/active_checks/check_mkevents.py
@@ -52,7 +52,8 @@ def query(query, remote_host):
sock.settimeout(3)
sock.connect(socket_path)
- sock.send(query)
+ sock.sendall(query)
+ sock.shutdown(socket.SHUT_WR)
response_text = ""
while True: