Skip to content

Commit

Permalink
Merge pull request #65 from bloemj/master
Browse files Browse the repository at this point in the history
Attempted to change memory check to check memAvailable instead of memFree
  • Loading branch information
proycon committed Mar 12, 2018
2 parents 930282e + 702fc7e commit e58ff6d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions clam/clamservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2301,15 +2301,15 @@ def sufficientresources():
if not os.path.exists('/proc/meminfo'):
printlog("WARNING: No /proc/meminfo available on your system! Not Linux? Skipping memory requirement check!")
else:
memfree = cached = 0.0
memavail = cached = 0.0
with open('/proc/meminfo') as f:
for line in f:
if line[0:8] == "MemFree:":
memfree = float(line[9:].replace('kB','').strip()) #in kB
if line[0:8] == "Cached:":
cached = float(line[9:].replace('kB','').strip()) #in kB
if settings.REQUIREMEMORY * 1024 > memfree + cached:
return False, str(settings.REQUIREMEMORY * 1024) + " kB memory is required but only " + str(memfree + cached) + " is available."
if line[0:13] == "MemAvailable:":
memavail = float(line[14:].replace('kB','').strip()) #in kB
if line[0:7] == "Cached:":
cached = float(line[14:].replace('kB','').strip()) #in kB
if settings.REQUIREMEMORY * 1024 > memavail + cached:
return False, str(settings.REQUIREMEMORY * 1024) + " kB memory is required but only " + str(memavail + cached) + " is available."
if settings.MAXLOADAVG > 0:
if not os.path.exists('/proc/loadavg'):
printlog("WARNING: No /proc/loadavg available on your system! Not Linux? Skipping load average check!")
Expand Down

0 comments on commit e58ff6d

Please sign in to comment.