summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Top.hs
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-10 17:06:42 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-10 17:06:42 +0100
commitd726f8e31984cd7afc4907615c58082e8049a671 (patch)
tree9058a26f534012262430faa640c10a0032229dcd /Plugins/Monitors/Top.hs
parentbf4b4ba93518ed75386533605df18bdadb93705b (diff)
downloadxmobar-d726f8e31984cd7afc4907615c58082e8049a671.tar.gz
xmobar-d726f8e31984cd7afc4907615c58082e8049a671.tar.bz2
Top: better meaning for -L/-H in memory entries
Now those are really thresholds over the percentage of process memory over total used memory (as was intended but badly implemented).
Diffstat (limited to 'Plugins/Monitors/Top.hs')
-rw-r--r--Plugins/Monitors/Top.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/Plugins/Monitors/Top.hs b/Plugins/Monitors/Top.hs
index 924d4b6..30476ac 100644
--- a/Plugins/Monitors/Top.hs
+++ b/Plugins/Monitors/Top.hs
@@ -17,7 +17,6 @@
module Plugins.Monitors.Top (startTop, topMemConfig, runTopMem) where
import Plugins.Monitors.Common
-import Plugins.Monitors.Mem (usedMem)
import Control.Exception (SomeException, handle)
import System.Directory
@@ -95,12 +94,13 @@ meminfos = handleProcesses meminfo
showMeminfo :: Float -> Meminfo -> Monitor [String]
showMeminfo scale (nm, rss) =
- showInfo nm (showWithUnits 2 1 rss) (rss / (1024 * scale))
+ showInfo nm (showWithUnits 2 1 rss) (100 * rss / scale)
runTopMem :: [String] -> Monitor String
runTopMem _ = do
ps <- io meminfos
- pstr <- mapM (showMeminfo 1) $ sortTop ps
+ let !tm = sum (map snd ps)
+ pstr <- mapM (showMeminfo tm) $ sortTop ps
parseTemplate $ concat pstr
type Pid = Int
@@ -140,17 +140,17 @@ topProcesses tref scale = do
showTimeInfo :: TimeInfo -> Monitor [String]
showTimeInfo (n, t) = showInfo n (showDigits 1 t) t
-runTop :: TimesRef -> Float -> Float -> [String] -> Monitor String
-runTop tref scale mscale _ = do
+runTop :: TimesRef -> Float -> [String] -> Monitor String
+runTop tref scale _ = do
(no, ps, ms) <- io $ topProcesses tref scale
pstr <- mapM showTimeInfo ps
- mstr <- mapM (showMeminfo mscale) ms
+ let !tm = sum (map snd ms)
+ mstr <- mapM (showMeminfo tm) ms
parseTemplate $! show no : concat (zipWith (++) pstr mstr)
startTop :: [String] -> Int -> (String -> IO ()) -> IO ()
startTop a r cb = do
cr <- getSysVar ClockTick
- m <- usedMem
c <- getCurrentTime
tref <- newIORef (M.empty, c)
- runM a topConfig (runTop tref (fromIntegral cr) m) r cb
+ runM a topConfig (runTop tref (fromIntegral cr)) r cb