writing disk usage now depends on logrotate config
authorAndrew Lorimer <andrew@charles.cortex>
Mon, 11 Mar 2019 09:34:41 +0000 (20:34 +1100)
committerAndrew Lorimer <andrew@charles.cortex>
Mon, 11 Mar 2019 09:34:41 +0000 (20:34 +1100)
logparse.py
index 890680226ac455ac793a3cb21a28231013694ae6..896e7640023a086e1c0f6fa697f8bbfbbe748de4 100755 (executable)
@@ -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))