当前位置: 首页>>代码示例>>Python>>正文


Python rrdtool.update方法代码示例

本文整理汇总了Python中rrdtool.update方法的典型用法代码示例。如果您正苦于以下问题:Python rrdtool.update方法的具体用法?Python rrdtool.update怎么用?Python rrdtool.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rrdtool的用法示例。


在下文中一共展示了rrdtool.update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plugin

# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import update [as 别名]
def plugin(srv, item):

    srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__, item.service, item.target)

    # If the incoming payload has been transformed, use that,
    # else the original payload
    text = item.message

    try:
        # addrs is a list[] associated with a particular target.
        # it can contain an arbitrary amount of entries that are just
        # passed along to rrdtool
        # mofified by otfdr @ github to accept abitray arguments with
        # the payload and to not always add the 'N' in front
        # 2017-06-05 - fix/enhancement for https://github.com/jpmens/mqttwarn/issues/248
        if re.match( "^\d+$", text ):
                rrdtool.update(item.addrs, "N:" + text)
        else:
                rrdtool.update(item.addrs + text.split())
    except Exception as e:
        srv.logging.warning("Cannot call rrdtool")
        return False

    return True 
开发者ID:jpmens,项目名称:mqttwarn,代码行数:26,代码来源:rrdtool.py

示例2: update_data

# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import update [as 别名]
def update_data(self, entity, timestamp, name_data_map):
		for table, data in name_data_map.items(): # for each section
			try:
				table += '.rrd'
				table = table.replace('/', '_') # some stat name include /
				entity_table = os.path.join(entity, table)
				handle = self.get_handle(entity_table)
				if handle:
					handle.update(timestamp, data)

			except Exception as e:
				print(e)
				print('on update table %s, %s (item: %d)' % (entity, table + '.rrd', len(data)))
				print(data)

		return True 
开发者ID:naver,项目名称:hubblemon,代码行数:18,代码来源:rrd_storage.py

示例3: update

# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import update [as 别名]
def update(self, *params):
		result = ''
		count = 0
		#print(params)

		if len(params) == 2 and isinstance(params[1], dict): # dict input
			data = params[1]
			keys = list(data.keys())
			keys.sort()

			result = '%d:' % params[0]

			count = len(keys)
			for key in keys:
				#print('update>> ' + key)
				result += '%d:' % data[key]

		else:
			count = len(params) - 1
			for p in params:
				result += '%d:' % p

		result = result[0:-1]
		
		#print ('## rrd update %s (%d): %s' % (self.filename, count, result))

		#ret = rrdtool.update(self.filename, result)
		try:
			self.fifo.write('update %s %s\n' % (self.filename, result))
		except Exception as e:
			print('## pipe write excpetion')
			print(e) 
开发者ID:naver,项目名称:hubblemon,代码行数:34,代码来源:rrd_storage.py

示例4: add_sample

# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import update [as 别名]
def add_sample(self, timestamp_epoch, cpu_usage, mem_usage):
        KOA_LOGGER.debug('[puller][sample] %s, %f, %f', self.dbname, cpu_usage, mem_usage)
        try:
            rrdtool.update(self.rrd_location, '%s:%s:%s' % (
                timestamp_epoch,
                round(cpu_usage, KOA_CONFIG.db_round_decimals),
                round(mem_usage, KOA_CONFIG.db_round_decimals)))
        except rrdtool.OperationalError as e:
            KOA_LOGGER.error("failing adding rrd sample (%s)", e) 
开发者ID:rchakode,项目名称:kube-opex-analytics,代码行数:11,代码来源:backend.py

示例5: update

# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import update [as 别名]
def update(self, filename, time, value):
        if value is None:
            return
        rrdtool.update(filename, "%d:%.4f" % (time, value)) 
开发者ID:20c,项目名称:vaping,代码行数:6,代码来源:rrd.py

示例6: get_all_table_list

# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import update [as 别名]
def get_all_table_list(self, prefix):
		table_list = []
		for entity in os.listdir(self.storage_path):
			entity_path = os.path.join(self.storage_path, entity)

			if os.path.isdir(entity_path):
				for table in os.listdir(entity_path):
					if table.startswith(prefix):
						table_list.append(entity + '/' + table)						

		return table_list

	# update data use member functions, it makes leak because rrdupdate has it 
开发者ID:naver,项目名称:hubblemon,代码行数:15,代码来源:rrd_storage.py

示例7: do_something

# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import update [as 别名]
def do_something(self):
		print('### do something invoked')
		start_timestamp = time.time()
		count = 0
		fifo = open(self.fifo_path, 'r')
		buffer = ''

		while True:
			before = time.time()
			tmp = fifo.read(4096)
			after = time.time()

			#print('>>> read: ', tmp)
			length = len(tmp)
			buffer += tmp

			while True:
				idx = buffer.find('\n')
				if idx < 0:
					break

				line = buffer[:idx]
				#print('>>> line: ', line)
				buffer = buffer[idx+1:]
				toks = line.split(' ', 2)

				if toks[0] == 'update':
					#print('update %s %s' % (toks[1], toks[2]))
					try:
						rrdtool.update(toks[1], toks[2])
					except rrdtool.OperationalError as e:
						#print(e)
						continue
					except Exception as e:
						print(e)
						continue
				else:
					pass

			if (after - before) > 0.1:
				time.sleep(1)

			count += 1
			if count > 50000:
				print('quit by overcounting, running sec: %d' % (time.time() - start_timestamp))
				sys.exit() 
开发者ID:naver,项目名称:hubblemon,代码行数:48,代码来源:rrd_storage.py


注:本文中的rrdtool.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。