Module: check_mk
Branch: master
Commit: c7349985ec1b0a75d7b8d0da720453396a3025e5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c7349985ec1b0a…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue May 31 11:37:27 2016 +0200
3629 gude_relayport: new check which monitors the ON/OFF state of a GUDE Power Control device
---
.werks/3629 | 9 +++++++
ChangeLog | 1 +
checkman/gude_relayport | 14 +++++++++++
checks/gude_relayport | 60 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 84 insertions(+)
diff --git a/.werks/3629 b/.werks/3629
new file mode 100644
index 0000000..61c02e8
--- /dev/null
+++ b/.werks/3629
@@ -0,0 +1,9 @@
+Title: gude_relayport: new check which monitors the ON/OFF state of a GUDE Power Control device
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1464687418
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index ca62d54..b5ea174 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,6 +93,7 @@
NOTE: Please refer to the migration notes!
* 3138 jolokia_metrics.cache_hits, jolokia_metrics.in_memory, jolokia_metrics.off_heap, jolokia_metrics.on_disk, jolokia_metrics.writer: added checks for monitoring of ehcache metrics through jolokia...
* 3628 emcvnx_mirrorview: new check which monitors the mirrorviews of EMC VNX storage system...
+ * 3629 gude_relayport: new check which monitors the ON/OFF state of a GUDE Power Control device
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/checkman/gude_relayport b/checkman/gude_relayport
new file mode 100644
index 0000000..ea41f61
--- /dev/null
+++ b/checkman/gude_relayport
@@ -0,0 +1,14 @@
+title: GUDE Power Control: Relay port status
+agents: snmp
+catalog: hw/other
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the ON/OFF state of a GUDE Power
+ Control device which supports the GUDEADS-EPC1100-MIB.
+
+item:
+ The relay port name.
+
+inventory:
+ One service per relay port is created.
diff --git a/checks/gude_relayport b/checks/gude_relayport
new file mode 100644
index 0000000..9a47499
--- /dev/null
+++ b/checks/gude_relayport
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2016 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+# .1.3.6.1.4.1.28507.19.1.3.1.2.1.2.1 Power Port 1 --> GUDEADS-EPC1100-MIB::epc1100PortName.1
+# .1.3.6.1.4.1.28507.19.1.3.1.2.1.3.1 1 --> GUDEADS-EPC1100-MIB::epc1100PortState.1
+
+
+def inventory_gude_relayport(info):
+ for port_name, port_status in info:
+ if port_status != "0":
+ yield port_name, None
+
+
+def check_gude_relayport(item, params, info):
+ map_powerstates = {
+ "0" : (2, "off"),
+ "1" : (0, "on"),
+ }
+
+ for port_name, port_status in info:
+ if item == port_name:
+ state, state_readable = map_powerstates[port_status]
+ infotext = "Status: %s" % state_readable
+ return state, infotext
+
+
+check_info['gude_relayport'] = {
+ 'inventory_function' : inventory_gude_relayport,
+ 'check_function' : check_gude_relayport,
+ 'service_description' : 'Relay port %s',
+ 'snmp_info' : (".1.3.6.1.4.1.28507.19.1.3.1.2.1", [
+ "2", # GUDEADS-EPC1100-MIB::epc1100PortName
+ "3", # GUDEADS-EPC1100-MIB::epc1100PortState
+ ]),
+ 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.28507.19"),
+}
Module: check_mk
Branch: master
Commit: 29888734dbd07c32560c797365ac8a9b46682d9a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=29888734dbd07c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue May 31 10:09:22 2016 +0200
3582 FIX check_mail: Fixed issue with processing multipart mails
When the check is configured to forward mails to the event console,
it was unable to parse multipart mails. This has been fixed. The
events now get the contents of the first text/plain part added until
the configured body limit.
---
.werks/3582 | 13 +++++++++++++
ChangeLog | 1 +
doc/treasures/active_checks/check_mail | 9 +++++++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/.werks/3582 b/.werks/3582
new file mode 100644
index 0000000..2427dd8
--- /dev/null
+++ b/.werks/3582
@@ -0,0 +1,13 @@
+Title: check_mail: Fixed issue with processing multipart mails
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1464681864
+
+When the check is configured to forward mails to the event console,
+it was unable to parse multipart mails. This has been fixed. The
+events now get the contents of the first text/plain part added until
+the configured body limit.
diff --git a/ChangeLog b/ChangeLog
index 1023a0c..a6d8f53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -246,6 +246,7 @@
* 3624 FIX: oracle_asm_diskgroup: fixed dismounted disk handling
* 3625 FIX: zfs_arc_cache: fixed data handling if hits and misses are missing
* 3626 FIX: dell_eql_storage: fixed scan function if sysDescr is empty
+ * 3582 FIX: check_mail: Fixed issue with processing multipart mails...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/doc/treasures/active_checks/check_mail b/doc/treasures/active_checks/check_mail
index 85b9dad..fecf5cf 100755
--- a/doc/treasures/active_checks/check_mail
+++ b/doc/treasures/active_checks/check_mail
@@ -300,8 +300,13 @@ def forward_to_ec(mails):
log_line = subject
# Now add the body to the event
if msg.is_multipart():
- for payload in msg.get_payload():
- log_line += '|' + payload.get_payload()[:body_limit]
+ # only care for the first text/plain element
+ for part in msg.walk():
+ content_type = part.get_content_type()
+ disposition = str(part.get('Content-Disposition'))
+ if content_type == 'text/plain' and 'attachment' not in disposition:
+ log_line += '|' + part.get_payload()[:body_limit]
+ break
else:
log_line += '|' + msg.get_payload()[:body_limit]
log_line = log_line.replace('\r\n', '\0')
Module: check_mk
Branch: master
Commit: 9674eb0ad458e9f4ce65a5afbd44d34457061b2d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9674eb0ad458e9…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon May 30 13:58:14 2016 +0200
Fixed the event daemon protocol, its implementation and its usage.
socket.recv can (and will, see the POSIX spec!) sometimes result in a
partial read, so we have to handle this, and basically the same holds for
socket.send. As a consequence, our protocol needs a way to determine when a
request is complete. One way of doing this is shutting down the writing
side, but this would make it impossible to handle multiple requests over the
same connection.
The solution on the receiving side is simple: Do it like Livestatus and
terminate a request with an empty line. A shutdown will of course continue
to terminate a request, too. On the sending side, use socket.sendall
instead of socket.send.
In a nutshell: 99.9% of all uses of recv/send/read/write which are not
within a loop are plainly wrong. The evil thing is that bugs caused by this
will only surface with a low probability, and even less when the I/O and/or
network load is low, i.e. basically never when doing naive testing by hand.
:-P
As a bonus, we even fix the encoding issue by defining the whole protocol to
be UTF-8-based.
---
bin/mkeventd | 75 +++++++++++++++++++++++++++++++-----------------
web/htdocs/mkeventd.py | 3 +-
2 files changed, 51 insertions(+), 27 deletions(-)
diff --git a/bin/mkeventd b/bin/mkeventd
index f613009..7ff0b8d 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -374,6 +374,30 @@ class MKClientError(Exception):
Exception.__init__(self, t)
+class Queries:
+ def __init__(self, sock):
+ self._socket = sock
+ self._buffer = ""
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ while True:
+ parts = self._buffer.split("\n\n", 1)
+ if len(parts) > 1:
+ break
+ data = self._socket.recv(4096)
+ if len(data) == 0:
+ if len(self._buffer) == 0:
+ raise StopIteration()
+ parts = [self._buffer, ""]
+ break
+ self._buffer += data
+ request, self._buffer = parts
+ return request.decode("utf-8").splitlines()
+
+
#.
# .--SNMP-Traps----------------------------------------------------------.
# | ____ _ _ __ __ ____ _____ |
@@ -2649,38 +2673,37 @@ class StatusServer:
def handle_client(self, socket, allow_commands, client_ip):
- query = decode_from_bytes(socket.recv(8192)).splitlines()
- parts = query[0].split(None, 1)
- if len(parts) != 2:
- raise MKClientError("Invalid query. Need GET/COMMAND plus argument(s)")
+ for query in Queries(socket):
+ parts = query[0].split(None, 1)
+ if len(parts) != 2:
+ raise MKClientError("Invalid query. Need GET/COMMAND plus argument(s)")
- method, table = parts
+ method, table = parts
+ output_format = "python"
- output_format = "python"
-
- with lock_eventstatus:
- if method == "GET":
- response, output_format = self.handle_get_request(table, query[1:])
+ with lock_eventstatus:
+ if method == "GET":
+ response, output_format = self.handle_get_request(table, query[1:])
- elif method == "REPLICATE":
- response = self.handle_replicate(table, client_ip)
+ elif method == "REPLICATE":
+ response = self.handle_replicate(table, client_ip)
- elif method == "COMMAND":
- if not allow_commands:
- raise MKClientError("Sorry. Commands are disallowed via TCP")
- self.handle_command_request(table)
- response = None
+ elif method == "COMMAND":
+ if not allow_commands:
+ raise MKClientError("Sorry. Commands are disallowed via TCP")
+ self.handle_command_request(table)
+ response = None
- else:
- raise MKClientError("Invalid method %s (allowed are GET, COMMAND and REPLICATE)" % method)
+ else:
+ raise MKClientError("Invalid method %s (allowed are GET, COMMAND and REPLICATE)" % method)
- if output_format == "plain":
- for line in response:
- socket.send("\t".join([to_utf8(quote_tab(c)) for c in line]))
- socket.send("\n")
- else:
- socket.send(repr(response))
- socket.send("\n")
+ if output_format == "plain":
+ for line in response:
+ socket.send("\t".join([to_utf8(quote_tab(c)) for c in line]))
+ socket.send("\n")
+ else:
+ socket.send(repr(response))
+ socket.send("\n")
socket.close()
diff --git a/web/htdocs/mkeventd.py b/web/htdocs/mkeventd.py
index 2a3c3bd..806dfe0 100644
--- a/web/htdocs/mkeventd.py
+++ b/web/htdocs/mkeventd.py
@@ -186,7 +186,8 @@ def query(query):
sock.settimeout(timeout)
sock.connect(socket_path)
- sock.send(query)
+ sock.sendall(query)
+ sock.shutdown(socket.SHUT_WR)
response_text = ""
while True: