本文整理匯總了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