diff options
Diffstat (limited to 'src/Plugins/Monitors/Mem.hs')
-rw-r--r-- | src/Plugins/Monitors/Mem.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Plugins/Monitors/Mem.hs b/src/Plugins/Monitors/Mem.hs index 7e9341f..47a4c3f 100644 --- a/src/Plugins/Monitors/Mem.hs +++ b/src/Plugins/Monitors/Mem.hs @@ -15,6 +15,7 @@ module Plugins.Monitors.Mem (memConfig, runMem, totalMem, usedMem) where import Plugins.Monitors.Common +import qualified Data.Map as M memConfig :: IO MConfig memConfig = mkMConfig @@ -28,8 +29,9 @@ fileMEM = readFile "/proc/meminfo" parseMEM :: IO [Float] parseMEM = do file <- fileMEM - let content = map words $ take 4 $ lines file - [total, free, buffer, cache] = map (\line -> (read $ line !! 1 :: Float) / 1024) content + let content = map words $ take 8 $ lines file + 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 usedratio = used / total |