Upgrade setuptools from 0.6c6 to 0.6c9
[iotop.git] / iotop / vmstat.py
blob5211fc84ae9b8a4d759390e9681e94aff3cbd822
1 import os
3 class VmStat(object):
4 def __init__(self):
5 self.vmstat_file = open('/proc/vmstat')
6 self.vmstat = self.read()
8 def read(self):
9 def extract(line):
10 return int(line.split()[1]) * 1024
12 for line in self.vmstat_file:
13 if line.startswith('pgpgin '):
14 pgpgin = extract(line)
15 break
17 for line in self.vmstat_file:
18 if line.startswith('pgpgout '):
19 pgpgout = extract(line)
20 break
22 self.vmstat_file.seek(0)
23 return pgpgin, pgpgout
25 def delta(self):
26 now = self.read()
27 delta = now[0] - self.vmstat[0], now[1] - self.vmstat[1]
28 self.vmstat = now
29 return delta