當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。