diff options
-rw-r--r-- | Plugins/Monitors/Top.hs | 16 | ||||
-rw-r--r-- | README | 10 |
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 @@ -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>` |