From 7d89f491115c6323e7427780052d86905d8507de Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 17 Nov 2018 22:14:56 +0000 Subject: TopProc: skipping kernel threads (fixes #369) --- src/Plugins/Monitors/Top.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Plugins/Monitors/Top.hs b/src/Plugins/Monitors/Top.hs index d60897d..41a68b2 100644 --- a/src/Plugins/Monitors/Top.hs +++ b/src/Plugins/Monitors/Top.hs @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Top --- Copyright : (c) 2010, 2011, 2012, 2013, 2014 Jose A Ortega Ruiz +-- Copyright : (c) 2010, 2011, 2012, 2013, 2014, 2018 Jose A Ortega Ruiz -- License : BSD-style (see LICENSE) -- -- Maintainer : Jose A Ortega Ruiz @@ -68,9 +68,18 @@ getProcessData pidf = where readWords = fmap (statWords . words) . hGetLine ign = const (return []) :: SomeException -> IO [String] +memPages :: [String] -> String +memPages fs = fs!!23 + +ppid :: [String] -> String +ppid fs = fs!!3 + +skip :: [String] -> Bool +skip fs = length fs < 24 || memPages fs == "0" || ppid fs == "0" + handleProcesses :: ([String] -> a) -> IO [a] handleProcesses f = - fmap (foldl' (\a p -> if length p < 15 then a else f p : a) []) + fmap (foldl' (\a p -> if skip p then a else f p : a) []) (processes >>= mapM getProcessData) showInfo :: String -> String -> Float -> Monitor [String] -- cgit v1.2.3