From: Andrew Lorimer Date: Mon, 11 Mar 2019 09:34:41 +0000 (+1100) Subject: writing disk usage now depends on logrotate config X-Git-Url: https://git.lorimer.id.au/logparse.git/diff_plain/7e5b6eac939f677d581a89ebe09080160c277411?ds=inline;hp=c24ab8a1e0437e1afcc990786c39186320475d87 writing disk usage now depends on logrotate config --- diff --git a/logparse.py b/logparse.py index 8906802..896e764 100755 --- a/logparse.py +++ b/logparse.py @@ -45,7 +45,7 @@ config = { 'sys': '/var/log/syslog', 'smb': '/var/log/samba', 'zfs': '/var/log/zpool.log', - 'alloc': '/tmp/alloc', + 'alloc': '/var/log/du.log', 'postfix': '/var/log/mail.log', 'httpd': '/var/log/apache2' } @@ -126,7 +126,7 @@ def __main__(): closetag(tag, 1) tempfile.close() mailprep(config['output'], MAILPATH) - if (config['mail']['to'] != None): + if (config['mail']['to']): logger.debug("sending email") ms = subject(config['mail']['subject']) cmd = "/bin/cat " + MAILPATH + " | /usr/bin/mail --debug-level=10 -a 'Content-type: text/html' -s '" + ms + "' " + config['mail']['to'] @@ -765,7 +765,8 @@ def du(): else: out.append([p, "used " + parsesize(alloc_f), "delta " + parsesize(delta)]) contentnew += (p + '\t' + str(alloc_f) + '\n') - writelog('alloc', contentnew) + if config['rotate'] == 'y': + writelog('alloc', contentnew) writetitle("du") logger.debug("disk usage data is " + str(out))