1 # -*- coding: utf-8 -*-
3 from __future__ import division
49 ('delayacct_blkio_ticks', int),
63 process = subprocess.Popen(['getconf', 'CLK_TCK'], shell=True, stdout=subprocess.PIPE)
64 if process.wait() != 0:
65 raise "getconf CLK_TCK failed"
68 #= 100 -> 1 tick = 1/100 seconds
69 # require libc-bin to be installed
72 def __init__(self, processid):
74 strstats = open('/proc/%s/stat' % processid).read()
75 strstats = strstats.rstrip('\n').split(' ')
76 for i, keycls in enumerate(__proc_keys__):
78 self[key] = cls(strstats[i])
82 nice_state = __states__.get(state, None)
85 return "%s (%s)" % (state, nice_state)
88 # subprocess.call(['getconf', 'CLK_TCK']) = 100 -> 1 tick = 1/100 seconds
90 return self['utime'] / 100
93 return self['stime'] / 100
95 if __name__ == '__main__':