summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-01-25 04:15:34 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-01-25 04:15:34 +0100
commit314a1261d5fed0bf7ae7a5537bf97e6549cf3401 (patch)
treedf1cf6bcfaee7b8f2a0c6d790cf557e9e567a959 /Plugins/Monitors
parent27d1c74b8c67a01e0203778d020336ed2dc189b0 (diff)
downloadxmobar-314a1261d5fed0bf7ae7a5537bf97e6549cf3401.tar.gz
xmobar-314a1261d5fed0bf7ae7a5537bf97e6549cf3401.tar.bz2
Disk: better error recovery
Ignore-this: 9a4573711403eb432c20e99efe176811 darcs-hash:20100125031534-1d908-ff74cc159bda5b25393f42b3c321b8b7282dfcb0.gz
Diffstat (limited to 'Plugins/Monitors')
-rw-r--r--Plugins/Monitors/Disk.hs12
1 files changed, 4 insertions, 8 deletions
diff --git a/Plugins/Monitors/Disk.hs b/Plugins/Monitors/Disk.hs
index 5e6901c..9a86b46 100644
--- a/Plugins/Monitors/Disk.hs
+++ b/Plugins/Monitors/Disk.hs
@@ -35,7 +35,7 @@ parseMountedDevices =
map undev . filter isDev . map (firstTwo . B.words) . B.lines
where
firstTwo (a:b:_) = (B.unpack a, B.unpack b)
- firstTwo _ = error "Unexpected mtab format"
+ firstTwo _ = ("", "")
isDev (d, _) = "/dev/" `isPrefixOf` d
undev (d, f) = (drop 5 d, f)
@@ -64,7 +64,7 @@ parseData reqs mounted dat dat2 =
in
case (f1, f2) of
(Just (_, x), Just (_, y)) -> formatDev path (dev, zipWith (-) y x)
- _ -> error $ "Device " ++ dev ++ "not found in diskstats"
+ _ -> (dev, path, [0, 0, 0])
in map format rm
formatDev :: Path -> (DevName, [Float]) -> (DevName, Path, [Float])
@@ -73,8 +73,8 @@ formatDev path (dev, xs) =
wSp = speed (xs !! 6) (xs !! 7)
sp = speed (xs !! 2 + xs !! 6) (xs !! 3 + xs !! 7)
speed x t = if t == 0 then 0 else 500 * x / t
- in
- (dev, path, [sp, rSp, wSp])
+ dat = if length xs > 6 then [sp, rSp, wSp] else [0, 0, 0]
+ in (dev, path, dat)
speedToStr :: Int -> Float -> String
speedToStr n x =
@@ -110,7 +110,3 @@ runDisk disks _ = do
dat <- io $ mountedData (map fst disks)
strs <- mapM (\(d, p, xs) -> runDisk' (findTempl d p disks) xs) dat
return $ intercalate " " strs
-
-
-
-