Module: check_mk
Branch: master
Commit: a7ad2d7fb48615226f47914504a7c09e5c5d48b6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a7ad2d7fb48615…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 26 09:13:19 2018 +0100
Refactoring: Use store.* functions for loading roles and groups now
Change-Id: I21d4a743994b165c7078503a4940c2fd11687e9e
---
web/htdocs/userdb.py | 138 +++++++++++++++++++++++----------------------------
1 file changed, 62 insertions(+), 76 deletions(-)
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 4b122e9..ce3fca9 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -925,51 +925,42 @@ def convert_idle_timeout(value):
# | |
# +----------------------------------------------------------------------+
-# TODO: Use store. methods. Don't initialize strucutres on corrupted files.
def load_roles():
- # Fake builtin roles into user roles.
- builtin_role_names = { # Default names for builtin roles
+ roles = store.load_from_mk_file(multisite_dir + "roles.mk", "roles",
+ default=_get_builtin_roles())
+
+ # Make sure that "general." is prefixed to the general permissions
+ # (due to a code change that converted "use" into "general.use", etc.
+ # TODO: Can't we drop this? This seems to be from very early days of the GUI
+ for role in roles.values():
+ for pname, pvalue in role["permissions"].items():
+ if "." not in pname:
+ del role["permissions"][pname]
+ role["permissions"]["general." + pname] = pvalue
+
+ # Reflect the data in the roles dict kept in the config module needed
+ # for instant changes in current page while saving modified roles.
+ # Otherwise the hooks would work with old data when using helper
+ # functions from the config module
+ # TODO: load_roles() should not update global structures
+ config.roles.update(roles)
+
+ return roles
+
+
+def _get_builtin_roles():
+ """Returns a role dictionary containing the bultin default roles"""
+ builtin_role_names = {
"admin" : _("Administrator"),
"user" : _("Normal monitoring user"),
"guest" : _("Guest user"),
}
- roles = dict([(id, {
+ return dict([(id, {
"alias" : builtin_role_names.get(id, id),
"permissions" : {}, # use default everywhere
"builtin": True})
for id in config.builtin_role_ids ])
- filename = multisite_dir + "roles.mk"
- try:
- vars = { "roles" : roles }
- execfile(filename, vars, vars)
- # Make sure that "general." is prefixed to the general permissions
- # (due to a code change that converted "use" into "general.use", etc.
- for role in roles.values():
- for pname, pvalue in role["permissions"].items():
- if "." not in pname:
- del role["permissions"][pname]
- role["permissions"]["general." + pname] = pvalue
-
- # Reflect the data in the roles dict kept in the config module needed
- # for instant changes in current page while saving modified roles.
- # Otherwise the hooks would work with old data when using helper
- # functions from the config module
- config.roles.update(vars['roles'])
-
- return vars["roles"]
-
- except IOError:
- return roles # Use empty structure, not existing file is ok!
- except Exception, e:
- if config.debug:
- raise MKGeneralException(_("Cannot read configuration file %s: %s") %
- (filename, e))
- else:
- auth_logger.error('load_roles: Problem while loading roles (%s - %s). '
- 'Initializing structure...' % (filename, e))
- return roles
-
#.
# .-Groups---------------------------------------------------------------.
# | ____ |
@@ -981,52 +972,47 @@ def load_roles():
# +----------------------------------------------------------------------+
# TODO: Contact groups are fine here, but service / host groups?
-# TODO: Use store. methods. Don't initialize strucutres on corrupted files.
def load_group_information():
- try:
- # Load group information from Check_MK world
- vars = {}
- for what in ["host", "service", "contact" ]:
- vars["define_%sgroups" % what] = {}
-
- filename = root_dir + "groups.mk"
- try:
- execfile(filename, vars, vars)
- except IOError:
- return {} # skip on not existing file
+ cmk_base_groups = _load_cmk_base_groups()
+ gui_groups = _load_gui_groups()
+
+ # Merge information from Check_MK and Multisite worlds together
+ groups = {}
+ for what in ["host", "service", "contact" ]:
+ groups[what] = {}
+ for id, alias in cmk_base_groups['define_%sgroups' % what].items():
+ groups[what][id] = {
+ 'alias': alias
+ }
+
+ if id in gui_groups['multisite_%sgroups' % what]:
+ groups[what][id].update(gui_groups['multisite_%sgroups' % what][id])
+
+ return groups
+
+
+def _load_cmk_base_groups():
+ """Load group information from Check_MK world"""
+ group_specs = {
+ "define_hostgroups": {},
+ "define_servicegroups": {},
+ "define_contactgroups": {},
+ }
+ for what in ["host", "service", "contact" ]:
+ group_specs["define_%sgroups" % what] = {}
- # Now load information from the Web world
- multisite_vars = {}
- for what in ["host", "service", "contact" ]:
- multisite_vars["multisite_%sgroups" % what] = {}
+ return store.load_mk_file(root_dir + "groups.mk", default=group_specs)
- filename = multisite_dir + "groups.mk"
- try:
- execfile(filename, multisite_vars, multisite_vars)
- except IOError:
- pass
-
- # Merge information from Check_MK and Multisite worlds together
- groups = {}
- for what in ["host", "service", "contact" ]:
- groups[what] = {}
- for id, alias in vars['define_%sgroups' % what].items():
- groups[what][id] = {
- 'alias': alias
- }
- if id in multisite_vars['multisite_%sgroups' % what]:
- groups[what][id].update(multisite_vars['multisite_%sgroups' % what][id])
- return groups
+def _load_gui_groups():
+ # Now load information from the Web world
+ group_specs = {
+ "multisite_hostgroups": {},
+ "multisite_servicegroups": {},
+ "multisite_contactgroups": {},
+ }
- except Exception, e:
- if config.debug:
- raise MKGeneralException(_("Cannot read configuration file %s: %s") %
- (filename, e))
- else:
- auth_logger.error('load_group_information: Problem while loading groups (%s - %s). '
- 'Initializing structure...' % (filename, e))
- return {}
+ return store.load_mk_file(multisite_dir + "groups.mk", default=group_specs)
class GroupChoice(DualListChoice):
Module: check_mk
Branch: master
Commit: fedccd95e72acd01e12f00df58855907a77d87d0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fedccd95e72acd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Feb 26 07:20:13 2018 +0100
5865 FIX omd rm --kill now kills all processes of the site user
Instead of just killing the processes that are currently accessing
the tmpfs of the site, the "omd rm" command together with the --kill
option now also kills all processes of the site user. This includes
open shells or similar that would otherwise make the site removal
fail in case such processes are open.
Change-Id: I88ec7cfdbf00f5f4950405d58138638c20480e64
---
.werks/5865 | 14 ++++++++++++++
omd/packages/omd/omd | 7 +++++--
omd/packages/omd/omd.8 | 4 ++--
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/.werks/5865 b/.werks/5865
new file mode 100644
index 0000000..1d9959f
--- /dev/null
+++ b/.werks/5865
@@ -0,0 +1,14 @@
+Title: omd rm --kill now kills all processes of the site user
+Level: 1
+Component: omd
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1519626013
+Class: fix
+
+Instead of just killing the processes that are currently accessing
+the tmpfs of the site, the "omd rm" command together with the --kill
+option now also kills all processes of the site user. This includes
+open shells or similar that would otherwise make the site removal
+fail in case such processes are open.
diff --git a/omd/packages/omd/omd b/omd/packages/omd/omd
index 05b81b8..8d9c7d3 100644
--- a/omd/packages/omd/omd
+++ b/omd/packages/omd/omd
@@ -2816,8 +2816,11 @@ def main_rm(args, options={}):
reuse = "reuse" in options
kill = "kill" in options
- if not kill and user_logged_in(g_sitename):
- bail_out("User '%s' still logged in or running processes." % g_sitename)
+ if user_logged_in(g_sitename):
+ if not kill:
+ bail_out("User '%s' still logged in or running processes." % g_sitename)
+ else:
+ kill_site_user_processes(exclude_current_and_parents=True)
if tmpfs_mounted(g_sitename):
unmount_tmpfs(g_sitename, kill=kill)
diff --git a/omd/packages/omd/omd.8 b/omd/packages/omd/omd.8
index 30c5272..c5e4d30 100644
--- a/omd/packages/omd/omd.8
+++ b/omd/packages/omd/omd.8
@@ -150,8 +150,8 @@ and group of that site. This - of course - needs root permissions.
The following options can be used:
The option \fB--kill\fP will automatically kill all processes that
-use the temporary filesystem of the site before unmounting it.
-Otherwise the unmount and the removal of the site will fail.
+either use the temporary filesystem of the site or are running as site
+user. Otherwise the unmount and the removal of the site will fail.
\fB--apache-reload\fP Issue a reaload of the apache process instead of the default restart
Module: check_mk
Branch: master
Commit: db2085a1f4be135cfc243c8905487c74b8735dc4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=db2085a1f4be13…
Author: Marcel Schulte <ms(a)mathias-kettner.de>
Date: Fri Feb 16 15:07:59 2018 +0100
4867 F5 BIG-IP: new checks for vCMP guest monitoring
New checks for vCMP guest monitoring have been added:
<ul>
<li>f5_bigip_vcmpguests: check only available on vCMP hosts, showing failover state of all guests</li>
<li>f5_bigip_vcmpfailover: check for vCMP guests, showing their failover status, configurable via WATO rule "Cluster status" - just like other failover/cluster checks, too</li>
</ul>
Change-Id: I4b22f9926894b0fdee612d6c80bb56f687474702
---
.werks/4867 | 16 +++++++++++
checkman/f5_bigip_vcmpfailover | 14 +++++++++
checkman/f5_bigip_vcmpguests | 13 +++++++++
checks/f5_bigip_vcmpfailover | 64 ++++++++++++++++++++++++++++++++++++++++++
checks/f5_bigip_vcmpguests | 64 ++++++++++++++++++++++++++++++++++++++++++
5 files changed, 171 insertions(+)
diff --git a/.werks/4867 b/.werks/4867
new file mode 100644
index 0000000..dbce881
--- /dev/null
+++ b/.werks/4867
@@ -0,0 +1,16 @@
+Title: F5 BIG-IP: new checks for vCMP guest monitoring
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1518790004
+Class: feature
+
+New checks for vCMP guest monitoring have been added:
+
+<ul>
+<li>f5_bigip_vcmpguests: check only available on vCMP hosts, showing failover state of all guests</li>
+<li>f5_bigip_vcmpfailover: check for vCMP guests, showing their failover status, configurable via WATO rule "Cluster status" - just like other failover/cluster checks, too</li>
+</ul>
+
diff --git a/checkman/f5_bigip_vcmpfailover b/checkman/f5_bigip_vcmpfailover
new file mode 100644
index 0000000..fb6f158
--- /dev/null
+++ b/checkman/f5_bigip_vcmpfailover
@@ -0,0 +1,14 @@
+title: F5 Big-IP: active/active or passive/active vCMP guest failover status
+agents: snmp
+catalog: hw/network/f5
+license: GPL
+distribution: check_mk
+description:
+ The check queries the MIB tables of F5 BIG-IP loadbalancers (local traffic managers) to identify
+ if the vCMP guest correctly runs in an {active/active} or an {active/passive} setup.
+ You can configure the expected behaviour via a WATO rule.
+ It will issue a warning if the cluster setup differs from the expected setup.
+
+inventory:
+ Creates one service
+
diff --git a/checkman/f5_bigip_vcmpguests b/checkman/f5_bigip_vcmpguests
new file mode 100644
index 0000000..33ff8ed
--- /dev/null
+++ b/checkman/f5_bigip_vcmpguests
@@ -0,0 +1,13 @@
+title: F5 Big-IP: show failover states of all vCMP guests running on a vCMP host
+agents: snmp
+catalog: hw/network/f5
+license: GPL
+distribution: check_mk
+description:
+ The check queries the MIB tables of F5 BIG-IP loadbalancers (local traffic managers) to identify
+ the failover status of every vCMP guest running on a vCMP host.
+ The service is informational, no parameters are used or configurable.
+
+inventory:
+ Creates one service
+
diff --git a/checks/f5_bigip_vcmpfailover b/checks/f5_bigip_vcmpfailover
new file mode 100644
index 0000000..ac27285
--- /dev/null
+++ b/checks/f5_bigip_vcmpfailover
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2018 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# 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.
+
+# Example SNMP output:
+#
+# .1.3.6.1.4.1.3375.2.1.13.1.1.0 0 # sysVcmpNumber
+# .1.3.6.1.4.1.3375.2.1.14.1.1.0 3 # sysCmFailoverStatusId
+
+
+def parse_f5_bigip_vcmpfailover(info):
+ return {
+ node: status for node, count, status in info
+ if int(count) == 0 # do nothing if we're at a vCMP-/Host/
+ }
+
+
+def inventory_f5_bigip_vcmpfailover(parsed):
+ if parsed:
+ return [ ( None, None ) ]
+
+
+def check_f5_bigip_vcmpfailover(_no_item, params, parsed):
+ if parsed:
+ return check_f5_bigip_cluster_status(_no_item, params, parsed, is_v11_2 = True)
+
+
+check_info["f5_bigip_vcmpfailover"] = {
+ "parse_function" : parse_f5_bigip_vcmpfailover,
+ "check_function" : check_f5_bigip_vcmpfailover,
+ "inventory_function" : inventory_f5_bigip_vcmpfailover,
+ "group" : "cluster_status",
+ "default_levels_variable" : "f5_bigip_cluster_default_levels",
+ "service_description" : "BIG-IP vCMP Guest Failover Status",
+ "node_info" : True,
+ "snmp_info" : (".1.3.6.1.4.1.3375.2.1", [
+ "13.1.1.0", # sysVcmpNumber
+ "14.3.1.0", # sysCmFailoverStatusId
+ ]),
+ "snmp_scan_function" : lambda oid: scan_f5_bigip_cluster_status(oid, is_v11_2=True),
+ "includes" : ["f5_bigip.include"],
+}
diff --git a/checks/f5_bigip_vcmpguests b/checks/f5_bigip_vcmpguests
new file mode 100644
index 0000000..b49a65b
--- /dev/null
+++ b/checks/f5_bigip_vcmpguests
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2018 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# 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.
+
+# Example SNMP output:
+#
+# .1.3.6.1.4.1.3375.2.1.13.4.2.1.1.8.101.97.115.108.50.48.48.49.0 easl2001 # sysVcmpStatVcmpName
+# .1.3.6.1.4.1.3375.2.1.13.4.2.1.1.8.112.97.115.108.50.48.48.49.0 pasl2001
+# .1.3.6.1.4.1.3375.2.1.13.4.2.1.1.8.116.97.115.108.50.48.48.49.0 tasl2001
+# .1.3.6.1.4.1.3375.2.1.13.4.2.1.17.8.101.97.115.108.50.48.48.49.0 Standby # sysVcmpStatPrompt
+# .1.3.6.1.4.1.3375.2.1.13.4.2.1.17.8.112.97.115.108.50.48.48.49.0 Standby
+# .1.3.6.1.4.1.3375.2.1.13.4.2.1.17.8.116.97.115.108.50.48.48.49.0 Standby
+
+
+def parse_f5_bigip_vcmpguests(info):
+ return {
+ guest: status.lower() for node, guest, status in info
+ }
+
+def inventory_f5_bigip_vcmpguests(parsed):
+ if parsed:
+ return [ ( None, None ) ]
+
+
+def check_f5_bigip_vcmpguests(_no_item, _no_params, parsed):
+ for guest in sorted(parsed):
+ yield 0, "Guest [%s] is %s" % (guest, parsed[guest])
+
+
+check_info["f5_bigip_vcmpguests"] = {
+ "parse_function" : parse_f5_bigip_vcmpguests,
+ "check_function" : check_f5_bigip_vcmpguests,
+ "inventory_function" : inventory_f5_bigip_vcmpguests,
+ "service_description" : "BIG-IP vCMP Guests",
+ "node_info" : True,
+ "snmp_info" : (".1.3.6.1.4.1.3375.2.1.13.4.2.1", [
+ "1", # sysVcmpStatVcmpName
+ "17", # sysVcmpStatPrompt
+ ]),
+ "snmp_scan_function" : lambda oid: scan_f5_bigip_cluster_status(oid, is_v11_2=True),
+ "includes" : ["f5_bigip.include"],
+}