Module: check_mk
Branch: master
Commit: fba32a19cc93866817b606d8a11d5095a176141e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fba32a19cc9386…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 25 14:26:29 2016 +0200
3436 Views/Dashobards: Can now be published to members of contact groups
In previous versions you could publish your views or dashboards to all or no user.
With this change, you can now create views or dashboards and publish them to a
the members of specific contact groups only.
---
.werks/3436 | 11 +++++++++++
ChangeLog | 1 +
2 files changed, 12 insertions(+)
diff --git a/.werks/3436 b/.werks/3436
new file mode 100644
index 0000000..95e4481
--- /dev/null
+++ b/.werks/3436
@@ -0,0 +1,11 @@
+Title: Views/Dashobards: Can now be published to members of contact groups
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.9i1
+Date: 1461586384
+Class: feature
+
+In previous versions you could publish your views or dashboards to all or no user.
+With this change, you can now create views or dashboards and publish them to a
+the members of specific contact groups only.
diff --git a/ChangeLog b/ChangeLog
index 58cd951..2345416 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -195,6 +195,7 @@
* 3376 Cleaned up handling of setting Livestatus AuthUser for "see all" users...
NOTE: Please refer to the migration notes!
* 3397 Show IP addresses of a host when hovering over its name...
+ * 3436 Views/Dashobards: Can now be published to members of contact groups...
* 3059 FIX: Fixed highlighting of availability timeline time slices
* 3175 FIX: Fix timeranges of graphs that are embedded in a dashboard...
* 3076 FIX: fixed broken views in check_mk raw edition
Module: check_mk
Branch: master
Commit: 07250cc7a9f02477a53b09b561d45600fe702186
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=07250cc7a9f024…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 25 13:14:24 2016 +0200
Views/Dashboards: Can now be published to members of specific contact groups
---
web/htdocs/userdb.py | 20 ++++++++++++++++++++
web/htdocs/views.py | 4 ++--
web/htdocs/visuals.py | 49 ++++++++++++++++++++++++++++++++++++-------------
web/htdocs/wato.py | 17 +++--------------
4 files changed, 61 insertions(+), 29 deletions(-)
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 61123ba..5b2240e 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -707,6 +707,7 @@ def load_roles():
# | \____|_| \___/ \__,_| .__/|___/ |
# | |_| |
# +----------------------------------------------------------------------+
+# TODO: Contact groups are fine here, but service / host groups?
def load_group_information():
try:
@@ -754,6 +755,25 @@ def load_group_information():
'Initializing structure...' % (filename, e))
return {}
+
+class GroupChoice(DualListChoice):
+ def __init__(self, what, **kwargs):
+ DualListChoice.__init__(self, **kwargs)
+ self.what = what
+ self._choices = lambda: self.load_groups()
+
+ def load_groups(self):
+ all_groups = load_group_information()
+ this_group = all_groups.get(self.what, {})
+ return [ (k, t['alias'] and t['alias'] or k) for (k, t) in this_group.items() ]
+
+
+# TODO: This is not performing good with a large user base. Hope it works for our needs.
+# Maybe we need to change it to livestatus or change our data structures somehow in the future.
+def groups_of_user(user_id):
+ users = load_users(lock=False)
+ return users[user_id]["contactgroups"]
+
#.
# .-Custom-Attrs.--------------------------------------------------------.
# | ____ _ _ _ _ |
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 71de7d2..b87767e 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -725,10 +725,10 @@ def transform_view_to_valuespec_value(view):
if view.get(key):
view['view']['options'].append(key)
- view['visibility'] = []
+ view['visibility'] = {}
for key in [ 'hidden', 'hidebutton', 'public' ]:
if view.get(key):
- view['visibility'].append(key)
+ view['visibility'][key] = view[key]
view['grouping'] = { "grouping" : view.get('group_painters', []) }
view['sorting'] = { "sorters" : view.get('sorters', {}) }
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 13e07b5..4a2cd0b 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -212,6 +212,17 @@ def available(what, all_visuals):
visuals = {}
permprefix = what[:-1]
+ def published_to_user(visual):
+ if visual["public"] == True:
+ return True
+
+ if type(visual["public"]) == tuple and visual["public"][0] == "contact_groups":
+ user_groups = set(userdb.groups_of_user(user))
+ if user_groups.intersection(visual["public"][1]):
+ return True
+
+ return False
+
# 1. user's own visuals, if allowed to edit visuals
if config.may("general.edit_" + what):
for (u, n), visual in all_visuals.items():
@@ -220,7 +231,7 @@ def available(what, all_visuals):
# 2. visuals of special users allowed to globally override builtin visuals
for (u, n), visual in all_visuals.items():
- if n not in visuals and visual["public"] and config.user_may(u, "general.force_" + what):
+ if n not in visuals and published_to_user(visual) and config.user_may(u, "general.force_" + what):
# Honor original permissions for the current user
permname = "%s.%s" % (permprefix, n)
if config.permission_exists(permname) \
@@ -238,7 +249,7 @@ def available(what, all_visuals):
# necessary.
if config.may("general.see_user_" + what):
for (u, n), visual in all_visuals.items():
- if n not in visuals and visual["public"] and config.user_may(u, "general.publish_" + what):
+ if n not in visuals and published_to_user(visual) and config.user_may(u, "general.publish_" + what):
# Is there a builtin visual with the same name? If yes, honor permissions.
permname = "%s.%s" % (permprefix, n)
if config.permission_exists(permname) \
@@ -635,13 +646,25 @@ def page_edit_visual(what, all_visuals, custom_field_handler = None,
# A few checkboxes concerning the visibility of the visual. These will
# appear as boolean-keys directly in the visual dict, but encapsulated
# in a list choice in the value spec.
- visibility_choices = [
- ('hidden', _('Hide this %s from the sidebar') % visual_type["title"]),
- ('hidebutton', _('Do not show a context button to this %s') % visual_type["title"]),
+ visibility_elements = [
+ ('hidden', FixedValue(None,
+ title = _('Hide this %s from the sidebar') % visual_type["title"],
+ )),
+ ('hidebutton', FixedValue(None,
+ title = _('Do not show a context button to this %s') % visual_type["title"],
+ )),
]
if config.may("general.publish_" + what):
- visibility_choices.append(
- ('public', _('Make this %s available for all users') % visual_type["title"]))
+ visibility_elements.append(('public', CascadingDropdown(
+ choices = [
+ (True, _("Publish to all users")),
+ ("contact_groups", _("Publish to members of contact groups"), userdb.GroupChoice(
+ "contact",
+ title = _("Publish to members of contact groups"),
+ )),
+ ],
+ title = _('Make this %s available for other users') % visual_type["title"]
+ )))
vs_general = Dictionary(
title = _("General Properties"),
@@ -677,9 +700,9 @@ def page_edit_visual(what, all_visuals, custom_field_handler = None,
('icon', IconSelector(
title = _('Button Icon'),
)),
- ('visibility', ListChoice(
+ ('visibility', Dictionary(
title = _('Visibility'),
- choices = visibility_choices,
+ elements = visibility_elements,
)),
],
)
@@ -712,8 +735,8 @@ def page_edit_visual(what, all_visuals, custom_field_handler = None,
visual[key] = general_properties[key]
# ...and import the visibility flags directly into the visual
- for key, title in visibility_choices:
- visual[key] = key in general_properties['visibility']
+ for key in dict(visibility_elements).keys():
+ visual[key] = general_properties['visibility'].get(key, False)
if not config.may("general.publish_" + what):
visual['public'] = False
@@ -763,8 +786,8 @@ def page_edit_visual(what, all_visuals, custom_field_handler = None,
# FIXME: Hier werden die Flags aus visibility nicht korrekt geladen. Wäre es nicht besser,
# diese in einem Unter-Dict zu lassen, anstatt diese extra umzukopieren?
- visib = []
- for key, title in visibility_choices:
+ visib = {}
+ for key, vs in visibility_elements:
if visual.get(key):
visib.append(key)
visual["visibility"] = visib
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 187a677..a92b6e8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -6911,17 +6911,6 @@ def FolderChoice(**kwargs):
return DropdownChoice(**kwargs)
-class GroupChoice(DualListChoice):
- def __init__(self, what, **kwargs):
- DualListChoice.__init__(self, **kwargs)
- self.what = what
- self._choices = lambda: self.load_groups()
-
- def load_groups(self):
- all_groups = userdb.load_group_information()
- this_group = all_groups.get(self.what, {})
- return [ (k, t['alias'] and t['alias'] or k) for (k, t) in this_group.items() ]
-
def vs_notification_bulkby():
return ListChoice(
title = _("Create separate notification bulks based on"),
@@ -7182,7 +7171,7 @@ def simple_host_rule_match_conditions():
title = _("Match Host Tags"))
),
( "match_hostgroups",
- GroupChoice("host",
+ userdb.GroupChoice("host",
title = _("Match Host Groups"),
help = _("The host must be in one of the selected host groups"),
allow_empty = False,
@@ -7210,7 +7199,7 @@ def simple_host_rule_match_conditions():
def generic_rule_match_conditions():
return simple_host_rule_match_conditions() + [
( "match_servicegroups",
- GroupChoice("service",
+ userdb.GroupChoice("service",
title = _("Match Service Groups"),
help = _("The service must be in one of the selected service groups. For host events this condition "
"never matches as soon as at least one group is selected."),
@@ -7261,7 +7250,7 @@ def generic_rule_match_conditions():
)
),
( "match_contactgroups",
- GroupChoice("contact",
+ userdb.GroupChoice("contact",
title = _("Match Contact Groups"),
help = _("The host/service must be in one of the selected contact groups. This only works with Check_MK Micro Core. " \
"If you don't use the CMC that filter will not apply"),
Module: check_mk
Branch: master
Commit: ff7c2dc8bb9b8fcfa5378a8750ff773d93290ed1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ff7c2dc8bb9b8f…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Apr 25 14:16:30 2016 +0200
3523 FIX esx_vsphere_hostsystem: fixed exception when no multipath state info is available
---
.werks/3523 | 9 +++++++++
ChangeLog | 2 +-
checks/esx_vsphere_hostsystem | 7 +++++--
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/.werks/3523 b/.werks/3523
new file mode 100644
index 0000000..6a65280
--- /dev/null
+++ b/.werks/3523
@@ -0,0 +1,9 @@
+Title: esx_vsphere_hostsystem: fixed exception when no multipath state info is available
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1461586573
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 04c6189..568f2bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -181,7 +181,7 @@
* 3421 FIX: cisco_asa_failover: Do not discover interfaces where failover is not enabled...
* 3422 FIX: printer_pages, canon_pages: Detect pages on Canon 8350 with generic check...
* 3463 FIX: ups_modulys_alarms: avoid crash on some SOCOMEC UPS where some alarm OIDs are empty
- * 3464 FIX: netstat.linux: fix monitoring of UDP listeners...
+ * 3523 FIX: esx_vsphere_hostsystem: fixed exception when no multipath state info is available
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/esx_vsphere_hostsystem b/checks/esx_vsphere_hostsystem
index 284f443..11fbf4a 100644
--- a/checks/esx_vsphere_hostsystem
+++ b/checks/esx_vsphere_hostsystem
@@ -373,9 +373,12 @@ check_info['esx_vsphere_hostsystem.maintenance'] = {
def esx_vsphere_multipath_convert(info):
data = esx_vsphere_hostsystem_convert(info)
- data = data['config.multipathState.path']
- data = zip(data[::2], data[1::2])
paths = {}
+ data = data.get('config.multipathState.path')
+ if not data:
+ return paths
+
+ data = zip(data[::2], data[1::2])
for path, state in data:
# ESX 6.0 uses a different format, e.g "vmhba32:C0:T0:L0 active"
if len(path.split(":")) == 4:
Module: check_mk
Branch: master
Commit: 82dc30b4c9df9d61c3c06feba4d7489c78497651
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=82dc30b4c9df9d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 22 16:56:40 2016 +0200
Fixed some pylint validation errors
---
modules/automation.py | 6 ++++++
modules/check_mk.py | 4 ++--
pylint/pylintrc.checks | 13 +++++++++----
pylint/pylintrc.modules | 13 +++++++++----
4 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/modules/automation.py b/modules/automation.py
index 13deccd..8be74cd 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -237,6 +237,7 @@ def automation_set_autochecks(args):
new_items = eval(sys.stdin.read())
set_autochecks_of(hostname, new_items)
trigger_discovery_check(hostname)
+ return None
# if required, schedule an inventory check
@@ -417,6 +418,8 @@ def automation_delete_host(args):
import shutil
shutil.rmtree("%s/%s" % (logwatch_dir, hostname))
+ return None
+
def automation_restart(job = "restart"):
if check_plugins_have_changed():
@@ -1381,6 +1384,7 @@ def automation_create_or_edit_package(args, mode):
create_package(new_package_info)
else:
edit_package(package_name, new_package_info)
+ return None
def automation_install_package(args):
@@ -1405,6 +1409,7 @@ def automation_remove_or_release_package(args, mode):
remove_package(package)
else:
remove_package_info(package_name)
+ return None
def automation_remove_unpackaged_file(args):
@@ -1423,3 +1428,4 @@ def automation_remove_unpackaged_file(args):
if not os.path.isfile(abspath):
raise MKAutomationError("No such file")
os.remove(abspath)
+ return None
diff --git a/modules/check_mk.py b/modules/check_mk.py
index c82e356..11d51be 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -3276,11 +3276,11 @@ def create_core_config():
verify_non_deprecated_checkgroups()
if monitoring_core == "cmc":
- warnings = do_create_cmc_config(opt_cmc_relfilename)
+ do_create_cmc_config(opt_cmc_relfilename)
else:
load_module("nagios")
out = file(nagios_objects_file, "w")
- warnings = create_nagios_config(out)
+ create_nagios_config(out)
num_warnings = len(g_configuration_warnings)
if num_warnings > 10:
diff --git a/pylint/pylintrc.checks b/pylint/pylintrc.checks
index 1ce71b5..a4468df 100644
--- a/pylint/pylintrc.checks
+++ b/pylint/pylintrc.checks
@@ -9,10 +9,15 @@ errors-only=yes
# C0111 missing module docstring
# C0326 bad-whitespace
disable=C0111,C0326
-# Disable this because we often use multiple types for a single variable. Maybe we
-# can change this in future to make such linter checks work, but for the moment these
-# checks are useless with Check_MK.
-disable=unsubscriptable-object,unsupported-membership-test,unpacking-non-sequence
+# unsubscriptable-object
+# unsupported-membership-test
+# unpacking-non-sequence
+# Disable this because we often use multiple types for a single variable. Maybe we
+# can change this in future to make such linter checks work, but for the moment these
+# checks are useless with Check_MK.
+# unpacking-non-sequence
+# Not a problem for us
+disable=unsubscriptable-object,unsupported-membership-test,unpacking-non-sequence,assignment-from-none
[TYPECHECK]
# Can not check methods / attributes of the rrdtool C module. Skipping related errors
diff --git a/pylint/pylintrc.modules b/pylint/pylintrc.modules
index 089938b..40a030b 100644
--- a/pylint/pylintrc.modules
+++ b/pylint/pylintrc.modules
@@ -9,10 +9,15 @@ errors-only=yes
# C0111 missing module docstring
# C0326 bad-whitespace
disable=C0111,C0326
-# Disable this because we often use multiple types for a single variable. Maybe we
-# can change this in future to make such linter checks work, but for the moment these
-# checks are useless with Check_MK.
-disable=unsubscriptable-object,unsupported-membership-test,unpacking-non-sequence
+# unsubscriptable-object
+# unsupported-membership-test
+# unpacking-non-sequence
+# Disable this because we often use multiple types for a single variable. Maybe we
+# can change this in future to make such linter checks work, but for the moment these
+# checks are useless with Check_MK.
+# unpacking-non-sequence
+# Not a problem for us
+disable=unsubscriptable-object,unsupported-membership-test,unpacking-non-sequence,assignment-from-none
[TYPECHECK]
# Can not check methods / attributes of the rrdtool C module. Skipping related errors