summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/Plugins')
-rw-r--r--src/Plugins/Monitors/MultiCpu.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Plugins/Monitors/MultiCpu.hs b/src/Plugins/Monitors/MultiCpu.hs
index eab21da..f0cdec4 100644
--- a/src/Plugins/Monitors/MultiCpu.hs
+++ b/src/Plugins/Monitors/MultiCpu.hs
@@ -58,15 +58,15 @@ multiCpuConfig =
[ k ++ n | n <- "" : map show [0 :: Int ..]
, k <- variables]
-type CpuDataRef = IORef [[Float]]
+type CpuDataRef = IORef [[Int]]
-cpuData :: IO [[Float]]
+cpuData :: IO [[Int]]
cpuData = parse `fmap` B.readFile "/proc/stat"
where parse = map parseList . cpuLists
cpuLists = takeWhile isCpu . map B.words . B.lines
isCpu (w:_) = "cpu" `isPrefixOf` B.unpack w
isCpu _ = False
- parseList = map (parseFloat . B.unpack) . tail
+ parseList = map (parseInt . B.unpack) . tail
parseCpuData :: CpuDataRef -> IO [[Float]]
parseCpuData cref =
@@ -76,9 +76,9 @@ parseCpuData cref =
let p0 = zipWith percent bs as
return p0
-percent :: [Float] -> [Float] -> [Float]
+percent :: [Int] -> [Int] -> [Float]
percent b a = if tot > 0 then map (/ tot) $ take 4 dif else [0, 0, 0, 0]
- where dif = zipWith (-) b a
+ where dif = map fromIntegral $ zipWith (-) b a
tot = sum dif
formatMultiCpus :: MultiCpuOpts -> [[Float]] -> Monitor [String]