summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/Monitors')
-rw-r--r--Plugins/Monitors/Swap.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/Plugins/Monitors/Swap.hs b/Plugins/Monitors/Swap.hs
index d18ab8a..40c21ed 100644
--- a/Plugins/Monitors/Swap.hs
+++ b/Plugins/Monitors/Swap.hs
@@ -29,9 +29,16 @@ fileMEM = B.readFile "/proc/meminfo"
parseMEM :: IO [Float]
parseMEM =
do file <- fileMEM
- let p x y = flip (/) 1024 . read . stringParser x $ y
- tot = p (1,11) file
- free = p (1,12) file
+ let li i l
+ | l /= [] = (head l) !! i
+ | otherwise = B.empty
+ fs s l
+ | l == [] = False
+ | otherwise = head l == B.pack s
+ get_data s = flip (/) 1024 . read . B.unpack . li 1 . filter (fs s)
+ st = map B.words . B.lines $ file
+ tot = get_data "SwapTotal:" st
+ free = get_data "SwapFree:" st
return [tot, (tot - free), free, (tot - free) / tot]
formatSwap :: [Float] -> Monitor [String]