Module: check_mk
Branch: master
Commit: e12998227bb59a948787a4485d42f4d8612db107
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e12998227bb59a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 3 14:20:42 2016 +0100
BI communicates via livestatus with the sites to first gather a list of
all hosts in all sites. Once this has been done BI knows which host
status can be found on which site.
But this info was not used when fetching the states of the hosts. The
host state queries were always sent to all sites causing a lot of needless
livestatus queries.
This should improve the performance of the BI views when having a higher
number of sites or some sites which have a bad connection.
---
.werks/3232 | 19 +++++++++++++++++++
ChangeLog | 1 +
web/htdocs/bi.py | 5 ++++-
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/.werks/3232 b/.werks/3232
new file mode 100644
index 0000000..b74516c
--- /dev/null
+++ b/.werks/3232
@@ -0,0 +1,19 @@
+Title: BI: Only querying site of host for specific host status info
+Level: 2
+Component: bi
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457010960
+
+BI communicates via livestatus with the sites to first gather a list of
+all hosts in all sites. Once this has been done BI knows which host
+status can be found on which site.
+
+But this info was not used when fetching the states of the hosts. The
+host state queries were always sent to all sites causing a lot of needless
+livestatus queries.
+
+This should improve the performance of the BI views when having a higher
+number of sites or some sites which have a bad connection.
diff --git a/ChangeLog b/ChangeLog
index 859415b..559aadc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -91,6 +91,7 @@
BI:
* 3247 FIX: Do not allow multiple BI aggregates with the same title...
+ * 3232 FIX: BI: Only querying site of host for specific host status info...
Reporting & Availability:
* 3249 FIX: Fix missing filter for non-OK services when report is called via context button
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 07bc9c3..29c7f02 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1219,11 +1219,14 @@ def get_status_info(required_hosts):
if len(hosts) > 1:
filter += "Or: %d\n" % len(hosts)
sites.live().set_auth_domain('bi')
+ sites.live().set_only_sites([site])
data = sites.live().query(
"GET hosts\n"
- "Columns: name state hard_state plugin_output scheduled_downtime_depth acknowledged in_service_period services_with_fullstate\n"
+ "Columns: name state hard_state plugin_output scheduled_downtime_depth "
+ "acknowledged in_service_period services_with_fullstate\n"
+ filter)
sites.live().set_auth_domain('read')
+ sites.live().set_only_sites(None)
tuples += [((site, e[0]), e[1:]) for e in data]
return dict(tuples)
Module: check_mk
Branch: master
Commit: 31d13fc196c7a440d3a7e4751dd10ce093fbdb6a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=31d13fc196c7a4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 3 10:51:30 2016 +0100
Updated bug entries #2426
---
.bugs/2426 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.bugs/2426 b/.bugs/2426
index a1bae94..755e57e 100644
--- a/.bugs/2426
+++ b/.bugs/2426
@@ -9,3 +9,5 @@ If you setup Interfacemmonitoring (SNMP) in a way that an UP port
will be warned then sometimes the check will not detect this and
stay OK - even in the port UP. Might or might not be due to
counter wraps.
+
+If you restart the OMD site then the problem is gone.
Module: check_mk
Branch: master
Commit: c142ca48c45583709af706ac62c9697250b1f339
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c142ca48c45583…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 3 10:47:20 2016 +0100
Fixed issue with modules not being loaded correctly in some situations
Seems that it is possible that the index module is re-initialized by
mod_python. This leads to a second call of index.initialize() which
will then reinitialize the multisite modules managed by "modules"
which could lead to no modules being registered.
---
web/htdocs/modules.py | 28 +++++++++++++++++++++++-----
web/htdocs/views.py | 1 +
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/modules.py b/web/htdocs/modules.py
index 572e492..1b8e064 100644
--- a/web/htdocs/modules.py
+++ b/web/htdocs/modules.py
@@ -24,6 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+import os
from types import ModuleType
from lib import load_web_plugins, local_web_plugins_have_changed
from mod_python.apache import import_module
@@ -44,13 +45,26 @@ pagehandlers = {}
# initialize them.
modules = []
+
# Returns a list of names of all currently imported python modules
def imports():
for name, val in globals().items():
if isinstance(val, ModuleType):
- # val.__name__ would be better, but this is not available in mod_python
- name = val.__file__.split("/")[-1][:-3]
- yield name
+ yield get_module_name(val)
+
+
+def cleanup_already_imported_modules():
+ g = globals()
+ for module in modules:
+ try:
+ del g[get_module_name(module)]
+ except KeyError:
+ pass # not loaded, it's ok
+
+
+# module name can not be get from __name__ in mod_python. use the file path to detect it.
+def get_module_name(module):
+ return os.path.splitext(os.path.basename(module.__file__))[0]
# Loads all modules needed into memory and performs global initializations for
@@ -58,8 +72,12 @@ def imports():
# If you need more time cosuming initializations, they should be done in
# the late_init_modules() function.
def init_modules():
- global modules ; modules = []
- global pagehandlers ; pagehandlers = {}
+ global modules, pagehandlers
+
+ cleanup_already_imported_modules()
+
+ modules = []
+ pagehandlers = {}
module_names_prev = set(imports())
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index d45df63..fe9b553 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -27,6 +27,7 @@
import config, defaults, time, os, re, pprint
import weblib, traceback, forms, valuespec, inventory, visuals, metrics
import sites
+import bi
from lib import *
# Datastructures and functions needed before plugins can be loaded
Module: check_mk
Branch: master
Commit: 201c1248a7a9ca9a175ec340e5418d4691a22d7c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=201c1248a7a9ca…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 3 10:45:08 2016 +0100
#3263 Notifications: allow users to restrict by their contact groups
In notification rules in the {{Contact Selection}} you can now restrict
users by their membership in contact groups. Note: this is not the same
as the <b>Selection</b> by contact groups - which already existed. This
feature is used to later reduce that selected contacts.
---
.werks/3263 | 13 +++++++++++++
ChangeLog | 1 +
modules/notify.py | 51 ++++++++++++++++++++++++++++++++++++++-------------
web/htdocs/wato.py | 18 ++++++++++++++++--
4 files changed, 68 insertions(+), 15 deletions(-)
diff --git a/.werks/3263 b/.werks/3263
new file mode 100644
index 0000000..c0d012b
--- /dev/null
+++ b/.werks/3263
@@ -0,0 +1,13 @@
+Title: Notifications: allow users to restrict by their contact groups
+Level: 1
+Component: notifications
+Class: feature
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1456998194
+
+In notification rules in the {{Contact Selection}} you can now restrict
+users by their membership in contact groups. Note: this is not the same
+as the <b>Selection</b> by contact groups - which already existed. This
+feature is used to later reduce that selected contacts.
diff --git a/ChangeLog b/ChangeLog
index 867e5bd..f6c36ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -85,6 +85,7 @@
* 3000 FIX: Host check command: "Use a custom check plugin" was not working with CMC...
Notifications:
+ * 3263 Notifications: allow users to restrict by their contact groups...
* 3253 FIX: sms: notification script sms now handles single quotes in the message in the right way
BI:
diff --git a/modules/notify.py b/modules/notify.py
index 995423c..663b720 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -683,23 +683,48 @@ def rbn_rule_contacts(rule, context):
notify_log(" - skipping contact %s: he/she has disabled notifications" % contactname)
continue
- if "contact_match_macros" in rule:
- match = True
- for macro_name, regexp in rule["contact_match_macros"]:
- value = contact.get("_" + macro_name, "")
- if not regexp.endswith("$"):
- regexp = regexp + "$"
- if not regex(regexp).match(value):
- notify_log(" - skipping contact %s: value '%s' for macro '%s' does not match '%s'" % (
- contactname, value, macro_name, regexp))
- match = False
- break
- if not match:
- continue
+ reason = rbn_match_contact_macros(rule, contactname, contact) or \
+ rbn_match_contact_groups(rule, contactname, contact)
+
+ if reason:
+ notify_log(" - skipping contact %s: %s" % (contactname, reason))
+ continue
+
+ else:
+ notify_log("Warning: cannot get information about contact %s: ignoring restrictions" % contactname)
+
all_enabled.append(contactname)
return all_enabled
+
+def rbn_match_contact_macros(rule, contactname, contact):
+ if "contact_match_macros" in rule:
+ for macro_name, regexp in rule["contact_match_macros"]:
+ value = contact.get("_" + macro_name, "")
+ if not regexp.endswith("$"):
+ regexp = regexp + "$"
+ if not regex(regexp).match(value):
+ macro_overview = ", ".join([
+ "%s=%s" % (varname[1:], val)
+ for (varname, val)
+ in contact.items()
+ if varname.startswith("_")])
+ return "value '%s' for macro '%s' does not match '%s'. His macros are: %s" % (
+ value, macro_name, regexp, macro_overview)
+
+
+def rbn_match_contact_groups(rule, contactname, contact):
+ if "contact_match_groups" in rule:
+ if "contactgroups" not in contact:
+ notify_log("Warning: cannot determine contact groups of %s: skipping restrictions" % contactname)
+ return
+ for required_group in rule["contact_match_groups"]:
+ if required_group not in contact["contactgroups"]:
+ return "he/she is not member of the contact group %s (his groups are %s)" % (
+ required_group, ", ".join(contact["contactgroups"] or ["<None>"]))
+
+
def rbn_match_notification_comment(rule, context):
if "match_notification_comment" in rule:
r = regex(rule["match_notification_comment"])
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index e3b3e9a..4117126 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -6907,7 +6907,8 @@ def vs_notification_rule(userid = None):
else:
contact_headers = [
( _("Contact Selection"), [ "contact_all", "contact_all_with_email", "contact_object",
- "contact_users", "contact_groups", "contact_emails", "contact_match_macros" ] ),
+ "contact_users", "contact_groups", "contact_emails", "contact_match_macros",
+ "contact_match_groups", ] ),
]
section_contacts = [
# Contact selection
@@ -6979,6 +6980,18 @@ def vs_notification_rule(userid = None):
add_label = _("Add condition"),
)
),
+ ( "contact_match_groups",
+ ListOf(
+ GroupSelection("contact"),
+ title = _("Restrict by contact groups"),
+ help = _("Here you can <i>restrict</i> the list of contacts that has been "
+ "built up by the previous options to those that are members of "
+ "selected contact groups. If you select more than one contact group here then "
+ "the user must be member of <i>all</i> these groups."),
+ add_label = _("Add Group"),
+ movable = False,
+ )
+ ),
]
section_override = [
( "allow_disable",
@@ -7082,7 +7095,8 @@ def vs_notification_rule(userid = None):
"match_plugin_output",
"match_timeperiod", "match_escalation", "match_escalation_throttle",
"match_sl", "match_host_event", "match_service_event", "match_ec", "match_notification_comment",
- "match_checktype", "bulk", "contact_users", "contact_groups", "contact_emails", "contact_match_macros" ],
+ "match_checktype", "bulk", "contact_users", "contact_groups", "contact_emails",
+ "contact_match_macros", "contact_match_groups" ],
headers = [
( _("General Properties"), [ "description", "comment", "disabled", "docu_url", "allow_disable" ] ),
( _("Notification Method"), [ "notify_plugin", "notify_method", "bulk" ] ),]
Module: check_mk
Branch: master
Commit: d130d3773ee5faf460de7318c2db6151708eae32
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d130d3773ee5fa…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 3 10:40:44 2016 +0100
Updated bug entries #2427
---
.bugs/2427 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/.bugs/2427 b/.bugs/2427
new file mode 100644
index 0000000..43b41b5
--- /dev/null
+++ b/.bugs/2427
@@ -0,0 +1,12 @@
+Title: Converting existing custom user macro to "Make avaible in notifications" needs load/save
+Component: wato
+State: open
+Date: 2016-03-03 10:38:16
+Targetversion: 1.2.8
+Class: bug
+
+If you create a new custom user macro and assign a value for a user to it.
+Then later you convert this macro to "Add as custom macro: [X] Make this
+variable available in notifications" then you need to save the user profile
+once again in order to make this effective. I assume that it is sufficiant
+to save any one user to correctly save all macros.
Module: check_mk
Branch: master
Commit: a16a46ad23bc57fb2584861162822be9ef68e70e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a16a46ad23bc57…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 3 08:57:17 2016 +0100
#3230 FIX Slightly improved popup menu positioning when hitting right+left or bottom+top border of screen/dashlet
---
.werks/3230 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/js/checkmk.js | 27 +++++++++++++++++++++------
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/.werks/3230 b/.werks/3230
new file mode 100644
index 0000000..5de8c06
--- /dev/null
+++ b/.werks/3230
@@ -0,0 +1,10 @@
+Title: Slightly improved popup menu positioning when hitting right+left or bottom+top border of screen/dashlet
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1456991805
+
+
diff --git a/ChangeLog b/ChangeLog
index 47a09e7..f772c50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,6 +65,7 @@
* 3181 FIX: Omit icon for downloading agent output on shadow hosts (cmcdump)...
* 3248 FIX: Avoid broken list of context filters and case of a BI error
* 3251 FIX: Fix sorting of entries in Views sidebar element
+ * 3230 FIX: Slightly improved popup menu positioning when hitting right+left or bottom+top border of screen/dashlet
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node selection...
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index ae2ac9f..7e301ce 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -2623,17 +2623,32 @@ function fix_popup_menu_position(event, menu) {
// Check whether or not the menu is out of the bottom border
// -> if so, move the menu up
if (rect.bottom > (window.innerHeight || document.documentElement.clientHeight)) {
- menu.style.top = 'auto';
- menu.style.bottom = '15px';
+ var height = rect.bottom - rect.top;
+ if (rect.top - height < 0) {
+ // would hit the top border too, then put the menu to the top border
+ // and hope that it fits within the screen
+ menu.style.top = '-' + (rect.top - 15) + 'px';
+ menu.style.bottom = 'auto';
+ } else {
+ menu.style.top = 'auto';
+ menu.style.bottom = '15px';
+ }
}
// Check whether or not the menu is out of right border and
// a move to the left would fix the issue
// -> if so, move the menu to the left
- if (rect.right > (window.innerWidth || document.documentElement.clientWidth)
- && rect.left - (rect.right - rect.left) >= 0) {
- menu.style.left = 'auto';
- menu.style.right = '15px';
+ if (rect.right > (window.innerWidth || document.documentElement.clientWidth)) {
+ var width = rect.right - rect.left;
+ if (rect.left - width < 0) {
+ // would hit the left border too, then put the menu to the left border
+ // and hope that it fits within the screen
+ menu.style.left = '-' + (rect.left - 15) + 'px';
+ menu.style.right = 'auto';
+ } else {
+ menu.style.left = 'auto';
+ menu.style.right = '15px';
+ }
}
}