summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Plugins/Monitors/Cpu.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Plugins/Monitors/Cpu.hs b/src/Plugins/Monitors/Cpu.hs
index 6e83c67..df2dc4e 100644
--- a/src/Plugins/Monitors/Cpu.hs
+++ b/src/Plugins/Monitors/Cpu.hs
@@ -24,12 +24,12 @@ cpuConfig = mkMConfig
"Cpu: <total>%"
["bar","vbar","total","user","nice","system","idle","iowait"]
-type CpuDataRef = IORef [Float]
+type CpuDataRef = IORef [Int]
-cpuData :: IO [Float]
+cpuData :: IO [Int]
cpuData = cpuParser `fmap` B.readFile "/proc/stat"
-cpuParser :: B.ByteString -> [Float]
+cpuParser :: B.ByteString -> [Int]
cpuParser = map (read . B.unpack) . tail . B.words . head . B.lines
parseCpu :: CpuDataRef -> IO [Float]
@@ -38,8 +38,8 @@ parseCpu cref =
b <- cpuData
writeIORef cref b
let dif = zipWith (-) b a
- tot = foldr (+) 0 dif
- percent = map (/ tot) dif
+ tot = fromIntegral $ foldr (+) 0 dif
+ percent = map (/ tot) (map fromIntegral dif)
return percent
formatCpu :: [Float] -> Monitor [String]