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


Python Graph.add_data方法代码示例

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


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

示例1: _create_graphs

# 需要导入模块: from graphs import Graph [as 别名]
# 或者: from graphs.Graph import add_data [as 别名]
	def _create_graphs(self):
		# opcode graph
		opcode_graph = Multigraph("%sopcodes" % self.mg_prefix, 'OPCodes', category='bind9')
		for opcode, count in self.opcodes.iteritems():
			opcode_graph.add_row('opcode_%s' % opcode, opcode, type='COUNTER')
			opcode_graph.add_data('opcode_%s' % opcode, count)

		yield opcode_graph


		# server statistics graph
		nsstat_graph = Multigraph("%snsstat" % self.mg_prefix, 'Server Statistics', category='bind9',
								args="-l 0", vlabel='Usage (Queries / Second)')
		for k, v in sorted(self.nsstat.iteritems()):
			nsstat_graph.add_row(k, k, 'DERIVE', 'AREASTACK')
			nsstat_graph.add_data(k, v)

		yield nsstat_graph


		# socket statistics graph
		sockstat_graph = Multigraph("%ssockstat" % self.mg_prefix, 'Socket I/O Statistics', category='bind9',
								args="-l 0", vlabel='Derived Count')
		for k, v in sorted(self.sockstat.iteritems()):
			sockstat_graph.add_row(k, k, type='DERIVE', draw='AREASTACK', min=0)
			sockstat_graph.add_data(k, v)
		yield sockstat_graph


		# view graphs
		resq_graph = Multigraph("%sresqtypes" % self.mg_prefix, 'Queries', category='bind9',
							args='-l 0', vlabel="Queries / second")
		resstat_graph = Multigraph("%sresstat" % self.mg_prefix, 'Resolver statistics', category='bind9',
							args='-l 0', vlabel="Queries / second")
		cachedb_graph = Multigraph("%scachedb" % self.mg_prefix, 'CacheDB', category='bind9',
							args='-l 0', vlabel="Count")

		# sum the totals over all views for the overview graph
		resq_totals = self._sum_dicts([x[1]['resqtype'] for x in self.views])
		resstat_totals = self._sum_dicts([x[1]['resstats'] for x in self.views])
		cachedb_totals = self._sum_dicts([x[1]['cachedb'] for x in self.views])

		# finish overview graphs
		for k, v in sorted(resq_totals.iteritems()):
			resq_graph.add_row(k, k, type='DERIVE', draw='AREASTACK', min=0)
			resq_graph.add_data(k, v)

		for k, v in sorted(resstat_totals.iteritems()):
			resstat_graph.add_row(k, k, type='DERIVE', draw='AREASTACK', min=0)
			resstat_graph.add_data(k, v)

		for k, v in sorted(cachedb_totals.iteritems()):
			cachedb_graph.add_row(k, k, type='DERIVE', draw='AREASTACK', min=0)
			cachedb_graph.add_data(k, v)

		for view_name, stats in self.views:
			q_graph = Graph("Queries for view '%s'" % view_name, category='bind9', args='-l 0')
			for k, v in sorted(stats['resqtype'].iteritems()):
				q_graph.add_row(k, k, type='DERIVE', draw='AREASTACK')
				q_graph.add_data(k, v)
			resq_graph.add_subgraph("%sresqtypes.%s" % (self.mg_prefix, view_name), q_graph)

			r_graph = Graph("Resolver statistics for view '%s'" % view_name, category='bind9', args='-l 0')
			for k, v in sorted(stats['resstats'].iteritems()):
				r_graph.add_row(k, k, type='DERIVE', draw='AREASTACK')
				r_graph.add_data(k, v)
			resq_graph.add_subgraph("%sresstat.%s" % (self.mg_prefix, view_name), r_graph)

			cdb_graph = Graph("Cache DB for view '%s'" % view_name, category='bind9', args='-l 0')
			for k, v in sorted(stats['cachedb'].iteritems()):
				cdb_graph.add_row(k, k, type='DERIVE', draw='AREASTACK')
				cdb_graph.add_data(k, v)
			cachedb_graph.add_subgraph("%scachedb.%s" % (self.mg_prefix, view_name), cdb_graph)

		yield resq_graph
		yield resstat_graph
		yield cachedb_graph

		# memory graph with total and inuse values
		mem_graph = Multigraph("%smemory" % self.mg_prefix, 'Memory usage', category='bind9',
							args="-l 0 --base 1024", vlabel="Memory in use")
		for k, v in self.memory:
			if k == "TotalUse":
				mem_graph.add_row(k, k, draw='LINE1', type='DERIVE', min=0)
			else:
				mem_graph.add_row(k, k, draw='AREASTACK')
			mem_graph.add_data(k, v)
		yield mem_graph
开发者ID:ercpe,项目名称:munin-plugins,代码行数:90,代码来源:bind9_statchannel.py


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