本文整理汇总了Python中rrdtool.create方法的典型用法代码示例。如果您正苦于以下问题:Python rrdtool.create方法的具体用法?Python rrdtool.create怎么用?Python rrdtool.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rrdtool
的用法示例。
在下文中一共展示了rrdtool.create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import create [as 别名]
def create(self):
args = []
keys = list(self.DS.keys())
keys.sort()
for key in keys:
#print('>> ' + key)
args.append(self.DS[key])
args += self.RRA
print('## rrd create - %s(%d items), start: %d, step: %d' % (self.filename, len(self.DS), self.start, self.step))
print(args)
try:
rrdtool.create(self.filename, '--start', '%d' % self.start, '--step', '%d' % self.step, *args)
except rrdtool.OperationalError as e:
print(e)
示例2: create_rrd_file_if_not_exists
# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import create [as 别名]
def create_rrd_file_if_not_exists(self):
if not os.path.exists(self.rrd_location):
xfs = 2 * KOA_CONFIG.polling_interval_sec
rrdtool.create(self.rrd_location,
"--step", str(KOA_CONFIG.polling_interval_sec),
"--start", "0",
str('DS:cpu_usage:GAUGE:%d:U:U' % xfs),
str('DS:mem_usage:GAUGE:%d:U:U' % xfs),
"RRA:AVERAGE:0.5:1:4032",
"RRA:AVERAGE:0.5:12:8880")
示例3: create
# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import create [as 别名]
def create(self, filename):
rrdtool.create(
filename,
"--step",
str(self.step),
self.data_sources,
*self.archives
)
示例4: create_rrd_unless_exists
# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import create [as 别名]
def create_rrd_unless_exists(filename):
if os.path.isfile(filename):
return
print("Creating RRD database file %s" % filename)
rrdtool.create(
filename,
'--step', '300',
'DS:temp:GAUGE:900:-100:100',
'RRA:AVERAGE:0.5:2:525600'
)
示例5: create_data
# 需要导入模块: import rrdtool [as 别名]
# 或者: from rrdtool import create [as 别名]
def create_data(self, entity, name_data_map):
entity_path = os.path.join(self.storage_path, entity)
if not os.path.exists(entity_path): # not exists, create folder
os.makedirs(entity_path)
rra_list = []
if 'RRA' in name_data_map:
rra_list = name_data_map['RRA']
for table, data in name_data_map.items(): # for each section
if table == 'RRA': # already read
continue
table += '.rrd'
table = table.replace('/', '_') # some stat name include /
entity_table = os.path.join(entity_path, table)
if not os.path.exists(entity_table):
handle = rrd_handle(entity_table, None)
assert (isinstance(data, list))
for item in data:
handle.put_ds(*item)
for rra in rra_list:
handle.put_rra(*rra)
handle.create()
return True