From 70fe560d6e66c6f5a44511f70d06977cde32215b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 4 Feb 2014 22:49:33 -0500 Subject: Use MemAvailable from meminfo if possible Use the functionality from newer kernels if available. Basically, the free+buffer+cache metric is a massive hack and not accurate anyways (e.g., not all cache can be swapped out and kernel accounting can change whenever). Kernels 3.14 and newer have MemAvailable in meminfo which is more accurate; use it if possible. --- src/Plugins/Monitors/Mem.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Plugins/Monitors') diff --git a/src/Plugins/Monitors/Mem.hs b/src/Plugins/Monitors/Mem.hs index 47a4c3f..d7b6754 100644 --- a/src/Plugins/Monitors/Mem.hs +++ b/src/Plugins/Monitors/Mem.hs @@ -33,7 +33,7 @@ parseMEM = info = M.fromList $ map (\line -> (line !! 0, (read $ line !! 1 :: Float) / 1024)) content [total, free, buffer, cache] = map (info M.!) ["MemTotal:", "MemFree:", "Buffers:", "Cached:"] rest = free + buffer + cache - used = total - rest + used = total - (M.findWithDefault rest "MemAvailable:" info) usedratio = used / total freeratio = free / total return [usedratio, freeratio, total, free, buffer, cache, rest, used, freeratio] -- cgit v1.2.3