Module: check_mk
Branch: master
Commit: ef557dc58d5749b06d44c18667861c77ddf9b84a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ef557dc58d5749…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 6 17:33:55 2016 +0200
logwatch: small cleanup removed way too complex directory creation
---
checks/logwatch | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/checks/logwatch b/checks/logwatch
index 4e4021e..141eedf 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -378,32 +378,14 @@ def logwatch_username():
def check_logwatch_generic(item, params, loglines, found, groups=False):
+ logdir = logwatch_dir + "/" + g_hostname
+
# Create directories, if neccessary
try:
- logdir = logwatch_dir + "/" + g_hostname
- if not os.path.exists(logwatch_dir):
- os.mkdir(logwatch_dir)
- if not os.path.exists(logdir):
- os.mkdir(logdir)
- if www_group != None:
- try:
- if i_am_root():
- to_user = nagios_user
- else:
- 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)
- raise MKGeneralException(("User %s cannot chown directory to
group id %d: %s. Please make sure "+
- "that %s is a member of that
group.") %
- (logwatch_username(), www_group, e,
logwatch_username()))
-
- except MKGeneralException:
- raise
- except Exception, e:
- raise MKGeneralException("User %s cannot create logwatch directory: %s"
% \
- (logwatch_username(), e))
+ os.makedirs(logdir)
+ except OSError, e:
+ if e.errno == 17:
+ pass # Exists
logfile = logdir + "/" + item.replace("/", "\\")