Module: check_mk
Branch: master
Commit: 838aa818f56604781b84451e93ac686f22967200
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=838aa818f56604…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jun 28 09:32:54 2017 +0200
4918 FIX EC views: Hiding wrong icons for events that are not related to a host
This issue was introduced with 1.4.0p6.
Change-Id: Iac2278c9ea1e6b43092eb644b7043c7d80477891
---
.werks/4918 | 11 +++++++++++
web/plugins/views/mkeventd.py | 1 +
web/plugins/views/painters.py | 6 +++++-
3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/.werks/4918 b/.werks/4918
new file mode 100644
index 0000000..aefe1a5
--- /dev/null
+++ b/.werks/4918
@@ -0,0 +1,11 @@
+Title: EC views: Hiding wrong icons for events that are not related to a host
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1498635111
+
+This issue was introduced with 1.4.0p6.
diff --git a/web/plugins/views/mkeventd.py b/web/plugins/views/mkeventd.py
index 7e598e3..b5ea5c9 100644
--- a/web/plugins/views/mkeventd.py
+++ b/web/plugins/views/mkeventd.py
@@ -68,6 +68,7 @@ def query_ec_table(datasource, columns, add_columns, query, only_sites, limit, t
for row in rows:
if not row.get("host_name"):
row["host_name"] = row["event_host"]
+ row["event_is_unrelated"] = True
return rows
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index ed52745..057c434 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -397,8 +397,12 @@ def replace_action_url_macros(url, what, row):
# what: either "host" or "service"
# row: the data row of the host or service
def paint_icons(what, row):
- if not row["host_name"]:
+ # EC: In case of unrelated events also skip rendering this painter. All the icons
+ # that display a host state are useless in this case. Maybe we make this decision
+ # individually for the single icons one day.
+ if not row["host_name"] or row.get("event_is_unrelated"):
return "", ""# Host probably does not exist
+
toplevel_icons = get_icons(what, row, toplevel=True)
# In case of non HTML output, just return the top level icon names
Module: check_mk
Branch: master
Commit: e1e8b8ae5b019607d721598db9b6a821d65aae31
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e1e8b8ae5b0196…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jun 27 10:24:37 2017 +0200
Added some non blocking locking and pid_file handling code
Change-Id: I0dc2175de6bf6a049d5425b461f47ad70ad12e6f
---
lib/daemon.py | 18 ++++++++++++++++++
lib/store.py | 19 +++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/lib/daemon.py b/lib/daemon.py
index 79ea505..b9323cf 100644
--- a/lib/daemon.py
+++ b/lib/daemon.py
@@ -31,6 +31,9 @@ from grp import getgrnam
import ctypes
import ctypes.util
+import cmk.store
+from .exceptions import MKGeneralException
+
def daemonize(user=0, group=0):
# do the UNIX double-fork magic, see Stevens' "Advanced
@@ -78,6 +81,21 @@ def daemonize(user=0, group=0):
os.close(so)
+def lock_with_pid_file(path):
+ """
+ Use this after daemonizing or in foreground mode to ensure there is only
+ one process running.
+ """
+ if not cmk.store.try_aquire_lock(path):
+ raise MKGeneralException("Failed to aquire PID file lock: "
+ "Another process is already running")
+
+ # Now that we have the lock we are allowed to write our pid to the file.
+ # The pid can then be used by the init script.
+ with file(path, "w") as f:
+ f.write("%d\n" % os.getpid())
+
+
def set_cmdline(cmdline):
"""
Change the process name and process command line on of the running process
diff --git a/lib/store.py b/lib/store.py
index 6a5b18c..b7d1013 100644
--- a/lib/store.py
+++ b/lib/store.py
@@ -240,7 +240,7 @@ def save_to_mk_file(path, key, value):
g_aquired_locks = []
g_locked_paths = []
-def aquire_lock(path):
+def aquire_lock(path, blocking=True):
if path in g_locked_paths:
return True # No recursive locking
@@ -252,7 +252,11 @@ def aquire_lock(path):
# Handle the case where the file has been renamed in the meantime
while True:
- fcntl.flock(fd, fcntl.LOCK_EX)
+ flags = fcntl.LOCK_EX
+ if not blocking:
+ flags |= fcntl.LOCK_NB
+
+ fcntl.flock(fd, flags)
fd_new = os.open(path, os.O_RDONLY | os.O_CREAT, 0660)
if os.path.sameopenfile(fd, fd_new):
os.close(fd_new)
@@ -265,6 +269,17 @@ def aquire_lock(path):
g_locked_paths.append(path)
+def try_aquire_lock(path):
+ try:
+ aquire_lock(path, blocking=False)
+ return True
+ except IOError, e:
+ if e.errno == 11: # Resource temporarily unavailable
+ return False
+ else:
+ raise
+
+
def release_lock(path):
if path not in g_locked_paths:
return # no unlocking needed
Module: check_mk
Branch: master
Commit: 203bc9f512244781900368562f022d706a0e3d8c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=203bc9f5122447…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jun 27 11:54:22 2017 +0200
4901 Reworked Livestatus Proxy to be more scalable
The livestatus proxy daemon has been reworked to use a multi process
architecture. It now has a master process that mainly cares about
monitoring the site processes. Each connected site has an own subprocess
that manages all channels to this site and the clients that use these
channels to communicate with the sites.
When you have a look at ps/top you should see something like this:
C+:
OMD[heute]:~$ ps -ef | grep liveproxyd
UID PID PPID C STIME TTY TIME CMD
heute 9261 1 0 11:40 ? 00:00:00 liveproxyd[master]
heute 9262 9261 0 11:40 ? 00:00:00 liveproxyd[heute_slave_1]
heute 9263 9261 0 11:40 ? 00:00:00 liveproxyd[heute_slave_2]
C-:
As you can may see there is the master process that has the process <tt>1</tt>
as parent process. The site processes have the master as parent.
When one site process terminates for some reason the master will restart it.
When the master is terminated all site processes will terminate too. In case
of a restart or config reload the master will restart itself and stop
all site processes and restart them again.
With this change the load of the livestatus proxy will now spread over
multiple CPUs.
Side note: There is a new global setting <i>Logging of the Livestatus Proxy</i>
that can be used to control the detail level of the log entries written to the
<tt>var/log/liveproxyd.log</tt> log file. In case you experience any issues
with the livestatus proxy daemon take a look at this log file and maybe increase
the log level to get more details.
Change-Id: If50c056ae91e155b1de9d44ddd7c6b4ce436c8e4
---
.werks/4901 | 41 +++++++++++++++++++++++++++++++++++++
tests/livestatus/test_liveproxyd.py | 14 +++++++++----
2 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/.werks/4901 b/.werks/4901
new file mode 100644
index 0000000..f384e1f
--- /dev/null
+++ b/.werks/4901
@@ -0,0 +1,41 @@
+Title: Reworked Livestatus Proxy to be more scalable
+Level: 2
+Component: liveproxy
+Compatible: compat
+Edition: cee
+Version: 1.5.0i1
+Date: 1498556532
+Class: feature
+
+The livestatus proxy daemon has been reworked to use a multi process
+architecture. It now has a master process that mainly cares about
+monitoring the site processes. Each connected site has an own subprocess
+that manages all channels to this site and the clients that use these
+channels to communicate with the sites.
+
+When you have a look at ps/top you should see something like this:
+
+C+:
+OMD[heute]:~$ ps -ef | grep liveproxyd
+UID PID PPID C STIME TTY TIME CMD
+heute 9261 1 0 11:40 ? 00:00:00 liveproxyd[master]
+heute 9262 9261 0 11:40 ? 00:00:00 liveproxyd[heute_slave_1]
+heute 9263 9261 0 11:40 ? 00:00:00 liveproxyd[heute_slave_2]
+C-:
+
+As you can may see there is the master process that has the process <tt>1</tt>
+as parent process. The site processes have the master as parent.
+
+When one site process terminates for some reason the master will restart it.
+When the master is terminated all site processes will terminate too. In case
+of a restart or config reload the master will restart itself and stop
+all site processes and restart them again.
+
+With this change the load of the livestatus proxy will now spread over
+multiple CPUs.
+
+Side note: There is a new global setting <i>Logging of the Livestatus Proxy</i>
+that can be used to control the detail level of the log entries written to the
+<tt>var/log/liveproxyd.log</tt> log file. In case you experience any issues
+with the livestatus proxy daemon take a look at this log file and maybe increase
+the log level to get more details.
diff --git a/tests/livestatus/test_liveproxyd.py b/tests/livestatus/test_liveproxyd.py
index 4ab3503..c57bfb8 100644
--- a/tests/livestatus/test_liveproxyd.py
+++ b/tests/livestatus/test_liveproxyd.py
@@ -138,10 +138,10 @@ def test_large_number_of_sites(default_cfg, site):
# Currently connect to local site
site_id = "site%03d" % site_num
- if site_num % 2 == 0:
- to_livestatus = None
- else:
- to_livestatus = ('127.0.0.1', 6999)
+ #if site_num % 2 == 0:
+ to_livestatus = None
+ #else:
+ # to_livestatus = ('127.0.0.1', 6999)
site_sockets[site_id] = {
"to_livestatus" : to_livestatus,
@@ -184,6 +184,12 @@ def test_large_number_of_sites(default_cfg, site):
site.execute(["cmk", "-O"])
+ # Disable limits of livestatus xinetd service
+ #site.execute(["sed", "-i", "-r",
+ # "'/^\s+cps\s+=/d;/^\s+instances\s+=/d;/^\s+per_source\s+=/d'",
+ # "etc/xinetd.d/mk-livestatus"])
+ #site.execute(["omd", "restart", "xinetd"])
+
_change_liveproxyd_sites(site, liveproxyd_sites)
def _num_connections_opened():