Module: check_mk
Branch: master
Commit: 9734ef3c93f31af42d8540144e54dbe7a32a93bd
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9734ef3c93f31a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Feb 27 14:44:19 2019 +0100
7189 Bookmark lists: Individual topics per bookmark can now be choosen from predefined topics
The individual topics that are defined in an existing bookmark list can now be choosen from
a dropdown field when creating new bookmark entries with individual topic.
CMK-1754
Change-Id: I378af578e8de3402bf712aa0f6bb21e7e771a9bc
---
.werks/7189 | 11 +++++++++++
cmk/gui/plugins/sidebar/bookmarks.py | 29 +++++++++++++++++++++++++----
2 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/.werks/7189 b/.werks/7189
new file mode 100644
index 0000000..a8a300c
--- /dev/null
+++ b/.werks/7189
@@ -0,0 +1,11 @@
+Title: Bookmark lists: Individual topics per bookmark can now be choosen from predefined topics
+Level: 1
+Component: multisite
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1551274970
+Class: feature
+
+The individual topics that are defined in an existing bookmark list can now be choosen from
+a dropdown field when creating new bookmark entries with individual topic.
diff --git a/cmk/gui/plugins/sidebar/bookmarks.py b/cmk/gui/plugins/sidebar/bookmarks.py
index 454fa5e..7b8cace 100644
--- a/cmk/gui/plugins/sidebar/bookmarks.py
+++ b/cmk/gui/plugins/sidebar/bookmarks.py
@@ -42,6 +42,7 @@ from cmk.gui.valuespec import (
IconSelector,
Alternative,
FixedValue,
+ OptionalDropdownChoice,
)
from . import (
@@ -135,24 +136,44 @@ class BookmarkList(pagetypes.Overridable):
@classmethod
def _vs_topic(cls):
+ choices = cls._topic_choices()
+
return Alternative(
elements=[
FixedValue(
None,
title=_("Use default topic"),
- totext=_("(default topic)"),
+ totext=_(""),
),
- TextUnicode(
+ OptionalDropdownChoice(
title=_("Individual topic"),
- size=30,
- allow_empty=False,
+ choices=choices,
+ default_value=choices[0][0] if choices else "",
+ explicit=TextUnicode(
+ size=30,
+ allow_empty=False,
+ ),
+ otherlabel="%s" % _("Add new topic"),
),
],
title=_("Topic") + "<sup>*</sup>",
style="dropdown",
+ orientation="horizontal",
)
@classmethod
+ def _topic_choices(cls):
+ topics = set()
+ for instance in cls.instances_sorted():
+ if (instance.is_mine() and instance.may_see()) or \
+ (not instance.is_mine() and instance.is_public() and instance.may_see()):
+ for topic, _bookmarks in instance.bookmarks_by_topic():
+ if topic is None:
+ topic = instance.default_bookmark_topic()
+ topics.add(topic)
+ return [(t, t) for t in sorted(list(topics))]
+
+ @classmethod
def validate_url(cls, value, varprefix):
parsed = urlparse.urlparse(value)
Module: check_mk
Branch: master
Commit: 75228a497c7c4093e251a541706e9d8f456139d3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=75228a497c7c40…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Feb 27 15:47:44 2019 +0100
Tiny comment improvements.
Change-Id: Ifd1a7862c7aed5d87454fbbd447bb9408253d440
---
livestatus/src/LogCache.cc | 54 ++++++++++++++++++----------------------------
1 file changed, 21 insertions(+), 33 deletions(-)
diff --git a/livestatus/src/LogCache.cc b/livestatus/src/LogCache.cc
index c25b00c..30068de 100644
--- a/livestatus/src/LogCache.cc
+++ b/livestatus/src/LogCache.cc
@@ -91,43 +91,35 @@ void LogCache::addToIndex(std::unique_ptr<Logfile> logfile) {
_logfiles.emplace(since, std::move(logfile));
}
-/* This method is called each time a log message is loaded
- into memory. If the number of messages loaded in memory
- is to large, memory will be freed by flushing logfiles
- and message not needed by the current query.
-
- The parameters to this method reflect the current query,
- not the messages that just has been loaded.
- */
+// This method is called each time a log message is loaded into memory. If the
+// number of messages loaded in memory is too large, memory will be freed by
+// flushing logfiles and message not needed by the current query.
+//
+// The parameters to this method reflect the current query, not the messages
+// that have just been loaded.
void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
if (++_num_cached_log_messages <= _mc->maxCachedMessages()) {
return; // current message count still allowed, everything ok
}
- /* Memory checking an freeing consumes CPU resources. We save
- resources, by avoiding to make the memory check each time
- a new message is loaded when being in a sitation where no
- memory can be freed. We do this by suppressing the check when
- the number of messages loaded into memory has not grown
- by at least check_mem_cycle messages */
+ // Memory checking and freeing consumes CPU resources. We save resources by
+ // avoiding the memory check each time a new message is loaded when being in
+ // a sitation where no memory can be freed. We do this by suppressing the
+ // check when the number of messages loaded into memory has not grown by at
+ // least check_mem_cycle messages.
if (_num_cached_log_messages < _num_at_last_check + check_mem_cycle) {
return; // Do not check this time
}
- // [1] Begin by deleting old logfiles
- // Begin deleting with the oldest logfile available
+ // [1] Delete old logfiles: Begin deleting with the oldest logfile available
logfiles_t::iterator it;
for (it = _logfiles.begin(); it != _logfiles.end(); ++it) {
if (it->second.get() == logfile) {
- // Do not touch the logfile the Query is currently accessing
- break;
+ break; // Do not touch the logfile the Query is currently accessing
}
if (it->second->size() > 0) {
_num_cached_log_messages -= it->second->freeMessages(~0);
if (_num_cached_log_messages <= _mc->maxCachedMessages()) {
- // remember the number of log messages in cache when
- // the last memory-release was done. No further
- // release-check shall be done until that number changes.
_num_at_last_check = _num_cached_log_messages;
return;
}
@@ -138,15 +130,14 @@ void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
// We save that pointer for later.
auto queryit = it;
- // [2] Delete message classes irrelevent to current query
- // Starting from the current logfile (wo broke out of the
- // previous loop just when 'it' pointed to that)
+ // [2] Delete message classes irrelevent to current query: Starting from the
+ // current logfile (we broke out of the previous loop just when 'it' pointed
+ // to that)
for (; it != _logfiles.end(); ++it) {
if (it->second->size() > 0 &&
(it->second->classesRead() & ~logclasses) != 0) {
Debug(logger()) << "freeing classes " << ~logclasses << " of file "
<< it->second->path();
- // flush only messages not needed for current query
_num_cached_log_messages -= it->second->freeMessages(~logclasses);
if (_num_cached_log_messages <= _mc->maxCachedMessages()) {
_num_at_last_check = _num_cached_log_messages;
@@ -155,10 +146,9 @@ void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
}
}
- // [3] Flush newest logfiles
- // If there are still too many messages loaded, continue
- // flushing logfiles from the oldest to the newest starting
- // at the file just after (i.e. newer than) the current logfile
+ // [3] Flush newest logfiles: If there are still too many messages loaded,
+ // continue flushing logfiles from the oldest to the newest starting at the
+ // file just after (i.e. newer than) the current logfile
for (it = ++queryit; it != _logfiles.end(); ++it) {
if (it->second->size() > 0) {
Debug(logger()) << "flush newer log, " << it->second->size()
@@ -170,11 +160,9 @@ void LogCache::logLineHasBeenAdded(Logfile *logfile, unsigned logclasses) {
}
}
}
+ // If we reach this point, no more logfiles can be unloaded, despite the
+ // fact that there are still too many messages loaded.
_num_at_last_check = _num_cached_log_messages;
- // If we reach this point, no more logfiles can be unloaded,
- // despite the fact that there are still too many messages
- // loaded.
-
Debug(logger()) << "cannot unload more messages, still "
<< _num_cached_log_messages << " loaded (max is "
<< _mc->maxCachedMessages() << ")";
Module: check_mk
Branch: master
Commit: 22f1bc277e5343b87e002e97f80c50e32a8678fb
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=22f1bc277e5343…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Feb 27 08:20:55 2019 +0100
Decouple LogEntry from MonitoringCore, part 1.
We shift the lookup of hosts, services, etc. to the moment when they are
actually needed. This commit does it for TableLog, more to come...
CMK-1753
Change-Id: Ifcbeadd00365860363009493e83661e8cdb4cdd0
---
livestatus/src/LogEntry.cc | 13 +-----
livestatus/src/LogEntry.h | 6 +--
livestatus/src/TableLog.cc | 104 +++++++++++++++++++++++++++------------------
livestatus/src/TableLog.h | 4 +-
4 files changed, 68 insertions(+), 59 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=22f1bc277e…