From 9778203cf27e77a9ba6620423395a04642a640b7 Mon Sep 17 00:00:00 2001 From: Jose A Ortega Ruiz Date: Fri, 26 Mar 2010 04:09:56 +0100 Subject: Less resource hungry Top monitors. Ignore-this: f963302295a675773ab3bfd54e458a0d darcs-hash:20100326030956-748be-df70f254d1274a3f4b576df392cf6c30a0f1f582.gz --- Plugins/Monitors/Mem.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Plugins/Monitors/Mem.hs') diff --git a/Plugins/Monitors/Mem.hs b/Plugins/Monitors/Mem.hs index c6c4dc4..f493862 100644 --- a/Plugins/Monitors/Mem.hs +++ b/Plugins/Monitors/Mem.hs @@ -12,7 +12,7 @@ -- ----------------------------------------------------------------------------- -module Plugins.Monitors.Mem where +module Plugins.Monitors.Mem (memConfig, runMem, totalMem, usedMem) where import Plugins.Monitors.Common @@ -35,18 +35,24 @@ parseMEM = usedratio = used / total return [usedratio, total, free, buffer, cache, rest, used] +totalMem :: IO Float +totalMem = fmap ((*1024) . (!!1)) parseMEM + +usedMem :: IO Float +usedMem = fmap ((*1024) . (!!6)) parseMEM + formatMem :: [Float] -> Monitor [String] formatMem (r:xs) = - do let f n = showDigits 0 n + do let f = showDigits 0 rr = 100 * r ub <- showPercentBar rr r fb <- showPercentBar (100 - rr) (1 - r) s <- mapM (showWithColors f) (rr:xs) return (ub:fb:s) -formatMem _ = return $ replicate 8 "N/A" +formatMem _ = return $ replicate 9 "N/A" runMem :: [String] -> Monitor String runMem _ = - do m <- io $ parseMEM + do m <- io parseMEM l <- formatMem m parseTemplate l -- cgit v1.2.3