Skip to content
This repository has been archived by the owner on May 21, 2023. It is now read-only.

Commit

Permalink
Calculate vmail on disk usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaldur committed Aug 11, 2022
1 parent 2c28415 commit 61ecb21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions plogical/IncScheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,7 @@ def CalculateAndUpdateDiskUsage():
email.save()
print('Disk Usage of %s is %s' % (email.email, email.DiskUsage))

config['DiskUsage'], config['DiskUsagePercentage'] = virtualHostUtilities.getDiskUsage(
"/home/" + website.domain, website.package.diskSpace)
config['DiskUsage'], config['DiskUsagePercentage'] = virtualHostUtilities.getDiskUsage(website.domain, website.package.diskSpace)

if website.package.enforceDiskLimits:
if config['DiskUsagePercentage'] >= 100:
Expand Down
7 changes: 6 additions & 1 deletion plogical/virtualHostUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,12 @@ def switchServer(virtualHostName, phpVersion, server, tempStatusPath):
def getDiskUsage(path, totalAllowed):
try:

totalUsageInMB = subprocess.check_output('du -hs %s --block-size=1M' % (path), shell=True).decode("utf-8").split()[0]
totalUsageInMB = subprocess.check_output('du -hs /home/%s --block-size=1M' % (path), shell=True).decode("utf-8").split()[0]

# Calculate vmail folder size and add it to usage
totalUsageEmailInMB = subprocess.check_output('du -hs /home/vmail/%s --block-size=1M' % (path), shell=True).decode("utf-8").split()[0]

totalUsageInMB = int(totalUsageEmailInMB) + int(totalUsageInMB)

percentage = float(100) / float(totalAllowed)

Expand Down

0 comments on commit 61ecb21

Please sign in to comment.