Ejemplo n.º 1
0
	def create_data(self, basedir, name_data_map):
		dir_path = os.path.join(self.path, basedir)

		if not os.path.exists(dir_path): # not exists, create folder
			os.makedirs(dir_path)

		rra_list = []
		if 'RRA' in name_data_map:
			rra_list = name_data_map['RRA']	

		for name, data in name_data_map.items(): # for each section
			if name == 'RRA':		# already read
				continue

			filename = name + '.rrd'
			filename = filename.replace('/', '_')
			
			path = os.path.join(dir_path, filename)

			if not os.path.exists(path):
				rrd_file = rrd_data(path)

				assert (isinstance(data, list))
				for item in data:
					rrd_file.put_ds(*item)

				for rra in rra_list:
					rrd_file.put_rra(*rra)

				rrd_file.create()
Ejemplo n.º 2
0
	def open_data(self, basedir, filename):
		path = os.path.join(self.path, basedir)
		path = os.path.join(path, filename)
		rrd_file = None

		if os.path.exists(path):
			rrd_file = rrd_data(path)

		return rrd_file
Ejemplo n.º 3
0
def rrd_update_data(file_path, timestamp, data):
	try:
		if os.path.exists(file_path):
			rrd_file = rrd_data(file_path)
			rrd_file.update(timestamp, data)
		else:
			print('## rrd file not found: %s' % file_path)

	except Exception as e:
		print(e)
		print('on update file %s (item: %d)' % (file_path, len(data)))
		print(data)