summaryrefslogtreecommitdiffhomepage
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
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).
-rw-r--r--Plugins/Monitors/Top.hs16
-rw-r--r--README10
2 files changed, 16 insertions, 10 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
diff --git a/README b/README
index ad49cd8..9a7f92b 100644
--- a/README
+++ b/README
@@ -422,7 +422,11 @@ Monitors have default aliases.
`TopProc Args RefreshRate`
- aliases to `top`
-- Args: default monitor arguments (see below)
+- Args: default monitor arguments (see below). The low and high
+ thresholds (`-L` and `-H`) denote, for memory entries, the percent
+ of the process memory over the total amount of memory currently in
+ use and, for cpu entries, the activity percentage (i.e., the value
+ of `cpuN`, which takes values between 0 and 100).
- Variables that can be used with the `-t`/`--template` argument:
`no`, `name1`, `cpu1`, `both1`, `mname1`, `mem1`, `mboth1`,
`name2`, `cpu2`, `both2`, `mname2`, `mem2`, `mboth2`, ...
@@ -435,7 +439,9 @@ Monitors have default aliases.
`TopMem Args RefreshRate`
- aliases to `topmem`
-- Args: default monitor arguments (see below)
+- Args: default monitor arguments (see below). The low and high
+ thresholds (`-L` and `-H`) denote the percent of the process memory
+ over the total amount of memory currently in use.
- Variables that can be used with the `-t`/`--template` argument:
`name1`, `mem1`, `both1`, `name2`, `mem2`, `both2`, ...
- Default template: `<both1>`