Module: check_mk
Branch: master
Commit: 418d9df3c086e79d38f4f7c748675695b095fc39
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=418d9df3c086e7…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Dec 18 11:24:42 2014 +0100
Fixed various bugs in new packed config for keepalive mode
---
checks/logwatch | 7 +++----
modules/check_mk.py | 21 ++++++++-------------
2 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/checks/logwatch b/checks/logwatch
index 16a32aa..74afebd 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -330,11 +330,10 @@ def check_logwatch_generic(item, params, loglines, found,
groups=False):
if www_group != None:
try:
if i_am_root():
- import pwd
- to_user = pwd.getpwnam(nagios_user)[2]
+ to_user = nagios_user
else:
- to_user = -1 # keep user unchanged
- os.chown(logdir, to_user, www_group)
+ to_user = "" # keep user unchanged
+ os.system("chown %s:%s %s" % (to_user, www_group,
quote_shell_string(logdir)))
os.chmod(logdir, 0775)
except Exception, e:
os.rmdir(logdir)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 054ed78..c608f2b 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -308,7 +308,7 @@ special_agent_info = {}
# Now read in all checks. Note: this is done *before* reading the
# configuration, because checks define variables with default
-# values. The user can override those variables in his configuration.
+# values user can override those variables in his configuration.
# Do not read in the checks if check_mk is called as module
def load_checks():
filelist = glob.glob(checks_dir + "/*")
@@ -3541,6 +3541,12 @@ def pack_config():
out.write("\n%s = %r\n" % (varname, globals()[varname]))
for varname in derived_config_variable_names:
out.write("\n%s = %r\n" % (varname, globals()[varname]))
+ for varname, factory_setting in factory_settings.items():
+ if varname in globals():
+ out.write("\n%s = %r\n" % (varname, globals()[varname]))
+ else: # remove explicit setting from previous packed config!
+ out.write("\nif %r in globals():\n del %s\n" % (varname,
varname))
+
out.close()
os.rename(filepath + ".new", filepath)
@@ -5705,7 +5711,7 @@ def read_config_files(with_autochecks=True, with_conf_d=True):
# Initialize dictionary-type default levels variables
for check in check_info.values():
- def_var = check.get("default_levels_variable")
+ def_var = check.get("default_levels_variable")
######################### HIRN
if def_var:
globals()[def_var] = {}
@@ -5841,17 +5847,6 @@ def read_config_files(with_autochecks=True, with_conf_d=True):
sys.stderr.write("If you use own helper variables, please prefix them with
_.\n")
sys.exit(1)
- # Convert www_group into numeric id
- global www_group
- if type(www_group) == str:
- try:
- import grp
- www_group = grp.getgrnam(www_group)[2]
- except Exception, e:
- sys.stderr.write("Cannot convert group '%s' into group id:
%s\n" % (www_group, e))
- sys.stderr.write("Please set www_group to an existing group in
main.mk.\n")
- sys.exit(3)
-
# Prepare information for --backup and --restore
global backup_paths
backup_paths = [