'httpd': {
'resolve-domains': '',
},
- 'du-paths': ['/', '/etc', '/home'],
+ 'du': {
+ 'paths': ['/', '/etc', '/home'],
+ 'force-write': 'n',
+ },
'hostname-path': '/etc/hostname',
'logs': {
'auth': '/var/log/auth.log',
return hn
def getlocaldomain(): # get the parent fqdn of current server
- domain = socket.getfqdn().split('.', 1)
- if len(domain) == 2:
+ domain = socket.getfqdn().split('.', 1) # Note: if socket.fetfqdn() returns localhost, make sure the first entry in /etc/hosts contains the fqdn
+ if len(domain) != 2:
logger.warning('Could not get domain of this server, only hostname. Please consider updating /etc/hosts')
return ''
else:
file = open(path, mode)
file.write(content)
file.close()
+ logger.debug("written to file " + path)
def getusage(path): # Get disk usage statistics
disk = os.statvfs(path)
out = []
content = readlog('alloc')
contentnew = ""
- for p in config['du-paths']:
- alloc_f = getusage(p).alloc
+ for path in config['du']['paths']:
+ alloc_f = getusage(path).alloc
delta = None
try:
- alloc_i = re.search(p + '\t(.*)\n', content).group(1)
+ alloc_i = re.search(path + '\t(.*)\n', content).group(1)
delta = alloc_f - float(alloc_i)
except:
pass
if (delta == None):
- out.append([p, "used " + parsesize(alloc_f)])
+ out.append([path, "used " + parsesize(alloc_f)])
else:
- out.append([p, "used " + parsesize(alloc_f), "delta " + parsesize(delta)])
- contentnew += (p + '\t' + str(alloc_f) + '\n')
- if config['rotate'] == 'y':
+ out.append([path, "used " + parsesize(alloc_f), "delta " + parsesize(delta)])
+ contentnew += (path + '\t' + str(alloc_f) + '\n')
+ if config['rotate'] == 'y' or config['du']['force-write'] == 'y':
writelog('alloc', contentnew)
writetitle("du")