def _get_mem_usage(self): """Compute percent memory in active use. @returns float of percent memory in use. """ total_memory = utils.get_mem_total() free_memory = utils.get_mem_free() return ((total_memory - free_memory) / total_memory) * 100
def get_mem_free(self): """Returns the currently free memory in the system in MBytes.""" return utils.get_mem_free()
def test_get_mem_free(self): self.fake_file_text = ('MemTotal: 2048000 kB\n' 'MemFree: 307200 kB\n' 'Buffers: 102400 kB\n' 'Cached: 204800 kB\n') self.assertAlmostEqual(utils.get_mem_free(), 300)
def used_mem(self): """Returns total used memory in %.""" total_memory = utils.get_mem_total() return (total_memory - utils.get_mem_free()) * 100 / total_memory