Commit 455c167a authored by Tristan Cavelier's avatar Tristan Cavelier

check_computer_memory: fix wrong var assignment + update docstring

free were equal to memory_used
used were equal to memory_free
parent db3c9243
#!/usr/bin/env python
"""
Check if memory usage is greater than given threshold.
Check if memory usage is lower than 80% of total memory.
Uses:
- /proc/meminfo
......@@ -29,7 +29,7 @@ def getFreeMemory(database, time, date):
# fetch free and used memory
where_query = "time between '%s:00' and '%s:30' " % (time, time)
query_result = database.select("system", date, "memory_used, memory_free", where=where_query)
query_result = database.select("system", date, "memory_free, memory_used", where=where_query)
result = zip(*query_result)
if not result or not result[0][0]:
print "couldn't fetch free memory"
......
......@@ -47,7 +47,7 @@ class TestComputerMemory(unittest.TestCase):
self.conn.close()
def test_check_memory(self):
self.assertEquals({'total': 33705312256.0, 'free': 33139023872.0, 'used': 566288384.0},
self.assertEquals({'total': 33705312256.0, 'used': 33139023872.0, 'free': 566288384.0},
getFreeMemory('/tmp', '00:02', '2017-09-15'))
def test_check_memory_with_unavailable_dates(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment