lists.checkmk.com
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
List overview
Download
Checkmk git commits
January 2019
----- 2024 -----
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
checkmk-commits@lists.checkmk.com
15 participants
490 discussions
Start a n
N
ew thread
7025 Icons & actions visibility can now be controlled by user permissions
by Lars Michelsen
Module: check_mk Branch: master Commit: b9e7d24128f4a653a67fa7c698165c92750fb9de URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b9e7d24128f4a6…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Wed Jan 9 13:57:01 2019 +0100 7025 Icons & actions visibility can now be controlled by user permissions The visibility of the standard and custom icons & actions can now be controlled by user permissions. By default the users of all roles may see all icons & actions. Each icon can be hidden for a role by disabling the permission to see an icon. CMK-995 Change-Id: Ic0c24167b42a280e462ddb089d7c75055919cc13 --- .werks/7025 | 12 ++++++++++++ cmk/gui/permissions.py | 1 + cmk/gui/plugins/views/icons/__init__.py | 3 +++ cmk/gui/plugins/views/icons/utils.py | 28 ++++++++++++++++++++++++++- tests/unit/cmk/gui/test_gui_config.py | 34 +++++++++++++++++++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/.werks/7025 b/.werks/7025 new file mode 100644 index 0000000..7fd914e --- /dev/null +++ b/.werks/7025 @@ -0,0 +1,12 @@ +Title: Icons & actions visibility can now be controlled by user permissions +Level: 1 +Component: multisite +Compatible: compat +Edition: cre +Version: 1.6.0i1 +Date: 1547038453 +Class: feature + +The visibility of the standard and custom icons & actions can now be controlled +by user permissions. By default the users of all roles may see all icons & actions. +Each icon can be hidden for a role by disabling the permission to see an icon. diff --git a/cmk/gui/permissions.py b/cmk/gui/permissions.py index 0601438..1f7db41 100644 --- a/cmk/gui/permissions.py +++ b/cmk/gui/permissions.py @@ -164,6 +164,7 @@ def declare_permission_section(name, title, prio=50, do_sort=False): # Kept for compatibility with pre 1.6 GUI plugins +# Some dynamically registered permissions still use this def declare_permission(name, title, description, defaults): if isinstance(name, unicode): name = name.encode("utf-8") diff --git a/cmk/gui/plugins/views/icons/__init__.py b/cmk/gui/plugins/views/icons/__init__.py index 9f470bf..d2d1f86 100644 --- a/cmk/gui/plugins/views/icons/__init__.py +++ b/cmk/gui/plugins/views/icons/__init__.py @@ -105,6 +105,9 @@ def _process_icons(what, row, tags, custom_vars, toplevel, user_icon_ids): if icon.type() == "custom_icon" and icon_id not in user_icon_ids: continue + if not config.user.may("icons_and_actions.%s" % icon_id): + continue + try: for icon in _process_icon(what, row, tags, custom_vars, icon_id, icon): icons.append(icon) diff --git a/cmk/gui/plugins/views/icons/utils.py b/cmk/gui/plugins/views/icons/utils.py index 34b5f6e..764a0f8 100644 --- a/cmk/gui/plugins/views/icons/utils.py +++ b/cmk/gui/plugins/views/icons/utils.py @@ -28,7 +28,28 @@ import abc from typing import Union, Optional, Tuple # pylint: disable=unused-import import cmk.gui.config as config +from cmk.gui.i18n import _ import cmk.utils.plugin_registry +from cmk.gui.permissions import ( + permission_section_registry, + PermissionSection, + declare_permission, +) + + +(a)permission_section_registry.register +class PermissionSectionIconsAndActions(PermissionSection): + @property + def name(self): + return "icons_and_actions" + + @property + def title(self): + return _("Icons") + + @property + def do_sort(self): + return True class Icon(object): @@ -111,7 +132,12 @@ class IconRegistry(cmk.utils.plugin_registry.ClassRegistry): return Icon def _register(self, plugin_class): - self._entries[plugin_class.ident()] = plugin_class + ident = plugin_class.ident() + self._entries[ident] = plugin_class + + declare_permission("icons_and_actions.%s" % ident, ident, + _("Allow to see the icon %s in the host and service views") % ident, + config.builtin_role_ids) icon_and_action_registry = IconRegistry() diff --git a/tests/unit/cmk/gui/test_gui_config.py b/tests/unit/cmk/gui/test_gui_config.py index 4c560a6..121b0ab 100644 --- a/tests/unit/cmk/gui/test_gui_config.py +++ b/tests/unit/cmk/gui/test_gui_config.py @@ -38,6 +38,7 @@ def test_registered_permission_sections(): ('report', (50, u'Reports', True)), ('nagvis', (50, u'NagVis', False)), ('view', (50, u'Views', True)), + ('icons_and_actions', (50, u'Icons', True)), ] section_names = permission_section_registry.keys() @@ -162,6 +163,39 @@ def test_registered_permissions(): 'general.use', 'general.view_option_columns', 'general.view_option_refresh', + 'icons_and_actions.action_menu', + 'icons_and_actions.agent_deployment', + 'icons_and_actions.aggregation_checks', + 'icons_and_actions.aggregations', + 'icons_and_actions.check_manpage', + 'icons_and_actions.check_period', + 'icons_and_actions.crashed_check', + 'icons_and_actions.custom_action', + 'icons_and_actions.deployment_status', + 'icons_and_actions.download_agent_output', + 'icons_and_actions.download_snmp_walk', + 'icons_and_actions.icon_image', + 'icons_and_actions.inventory', + 'icons_and_actions.logwatch', + 'icons_and_actions.mkeventd', + 'icons_and_actions.notes', + 'icons_and_actions.perfgraph', + 'icons_and_actions.prediction', + 'icons_and_actions.reschedule', + 'icons_and_actions.rule_editor', + 'icons_and_actions.stars', + 'icons_and_actions.status_acknowledged', + 'icons_and_actions.status_active_checks', + 'icons_and_actions.status_comments', + 'icons_and_actions.status_downtimes', + 'icons_and_actions.status_flapping', + 'icons_and_actions.status_notification_period', + 'icons_and_actions.status_notifications_enabled', + 'icons_and_actions.status_passive_checks', + 'icons_and_actions.status_service_period', + 'icons_and_actions.status_shadow', + 'icons_and_actions.status_stale', + 'icons_and_actions.wato', 'mkeventd.actions', 'mkeventd.activate', 'mkeventd.archive_events_of_hosts',
5 years, 5 months
1
0
0
0
Register user configured icons and actions to the icon plugin registry
by Lars Michelsen
Module: check_mk Branch: master Commit: dff51534ff0dbe2564619c26311e8f77eb0ad485 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dff51534ff0dbe…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Wed Jan 9 12:27:22 2019 +0100 Register user configured icons and actions to the icon plugin registry CMK-1514 Change-Id: I7c023dfdc7e6e22f841956c76daf5e0cbf94cde4 --- cmk/gui/config.py | 17 ++++++++++++++ cmk/gui/plugins/views/icons/__init__.py | 41 ++++++--------------------------- cmk/gui/plugins/views/icons/utils.py | 38 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/cmk/gui/config.py b/cmk/gui/config.py index 54943b9..9d0df8d 100644 --- a/cmk/gui/config.py +++ b/cmk/gui/config.py @@ -28,6 +28,7 @@ import sys import errno import os import copy +from typing import Callable # pylint: disable=unused-import import cmk.gui.utils as utils import cmk.gui.i18n @@ -200,6 +201,21 @@ def load_config(): migrate_old_sample_config_tag_groups(wato_host_tags, wato_aux_tags) + execute_post_config_load_hooks() + + +def execute_post_config_load_hooks(): + for func in _post_config_load_hooks: + func() + + +_post_config_load_hooks = [] + + +def register_post_config_load_hook(func): + # type: (Callable) -> None + _post_config_load_hooks.append(func) + def _initialize_with_default_config(): vars_before_plugins = all_nonfunction_vars(globals()) @@ -764,6 +780,7 @@ class BuiltinTags(object): # a) Check whether or not the tag group has been modified. If not, simply remove it from the user # config and use the builtin tag group in the future. # b) Extend the tag group in the user configuration with the tag configuration we need for 1.5. +# TODO: Move to wato/watolib and register using register_post_config_load_hook() def migrate_old_sample_config_tag_groups(host_tags, aux_tags_): remove_old_sample_config_tag_groups(host_tags, aux_tags_) extend_user_modified_tag_groups(host_tags) diff --git a/cmk/gui/plugins/views/icons/__init__.py b/cmk/gui/plugins/views/icons/__init__.py index 84d58aa..9f470bf 100644 --- a/cmk/gui/plugins/views/icons/__init__.py +++ b/cmk/gui/plugins/views/icons/__init__.py @@ -62,17 +62,6 @@ def get_multisite_icons(): for icon_class in icon_and_action_registry.values(): icons[icon_class.ident()] = icon_class() - # Now apply the global settings customized options - for icon_id, cfg in config.builtin_icon_visibility.items(): - icon = icon_and_action_registry.get(icon_id) - if icon is None: - continue - - if 'toplevel' in cfg: - icon.override_toplevel(cfg['toplevel']) - if 'sort_index' in cfg: - icon.override_sort_index(cfg['sort_index']) - return icons @@ -94,7 +83,7 @@ def get_icons(what, row, toplevel): # Extract needed custom variables tags = host_custom_vars.get('TAGS', '').split() - user_action_ids = custom_vars.get('ACTIONS', '').split(',') + user_icon_ids = custom_vars.get('ACTIONS', '').split(',') # Icons is a list of triple or quintuplets with these elements: # (toplevel, sort_index, html_code) @@ -103,22 +92,21 @@ def get_icons(what, row, toplevel): # is written to HTML # -> or when an exception occured # (toplevel, sort_index, icon_name, title, url) - icons = _process_multisite_icons(what, row, tags, host_custom_vars, toplevel) - icons += _process_custom_user_icons_and_actions(user_action_ids, toplevel) + icons = _process_icons(what, row, tags, host_custom_vars, toplevel, user_icon_ids) return sorted(icons, key=lambda i: i[0]) -def _process_multisite_icons(what, row, tags, custom_vars, toplevel): +def _process_icons(what, row, tags, custom_vars, toplevel, user_icon_ids): icons = [] for icon_id, icon in get_multisite_icons().items(): - if icon.type() != 'icon': + if icon.toplevel() != toplevel: continue - if icon.toplevel() != toplevel: + if icon.type() == "custom_icon" and icon_id not in user_icon_ids: continue try: - for icon in _process_multisite_icon(what, row, tags, custom_vars, icon_id, icon): + for icon in _process_icon(what, row, tags, custom_vars, icon_id, icon): icons.append(icon) except Exception: icons.append((icon.sort_index(), @@ -126,7 +114,7 @@ def _process_multisite_icons(what, row, tags, custom_vars, toplevel): return icons -def _process_multisite_icon(what, row, tags, custom_vars, icon_id, icon): +def _process_icon(what, row, tags, custom_vars, icon_id, icon): # In old versions, the icons produced html code directly. The new API # is that the icon functions need to return: # a) None - nothing to be rendered @@ -176,21 +164,6 @@ def _process_multisite_icon(what, row, tags, custom_vars, icon_id, icon): yield icon.sort_index(), icon_name, title, url -def _process_custom_user_icons_and_actions(user_action_ids, toplevel): - icons = [] - for uid in user_action_ids: - try: - icon = config.user_icons_and_actions[uid] - except KeyError: - continue # Silently skip not existing icons - - if icon.get('toplevel', False) == toplevel: - sort_index = icon.get('sort_index', 15) - icons.append((sort_index, icon['icon'], icon.get('title'), icon.get('url'))) - - return icons - - # toplevel may be # True to get only columns for top level icons # False to get only columns for dropdown menu icons diff --git a/cmk/gui/plugins/views/icons/utils.py b/cmk/gui/plugins/views/icons/utils.py index 17f41ee..34b5f6e 100644 --- a/cmk/gui/plugins/views/icons/utils.py +++ b/cmk/gui/plugins/views/icons/utils.py @@ -27,6 +27,7 @@ import abc from typing import Union, Optional, Tuple # pylint: disable=unused-import +import cmk.gui.config as config import cmk.utils.plugin_registry @@ -114,3 +115,40 @@ class IconRegistry(cmk.utils.plugin_registry.ClassRegistry): icon_and_action_registry = IconRegistry() + + +def update_icons_from_configuration(): + _update_builtin_icons(config.builtin_icon_visibility) + _register_custom_user_icons_and_actions(config.user_icons_and_actions) + + +config.register_post_config_load_hook(update_icons_from_configuration) + + +def _update_builtin_icons(builtin_icon_visibility): + # Now apply the global settings customized options + for icon_id, cfg in builtin_icon_visibility.items(): + icon = icon_and_action_registry.get(icon_id) + if icon is None: + continue + + if 'toplevel' in cfg: + icon.override_toplevel(cfg['toplevel']) + if 'sort_index' in cfg: + icon.override_sort_index(cfg['sort_index']) + + +def _register_custom_user_icons_and_actions(user_icons_and_actions): + for icon_id, icon_cfg in user_icons_and_actions.items(): + icon_class = type( + "CustomIcon%s" % icon_id.title(), (Icon,), { + "_ident": icon_id, + "_icon_spec": icon_cfg, + "ident": classmethod(lambda cls: cls._ident), + "type": classmethod(lambda cls: "custom_icon"), + "sort_index": lambda self: self._icon_spec.get("sort_index", 15), + "toplevel": lambda self: self._icon_spec.get("toplevel", False), + "render": lambda self, *args: (self._icon_spec["icon"], self._icon_spec.get("title"), self._icon_spec.get("url")), + }) + + icon_and_action_registry.register_plugin(icon_class)
5 years, 5 months
1
0
0
0
cpu_util.include: fix missing minutes in check output
by Moritz Kiemer
Module: check_mk Branch: master Commit: b7ff69c1ab3feb25d7cbe49d148769a3679074fd URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b7ff69c1ab3feb…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Thu Jan 10 09:45:34 2019 +0100 cpu_util.include: fix missing minutes in check output Change-Id: I7d9b1482019bdf113518ece028d48240f50042bc --- checks/cpu_util.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks/cpu_util.include b/checks/cpu_util.include index 6b53583..641d8ad 100644 --- a/checks/cpu_util.include +++ b/checks/cpu_util.include @@ -83,7 +83,7 @@ def check_cpu_util(util, params, this_time=None, cores=None, perf_max=100): "util_average", levels, human_readable_func=get_percent_human_readable, - infoname="%dmin average") + infoname="%dmin average" % params["average"]) else: state, infotext, extraperf = check_levels( util,
5 years, 5 months
1
0
0
0
agent_aws: Use US East (N. Virgina) for Cost Explorer
by Simon Betz
Module: check_mk Branch: master Commit: 876921d98eedf7a7aadfb7f96d701707f5bf5d5f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=876921d98eedf7…
Author: Simon Betz <si(a)mathias-kettner.de> Date: Thu Jan 10 09:32:14 2019 +0100 agent_aws: Use US East (N. Virgina) for Cost Explorer Change-Id: I09fd2a4a48a7d8b2f64d34731ffbae326126e3d3 --- agents/special/agent_aws | 155 ++++++++++++++++++++++++++++------------------- checks/aws_exceptions | 2 +- 2 files changed, 94 insertions(+), 63 deletions(-) diff --git a/agents/special/agent_aws b/agents/special/agent_aws index 23e04df..b5eb18d 100755 --- a/agents/special/agent_aws +++ b/agents/special/agent_aws @@ -220,7 +220,7 @@ class CostsAndUsage(AWSSection): return self._client.get_cost_and_usage( TimePeriod={ 'Start': time.strftime(fmt, time.gmtime(now)), - 'End': time.strftime(fmt, time.gmtime(now + self.interval)), + 'End': time.strftime(fmt, time.gmtime(now + self.period)), }, Granularity='DAILY', Metrics=['UnblendedCost'], @@ -881,65 +881,19 @@ class CloudTrail(AWSSection): # '----------------------------------------------------------------------' -class AWSSections(object): - def __init__(self, session, hostname): +class AWSSectionsTmpl(object): + def __init__(self, hostname, access_key_id, secret_access_key, region): self._hostname = hostname - self._session = session + self._session = self._init_session(access_key_id, secret_access_key, region) self._sections = [] self._results = {} self._exceptions = [] - #---clients--------------------------------------------------------- - ce_client = self._init_client('ce') - ec2_client = self._init_client('ec2') - s3_client = self._init_client('s3') - elb_client = self._init_client('elb') - cloudtrail_client = self._init_client('cloudtrail') - glacier_client = self._init_client('glacier') - cloudwatch_client = self._init_client('cloudwatch') - - #---distributors---------------------------------------------------- - ec2_summary_distributor = ResultDistributor() - elb_summary_distributor = ResultDistributor() - ebs_summary_distributor = ResultDistributor() - - #---sections with distributors-------------------------------------- - ec2_summary = EC2Summary(ec2_client, ec2_summary_distributor) - elb_summary = ELBSummary(elb_client, elb_summary_distributor) - ebs_summary = EBSSummary(ec2_client, ebs_summary_distributor) - - #---sections-------------------------------------------------------- - s3 = S3(s3_client) - elb_health = ELBHealth(elb_client) - ce = CostsAndUsage(ce_client) - cloudtrail = CloudTrail(cloudtrail_client) - ec2 = EC2(cloudwatch_client) - elb = ELB(cloudwatch_client) - ebs = EBS(cloudwatch_client) - glacier = Glacier(glacier_client) - - #---register sections to distributors------------------------------- - ec2_summary_distributor.add(ec2) - ec2_summary_distributor.add(ebs_summary) - ec2_summary_distributor.add(ebs) - elb_summary_distributor.add(elb_health) - elb_summary_distributor.add(elb) - ebs_summary_distributor.add(ebs) - - #---register sections with distributors for execution--------------- - self._sections.append(ec2_summary) - self._sections.append(elb_summary) - self._sections.append(ebs_summary) - - #---register sections for execution--------------------------------- - self._sections.append(ce) - self._sections.append(ec2) - self._sections.append(s3) - self._sections.append(elb_health) - self._sections.append(elb) - self._sections.append(ebs) - self._sections.append(cloudtrail) - self._sections.append(glacier) + def _init_session(self, access_key_id, secret_access_key, region): + return boto3.session.Session( + aws_access_key_id=access_key_id, + aws_secret_access_key=secret_access_key, + region_name=region) def _init_client(self, client_key): try: @@ -1005,7 +959,7 @@ class AWSSections(object): out = "\n".join([e.message for e in self._exceptions]) else: out = "No exceptions" - sys.stdout.write("%s\n" % out) + sys.stdout.write("%s: %s\n" % (self.__class__.__name__, out)) def _write_section_results(self, now): if not self._results: @@ -1042,6 +996,80 @@ class AWSSections(object): sys.stdout.write("<<<<>>>>\n") +class AWSSectionsUSEast(AWSSectionsTmpl): + """ + Some clients like CostExplorer only work with US East region: +
https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/ce-api.html
+ """ + + def __init__(self, hostname, access_key_id, secret_access_key): + super(AWSSectionsUSEast, self).__init__(hostname, access_key_id, secret_access_key, + "us-east-1") + + #---clients--------------------------------------------------------- + ce_client = self._init_client('ce') + + #---sections-------------------------------------------------------- + ce = CostsAndUsage(ce_client) + + #---register sections for execution--------------------------------- + self._sections.append(ce) + + +class AWSSections(AWSSectionsTmpl): + def __init__(self, hostname, access_key_id, secret_access_key, region): + super(AWSSections, self).__init__(hostname, access_key_id, secret_access_key, region) + + #---clients--------------------------------------------------------- + ec2_client = self._init_client('ec2') + s3_client = self._init_client('s3') + elb_client = self._init_client('elb') + cloudtrail_client = self._init_client('cloudtrail') + glacier_client = self._init_client('glacier') + cloudwatch_client = self._init_client('cloudwatch') + + #---distributors---------------------------------------------------- + ec2_summary_distributor = ResultDistributor() + elb_summary_distributor = ResultDistributor() + ebs_summary_distributor = ResultDistributor() + + #---sections with distributors-------------------------------------- + ec2_summary = EC2Summary(ec2_client, ec2_summary_distributor) + elb_summary = ELBSummary(elb_client, elb_summary_distributor) + ebs_summary = EBSSummary(ec2_client, ebs_summary_distributor) + + #---sections-------------------------------------------------------- + s3 = S3(s3_client) + elb_health = ELBHealth(elb_client) + cloudtrail = CloudTrail(cloudtrail_client) + ec2 = EC2(cloudwatch_client) + elb = ELB(cloudwatch_client) + ebs = EBS(cloudwatch_client) + glacier = Glacier(glacier_client) + + #---register sections to distributors------------------------------- + ec2_summary_distributor.add(ec2) + ec2_summary_distributor.add(ebs_summary) + ec2_summary_distributor.add(ebs) + elb_summary_distributor.add(elb_health) + elb_summary_distributor.add(elb) + ebs_summary_distributor.add(ebs) + + #---register sections with distributors for execution--------------- + self._sections.append(ec2_summary) + self._sections.append(elb_summary) + self._sections.append(ebs_summary) + + #---register sections for execution--------------------------------- + self._sections.append(ec2) + self._sections.append(s3) + self._sections.append(elb_health) + self._sections.append(elb) + self._sections.append(ebs) + self._sections.append(cloudtrail) + self._sections.append(glacier) + + #. # .--main----------------------------------------------------------------. # | _ | @@ -1110,14 +1138,17 @@ def main(args=None): args = parse_arguments(args) setup_logging(args.debug) - s = boto3.session.Session( - aws_access_key_id=args.aws_access_key_id, - aws_secret_access_key=args.aws_secret_access_key, - region_name=args.region) + hostname = args.hostname + access_key_id = args.aws_access_key_id + secret_access_key = args.aws_secret_access_key + use_cache = not args.no_cache try: - aws_sections = AWSSections(s, args.hostname) - aws_sections.run(use_cache=not args.no_cache) + aws_sections_us_east = AWSSectionsUSEast(hostname, access_key_id, secret_access_key) + aws_sections_us_east.run(use_cache=use_cache) + + aws_sections = AWSSections(hostname, access_key_id, secret_access_key, args.region) + aws_sections.run(use_cache=use_cache) except Exception as e: if args.debug: raise diff --git a/checks/aws_exceptions b/checks/aws_exceptions index b2db9fb..80a4c8d 100644 --- a/checks/aws_exceptions +++ b/checks/aws_exceptions @@ -33,7 +33,7 @@ def inventory_aws_exceptions(info): def check_aws_exceptions(item, params, info): for line in info: joined_line = " ".join(line) - if joined_line == 'No exceptions': + if joined_line.endswith('No exceptions'): state = 0 else: state = 2
5 years, 5 months
1
0
0
0
cpu util wato params: unify wato rules
by Moritz Kiemer
Module: check_mk Branch: master Commit: f187ea54129a29f8d39e15afee90e9d3f40ee297 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f187ea54129a29…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Wed Jan 9 14:44:39 2019 +0100 cpu util wato params: unify wato rules * fuse options into one dict * update help text of dict * change titles of rules Change-Id: I6ae8c5fceec67c97fa8c17b45359464a9288bf03 --- .../wato/check_parameters/cpu_utilization.py | 213 +++++++++++---------- 1 file changed, 107 insertions(+), 106 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=f187ea5412…
5 years, 5 months
1
0
0
0
mk_logwatch.aix: double brackets apparently not always available
by Moritz Kiemer
Module: check_mk Branch: master Commit: 1dc2fac8ddc6421b121f3a293a918f7b40756530 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1dc2fac8ddc642…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Thu Jan 10 07:16:52 2019 +0100 mk_logwatch.aix: double brackets apparently not always available Change-Id: I9053cd69dc61c469fad2eef34e4b65a5ae516526 --- agents/plugins/mk_logwatch.aix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agents/plugins/mk_logwatch.aix b/agents/plugins/mk_logwatch.aix index ceb7ec0..0c7f970 100755 --- a/agents/plugins/mk_logwatch.aix +++ b/agents/plugins/mk_logwatch.aix @@ -19,13 +19,13 @@ echo "[[[errorlog]]]" # the last line we already reported (may be empty) LINE=$(tail -n1 "$MK_LOGWATCH_AIX_STATE" 2> /dev/null) -if [[ "$LINE" ]]; then # get rid of all lines after that: +if [ "$LINE" ]; then # get rid of all lines after that: OUT=$(errpt | awk '/'"$LINE"'/ {exit}; (NR>1) {printf "C %s\n", $0}') else # LINE is empty -> report all OUT=$(errpt | awk '(NR>1) {printf "C %s\n", $0}') fi -if [[ "$OUT" ]]; then +if [ "$OUT" ]; then # output data; if successful, remember most recent echo "$OUT" && echo "$OUT" | head -n1 | sed 's/^C\ //' > "$MK_LOGWATCH_AIX_STATE" fi
5 years, 5 months
1
0
0
0
Move the special agent utilities to the cmk module
by Tom Baerwinkel
Module: check_mk Branch: master Commit: 2032ea0f0b3cf8960c1c4c8a0e0b0101cfec439f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2032ea0f0b3cf8…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de> Date: Wed Jan 9 13:23:36 2019 +0100 Move the special agent utilities to the cmk module Introduce the new module cmk.special_agents and move the special agent utilities defined in agents/special/lib/cmk_special_agent_api.py to cmk/special_agents/utils.py. This makes it possible to introduce a similar module structure like in cmk.notification_scripts later on. Change-Id: I673934465a9fe0e22468f3ac4c1c93b0cb653815 --- Makefile | 4 ---- agents/special/.f12 | 1 - agents/special/agent_salesforce | 4 ++-- agents/special/cmk_special_agent_api.py | 1 - cmk/special_agents/__init__.py | 0 .../cmk_special_agent_api.py => cmk/special_agents/utils.py | 12 ++++++++---- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 010af8e..bce07c0 100644 --- a/Makefile +++ b/Makefile @@ -202,10 +202,6 @@ $(DISTNAME).tar.gz: mk-livestatus-$(VERSION).tar.gz .werks/werks web/htdocs/js/m --exclude "cme.py*" \ cmk_base/* ; \ rm cmk_base/*.pyc - python -m compileall agents/special/lib ; \ - tar czf $(DISTNAME)/special_agent_api.tar.gz $(TAROPTS) -C agents/special/lib cmk_special_agent_api.py \ - --exclude ".f12" - rm agents/special/lib/*.pyc tar czf $(DISTNAME)/werks.tar.gz $(TAROPTS) -C .werks werks tar czf $(DISTNAME)/checks.tar.gz $(TAROPTS) -C checks $$(cd checks ; ls) tar czf $(DISTNAME)/active_checks.tar.gz $(TAROPTS) -C active_checks $$(cd active_checks ; ls) diff --git a/agents/special/.f12 b/agents/special/.f12 index cf2c7d2..27d708f 100755 --- a/agents/special/.f12 +++ b/agents/special/.f12 @@ -6,4 +6,3 @@ SITE=${SITE:-$(omd sites --bare | head -n 1)} ROOT=/omd/sites/$SITE sudo cp agent_* $ROOT/share/check_mk/agents/special/ -sudo cp lib/cmk_special_agent_api.py $ROOT/lib/python/ diff --git a/agents/special/agent_salesforce b/agents/special/agent_salesforce index 68dd656..289c3f7 100755 --- a/agents/special/agent_salesforce +++ b/agents/special/agent_salesforce @@ -25,9 +25,9 @@ # Boston, MA 02110-1301 USA. import sys -import cmk_special_agent_api as special_agent_api +import cmk.special_agents.utils as utils -agent = special_agent_api.AgentJSON("salesforce", "Salesforce") +agent = utils.AgentJSON("salesforce", "Salesforce") content = agent.get_content() for section, section_content in content.iteritems(): sys.stdout.write("<<<%s>>>\n" % section) diff --git a/agents/special/cmk_special_agent_api.py b/agents/special/cmk_special_agent_api.py deleted file mode 120000 index 1529cf0..0000000 --- a/agents/special/cmk_special_agent_api.py +++ /dev/null @@ -1 +0,0 @@ -lib/cmk_special_agent_api.py \ No newline at end of file diff --git a/cmk/special_agents/__init__.py b/cmk/special_agents/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/agents/special/lib/cmk_special_agent_api.py b/cmk/special_agents/utils.py similarity index 95% rename from agents/special/lib/cmk_special_agent_api.py rename to cmk/special_agents/utils.py index 7a35438..05d930b 100644 --- a/agents/special/lib/cmk_special_agent_api.py +++ b/cmk/special_agents/utils.py @@ -23,10 +23,15 @@ # 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. - -import sys, requests, getopt """Place for common code shared among different Check_MK special agents""" +import getopt +import json +import pprint +import sys + +import requests + class AgentJSON(object): def __init__(self, key, title): @@ -51,7 +56,7 @@ USAGE: agent_%s --section_url [{section_name},{url}] long_options = ["section_url=", "help", "newline_replacement=", "debug"] try: - opts, args = getopt.getopt(sys.argv[1:], short_options, long_options) + opts, _args = getopt.getopt(sys.argv[1:], short_options, long_options) except getopt.GetoptError as err: sys.stderr.write("%s\n" % err) sys.exit(1) @@ -81,7 +86,6 @@ USAGE: agent_%s --section_url [{section_name},{url}] content[section_name].append(requests.get(url).text.replace("\n", newline_replacement)) if opt_debug: - import pprint, json for line in content: try: pprint.pprint(json.loads(line))
5 years, 5 months
1
0
0
0
cpu util wato params: move params to own file
by Moritz Kiemer
Module: check_mk Branch: master Commit: 2b2022cc94ddb2c3ba913422c12fbbe6c04fb4e5 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b2022cc94ddb2…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Wed Jan 9 14:24:32 2019 +0100 cpu util wato params: move params to own file Change-Id: I3a189d37b1263db79c52944b0fea43b03e1cdc99 --- .../wato/check_parameters/cpu_utilization.py | 179 +++++++++++++++++++++ cmk/gui/plugins/wato/check_parameters/unsorted.py | 138 ---------------- .../cmk/gui/plugins/wato/test_check_parameters.py | 4 +- 3 files changed, 181 insertions(+), 140 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=2b2022cc94…
5 years, 5 months
1
0
0
0
6953 lparstat_aix.cpu: Add levels for utilization
by Moritz Kiemer
Module: check_mk Branch: master Commit: 14885098b77fbaf416e4e9d706f18493f3644ded URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=14885098b77fba…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Wed Jan 9 15:04:19 2019 +0100 6953 lparstat_aix.cpu: Add levels for utilization You can now set levels for the CPU utilization as well as for IO-wait. Also available: Averaging and levels for time periods where CPU utilization is above the CPU entitlement. CMK-1297 Change-Id: I5ebe6ae882f61ca7d7300fb941e642aee494a36a --- .werks/6953 | 12 ++++++++ checks/lparstat_aix | 26 ++++------------- .../datasets/lparstat_aix_1_regression.py | 9 +++--- .../datasets/lparstat_aix_2_regression.py | 9 +++--- .../datasets/lparstat_aix_regression.py | 33 +++++++++++++--------- 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/.werks/6953 b/.werks/6953 new file mode 100644 index 0000000..832b80d --- /dev/null +++ b/.werks/6953 @@ -0,0 +1,12 @@ +Title: lparstat_aix.cpu: Add levels for utilization +Level: 1 +Component: checks +Compatible: compat +Edition: cre +Version: 1.6.0i1 +Date: 1547044973 +Class: feature + +You can now set levels for the CPU utilization as well as for IO-wait. +Also available: Averaging and levels for time periods where CPU +utilization is above the CPU entitlement. diff --git a/checks/lparstat_aix b/checks/lparstat_aix index 972f004..668e888 100644 --- a/checks/lparstat_aix +++ b/checks/lparstat_aix @@ -100,26 +100,12 @@ def check_lparstat_aix_cpu(_no_item, params, parsed): # and legacy None defaults before 1.6 params = transform_cpu_iowait(params) - perfdata = [("user", user), ("system", system), ("wait", wait)] + yield check_levels(user, "user", None, "%") + yield check_levels(system, "system", None, "%") + yield check_levels(wait, "wait", params.get('iowait'), "%") - infotext = "user: %2.1f%%, system: %2.1f%%, wait: %2.1f%%" % (user, system, wait) - - result = 0 - - if isinstance(params.get('util'), tuple): - warn, crit = params['util'] - if util >= crit: - result = max(result, 2) - elif util >= warn: - result = max(result, 1) - if 'iowait' in params: - warn, crit = params['iowait'] - if wait >= crit: - result = max(result, 2) - elif wait >= warn: - result = max(result, 1) - - yield result, infotext, perfdata + for util_result in check_cpu_util(util, params, perf_max=None): + yield util_result check_info['lparstat_aix.cpu_util'] = { @@ -128,5 +114,5 @@ check_info['lparstat_aix.cpu_util'] = { "service_description": "CPU utilization", "has_perfdata": True, "group": "cpu_iowait", - 'includes': ['transforms.include'], + "includes": ["transforms.include", "cpu_util.include"], } diff --git a/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py b/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py index 81e1c80..f883db4 100644 --- a/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py +++ b/tests/unit/checks/generictests/datasets/lparstat_aix_1_regression.py @@ -32,11 +32,10 @@ checks = { ], 'cpu_util': [ (None, None, [ - (0, 'user: 0.2%, system: 0.4%, wait: 0.0%', [ - ('user', 0.2, None, None, None, None), - ('system', 0.4, None, None, None, None), - ('wait', 0.0, None, None, None, None), - ]), + (0, 'user: 0.20%', [('user', 0.2)]), + (0, 'system: 0.40%', [('system', 0.4)]), + (0, 'wait: 0.00%', [('wait', 0.0)]), + (0, 'total cpu: 0.60%', [('util', 0.6000000000000001, None, None, 0, None)]), ]), ], } diff --git a/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py b/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py index d667b35..0a2dbe7 100644 --- a/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py +++ b/tests/unit/checks/generictests/datasets/lparstat_aix_2_regression.py @@ -65,11 +65,10 @@ checks = { ], 'cpu_util': [ (None, None, [ - (0, 'user: 0.2%, system: 0.4%, wait: 0.0%', [ - ('user', 0.2, None, None, None, None), - ('system', 0.4, None, None, None, None), - ('wait', 0.0, None, None, None, None), - ]), + (0, 'user: 0.20%', [('user', 0.2)]), + (0, 'system: 0.40%', [('system', 0.4)]), + (0, 'wait: 0.00%', [('wait', 0.0)]), + (0, 'total cpu: 0.60%', [('util', 0.6000000000000001, None, None, 0, None)]), ]), ], } diff --git a/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py b/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py index 8695c96..490b993 100644 --- a/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py +++ b/tests/unit/checks/generictests/datasets/lparstat_aix_regression.py @@ -17,7 +17,7 @@ discovery = { checks = { '': [ (None, None, [ - (0, 'Physc: 0.02',[('physc', 0.02, None, None, None, None)]), + (0, 'Physc: 0.02', [('physc', 0.02, None, None, None, None)]), (0, 'Entc: 9.3%', [('entc', 9.3, None, None, None, None)]), (0, 'Lbusy: 0.1', [('lbusy', 0.1, None, None, None, None)]), (0, 'App: 519.0', [('app', 519.0, None, None, None, None)]), @@ -27,18 +27,23 @@ checks = { ]), ], 'cpu_util': [ - (None, None, [(0, 'user: 0.2%, system: 1.2%, wait: 0.2%', - [('user', 0.2, None, None, None, None), - ('system', 1.2, None, None, None, None), - ('wait', 0.2, None, None, None, None)])]), - (None, (0.1, 0.3), [(1, 'user: 0.2%, system: 1.2%, wait: 0.2%', - [('user', 0.2, None, None, None, None), - ('system', 1.2, None, None, None, None), - ('wait', 0.2, None, None, None, None)])]), - (None, { - 'util': (0.5, 1.3) - }, [(2, 'user: 0.2%, system: 1.2%, wait: 0.2%', [('user', 0.2, None, None, None, None), - ('system', 1.2, None, None, None, None), - ('wait', 0.2, None, None, None, None)])]), + (None, None, [ + (0, 'user: 0.20%', [('user', 0.2)]), + (0, 'system: 1.20%', [('system', 1.2)]), + (0, 'wait: 0.20%', [('wait', 0.2)]), + (0, 'total cpu: 1.60%', [('util', 1.5999999999999999, None, None, 0, None)]), + ]), + (None, (0.1, 0.3), [ + (0, 'user: 0.20%', [('user', 0.2)]), + (0, 'system: 1.20%', [('system', 1.2)]), + (1, 'wait: 0.20% (warn/crit at 0.10%/0.30%)', [('wait', 0.2, 0.1, 0.3)]), + (0, 'total cpu: 1.60%', [('util', 1.5999999999999999, None, None, 0, None)]), + ]), + (None, {'util': (0.5, 1.3)}, [ + (0, 'user: 0.20%', [('user', 0.2)]), + (0, 'system: 1.20%', [('system', 1.2)]), + (0, 'wait: 0.20%', [('wait', 0.2)]), + (2, 'total cpu: 1.60% (warn/crit at 0.50%/1.30%)', [('util', 1.5999999999999999, 0.5, 1.3, 0, None)]), + ]), ] }
5 years, 5 months
1
0
0
0
lparstat_aix: minor reorganization
by Moritz Kiemer
Module: check_mk Branch: master Commit: 4af2507cc770964e54cd97625d8cd918bfb1b721 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4af2507cc77096…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Wed Jan 9 15:01:49 2019 +0100 lparstat_aix: minor reorganization Change-Id: I190ba557220584e91b2b8c509a61f464c740b82e --- checks/lparstat_aix | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/checks/lparstat_aix b/checks/lparstat_aix index 3ef6031..972f004 100644 --- a/checks/lparstat_aix +++ b/checks/lparstat_aix @@ -30,22 +30,6 @@ # | Joerg Linge 2009 <joerg.linge(a)pnp4nagios.org> Copyright 2010 | # +------------------------------------------------------------------+ -# %user %sys %wait %idle physc %entc lbusy app vcsw phint -# ----- ---- ----- ----- ----- ----- ------ --- ---- ----- -# 2.5 6.0 0.1 91.5 0.03 11.4 1.8 3.27 1976647217 490545630 - -# %user %sys %wait %idle physc %entc lbusy vcsw phint %nsp %utcyc -# ----- ----- ------ ------ ----- ----- ------ ----- ----- ----- ------ -# 0.2 0.4 0.0 99.3 0.02 1.7 0.0 215 3 101 0.64 - -# %user %sys %wait %idle physc %entc lbusy app vcsw phint %nsp %utcyc -# ----- ----- ------ ------ ----- ----- ------ --- ----- ----- ----- ------ -# 0.1 0.4 0.0 99.5 0.02 1.6 0.0 3.97 297 0 101 0.64 - -# %user %sys %wait %idle physc %entc lbusy vcsw phint %nsp -# ----- ----- ------ ------ ----- ----- ------ ----- ----- ----- -# 0.1 0.2 0.0 99.6 0.04 1.8 2.3 371 0 58 - def parse_lparstat_aix(info): if not info: @@ -111,15 +95,15 @@ def check_lparstat_aix_cpu(_no_item, params, parsed): if None in (user, system, wait): return - perfdata = [("user", user), ("system", system), ("wait", wait)] - util = user + system + wait - - infotext = "user: %2.1f%%, system: %2.1f%%, wait: %2.1f%%" % (user, system, wait) - # ancient legacy rule # and legacy None defaults before 1.6 params = transform_cpu_iowait(params) + + perfdata = [("user", user), ("system", system), ("wait", wait)] + + infotext = "user: %2.1f%%, system: %2.1f%%, wait: %2.1f%%" % (user, system, wait) + result = 0 if isinstance(params.get('util'), tuple):
5 years, 5 months
1
0
0
0
← Newer
1
...
34
35
36
37
38
39
40
...
49
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Results per page:
10
25
50
100
200