
17 Jun
2008
17 Jun
'08
11:56 a.m.
dons:
magicloud.magiclouds:
OK. Here it is. I want to make a monitor tool for linux. It runs for a long time, and give out a certain process's io stat per second. The way I get io stat is to read from /proc/pid/io. But the data in this file is a total, I need to read it first, then next second, read it again, and shows the difference, and go on. So, what is your idea?
Easy,
import Control.Concurrent import Control.Monad
main = go 0 where go st = forever $ do n <- read `fmap` readFile "/proc/pid/io" print (n - st) -- display difference threadDelay (10^6)
Oops, not 'forever' :) go st = do ... go n