コード例 #1
0
ファイル: ram.py プロジェクト: donaldharvey/drizzle
	def __init__(self, options={}):
		Sensor.__init__(self, options)
		# find out the location in the file of various bits of info about RAM
		# as defined at http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/filesystems/proc.txt;hb=HEAD
		self.data_positions = {}
		contents = open('/proc/meminfo').read()
		contents = contents.split('\n')[:-1]
		for index, line in enumerate(contents):
			print line
			print line.split()
			try:
				self.data_positions[line.split()[0][:-1]] = index + 1 # line numbers aren't zero-based
			except IndexError:
				pass # in case line is empty
コード例 #2
0
ファイル: cpu.py プロジェクト: donaldharvey/drizzle
 def __init__(self, options={}):
     Sensor.__init__(self, options)
     self.re = re.compile("^cpu .*\n")
     self.prev_idle = 0
     self.prev_total = 0