本文整理汇总了Python中pyrrd.rrd.RRD类的典型用法代码示例。如果您正苦于以下问题:Python RRD类的具体用法?Python RRD怎么用?Python RRD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RRD类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: create
def create(self):
"""
Creates a new RRD database
"""
ds1 = DS(dsName=self.value_name, dsType=self.type, heartbeat=self.heartbeat)
dss = [ds1]
rras = []
# 1 days-worth of n heartbeat samples --> 60/1 * 24
rra1 = RRA(cf="AVERAGE", xff=0.5, steps=1, rows=int(self.heartbeat / 1.0 * 24))
# 7 days-worth of n heartbeat samples --> 60/5 * 24 * 7
rra2 = RRA(cf="AVERAGE", xff=0.5, steps=5, rows=int(self.heartbeat / 5.0 * 24 * 7))
# 30 days-worth of n heartbeat samples --> 60/60 * 24 * 30
rra3 = RRA(cf="AVERAGE", xff=0.5, steps=60, rows=int(self.heartbeat / 60.0 * 24 * 30))
# 365 days worth of n heartbeat samples --> 60/120 * 24 * 365
rra4 = RRA(cf="AVERAGE", xff=0.5, steps=120, rows=int(self.heartbeat / 120.0 * 24 * 365))
# 10 years worth of n heartbeat samples --> 60/180 * 24 * 365 * 10
rra5 = RRA(cf="AVERAGE", xff=0.5, steps=180, rows=int(self.heartbeat / 180.0 * 24 * 365 * 10))
rras.extend([rra1, rra2, rra3, rra4, rra5])
rrd = RRD(
os.path.join("history/", "%s.rrd" % self.value_id), step=self.heartbeat, ds=dss, rra=rras, start=self.time
)
rrd.create(debug=False)
开发者ID:hadara,项目名称:HouseAgent,代码行数:25,代码来源:database.py
示例2: graph
def graph(req, rrd):
if os.path.isfile(rrdPath+rrd):
filename = rrd
rrd = RRD(rrdPath+rrd, mode='r')
info = rrd.getData()
info['filename'] = filename
return render_to_response('rrd/graph.html', {'info': info})
开发者ID:zuoxiaosheng,项目名称:DjangoRRD,代码行数:7,代码来源:views.py
示例3: RrdCreate
def RrdCreate(rrdfile):
'''Creates a RRD database.'''
dataSources = []
roundRobinArchives = []
dataSources.append(DataSource(
dsName='temperature', dsType='GAUGE', heartbeat=600,
minval=-50, maxval=100))
dataSources.append(DataSource(
dsName='humidity', dsType='GAUGE', heartbeat=600,
minval=0, maxval=100))
dataSources.append(DataSource(
dsName='mq9', dsType='GAUGE', heartbeat=600))
dataSources.append(DataSource(
dsName='dust_pc', dsType='GAUGE', heartbeat=600, minval=0))
dataSources.append(DataSource(
dsName='dust_raw', dsType='GAUGE', heartbeat=600))
# Keep all values for 10 days
roundRobinArchives.append(RRA(cf='AVERAGE', xff=0.5, steps=1,
rows=10*24*60))
# Keep 15-minute averages for one year days
roundRobinArchives.append(RRA(cf='AVERAGE', xff=0.5, steps=15,
rows=365*24*4))
# Keep 1-hour averages for 10 years
roundRobinArchives.append(RRA(cf='AVERAGE', xff=0.5, steps=60,
rows=10*365*24))
myRRD = RRD(
rrdfile, step=60, ds=dataSources, rra=roundRobinArchives)
myRRD.create()
开发者ID:ppetr,项目名称:particulate-matter-meter,代码行数:28,代码来源:collect.py
示例4: create
def create(namerrd,fieldname,starttime,typeofinfo):
try:
dataSources = []
roundRobinArchives = []
dataSources = get_ds(fieldname)
if typeofinfo == 'hardware' :
dict = {}
dict = config_info['hardware']
s = dict['func']
step = dict['step']
funcProfile = globals()[s]
roundRobinArchives = funcProfile()
elif typeofinfo == 'netusage':
dict = {}
dict = config_info['netusage']
s = dict['func']
step = int(dict['step'])
funcProfile = globals()[s]
roundRobinArchives = funcProfile()
myRRD = RRD(filename=namerrd,ds=dataSources, rra=roundRobinArchives, start=starttime,step=step)
myRRD.create()
return (True,'Create is successfull.')
except Exception,e:
return (False,str(e))
开发者ID:wfsiew,项目名称:proxynow5_proj,代码行数:30,代码来源:rrd_info.py
示例5: rrdtool_log
def rrdtool_log(self, count, category, key):
""" Log a message to an category's corresponding rrdtool databse """
# rrdtool doesn't like spaces
key = key.replace(' ', '_')
filename = rrd_dir + '/' + category + '/' + key + '.rrd'
if not category in rrd_categories:
raise ValueError, "Invalid category %s" % category
if not os.path.isfile(filename):
self.rrdtool_create(filename)
# rrdtool complains if you stuff data into a freshly created
# database less than one second after you created it. We could do a
# number of things to mitigate this:
# - sleep for 1 second here
# - return from this function and not log anything only on the
# first time we see a new data key (a new country, a new
# filename).
# - pre-create our databases at startup based on magical knowledge
# of what keys we're going to see coming over the AMQP line
#
# For now, we're just going to return.
return
# TODO -- Is this an expensive operation (opening the RRD)? Can we make
# this happen less often?
rrd = RRD(filename)
rrd.bufferValue(str(int(time.time())), str(count))
# This flushes the values to file.
# TODO -- Can we make this happen less often?
rrd.update()
开发者ID:lmacken,项目名称:narcissus,代码行数:35,代码来源:consumers.py
示例6: RRDB
class RRDB(object):
def __init__(self, filename):
self.db = RRD(filename)
def store(self, values):
self.db.bufferValue(int(time.time()), *values)
self.db.update()
@classmethod
def generate_archives(cls, step, rows=1440,
day_periods=[2, 14, 60, 180, 720]):
rras = []
for days in day_periods:
# how many primary data points (we get one each step)
# go into a consolidated data point
PDPs = 86400 * days / step / rows
rras.extend([
RRA(cf='AVERAGE', xff=0.1, rows=rows, steps=PDPs),
RRA(cf='MIN', xff=0.1, rows=rows, steps=PDPs),
RRA(cf='MAX', xff=0.1, rows=rows, steps=PDPs),
])
return rras
@classmethod
def create_db(cls):
raise NotImplementedError("Create DB is not implemented")
def graph(self, outfile):
raise NotImplementedError("graph method should be overriden")
开发者ID:rodolf0,项目名称:bs-bots,代码行数:30,代码来源:grumnus.py
示例7: load_rrd
def load_rrd(cls, filepath, options, default_options):
take_param = lambda k: (k, options[k]
if k in options else default_options.get(k))
kargs = dict(map(take_param, ['start', 'end', 'resolution', 'cf']))
rrd = RRD(filepath, mode='r', backend=bindings)
rrd_data = rrd.fetch(**kargs)
return rrd_data.get('42')
开发者ID:cstoku,项目名称:munin-custom-view,代码行数:7,代码来源:plugin.py
示例8: _rrdtool_log
def _rrdtool_log(self, count, filename):
""" Workhorse for rrdtool logging. Shouldn't be called directly. """
if not os.path.isfile(filename):
self.rrdtool_create(filename)
# rrdtool complains if you stuff data into a freshly created
# database less than one second after you created it. We could do a
# number of things to mitigate this:
# - sleep for 1 second here
# - return from this function and not log anything only on the
# first time we see a new data key (a new country, a new
# filename).
# - pre-create our databases at startup based on magical knowledge
# of what keys we're going to see coming over the AMQP line
#
# For now, we're just going to return.
return
# TODO -- Is this an expensive operation (opening the RRD)? Can we make
# this happen less often?
rrd = RRD(filename)
rrd.bufferValue(str(int(time.time())), str(count))
# This flushes the values to file.
# TODO -- Can we make this happen less often?
rrd.update()
开发者ID:ralphbean,项目名称:narcissus,代码行数:27,代码来源:consumers.py
示例9: init_rdd
def init_rdd(self):
# Initiates RRD-archive
# Creates the new one if absent or need to reset
filename = options.rrd_file
if not options.rrd_reset and access(filename, F_OK):
myRRD = RRD(filename)
else:
heartbeat=options.stats_period*2
dataSources = [
DataSource(dsName='agents_u', dsType='ABSOLUTE', heartbeat=heartbeat),
DataSource(dsName='t_unique', dsType='ABSOLUTE', heartbeat=heartbeat),
DataSource(dsName='t_started', dsType='ABSOLUTE', heartbeat=heartbeat),
DataSource(dsName='t_completed', dsType='ABSOLUTE', heartbeat=heartbeat),
DataSource(dsName='t_failed', dsType='ABSOLUTE', heartbeat=heartbeat),
DataSource(dsName='bytes', dsType='ABSOLUTE', heartbeat=heartbeat),
DataSource(dsName='cpu', dsType='DERIVE', heartbeat=heartbeat,minval=0),
DataSource(dsName='duration', dsType='ABSOLUTE', heartbeat=heartbeat),
DataSource(dsName='duration_avg', dsType='GAUGE', heartbeat=heartbeat),
]
roundRobinArchives = []
for (_steps, _rows) in options.rrd_rra:
roundRobinArchives.append(RRA(cf='AVERAGE', xff=0.5, steps=_steps, rows=_rows))
roundRobinArchives.append(RRA(cf='MAX', xff=0.5, steps=_steps, rows=_rows))
myRRD = RRD(filename, ds=dataSources, rra=roundRobinArchives, step=options.stats_period)
myRRD.create(debug=True)
return myRRD
开发者ID:Inexika,项目名称:MyNotes-Service,代码行数:26,代码来源:mn_stats.py
示例10: create
def create(self):
if os.path.exists(self.rrdfile):
self.rrd = RRD(self.rrdfile)
return
dss = []
ds1 = DS(dsName="requests", dsType="COUNTER", heartbeat=120, minval=0, maxval=100000000)
ds2 = DS(dsName="connections", dsType="ABSOLUTE", heartbeat=120, minval=0, maxval=60000)
ds3 = DS(dsName="reading", dsType="ABSOLUTE", heartbeat=120, minval=0, maxval=60000)
ds4 = DS(dsName="writing", dsType="ABSOLUTE", heartbeat=120, minval=0, maxval=60000)
ds5 = DS(dsName="waiting", dsType="ABSOLUTE", heartbeat=120, minval=0, maxval=60000)
dss.extend([ds1,ds2,ds3,ds4,ds5])
rras = []
rra1 = RRA(cf="AVERAGE", xff=0.5, steps=1, rows=2880)
rra2 = RRA(cf="AVERAGE", xff=0.5, steps=30, rows=672)
rra3 = RRA(cf="AVERAGE", xff=0.5, steps=120, rows=732)
rra4 = RRA(cf="AVERAGE", xff=0.5, steps=720, rows=1460)
rras.extend([rra1, rra2, rra3, rra4])
self.rrd = RRD(self.rrdfile, step=60, ds=dss, rra=rras)
self.rrd.create(debug=False)
time.sleep(2)
开发者ID:AmineAbidi1,项目名称:nginx-monitor,代码行数:25,代码来源:rrdcontroller.py
示例11: insert
def insert(self):
"""
Inserts new data in the RRD database
"""
rrd = RRD(os.path.join("history/", "%s.rrd" % self.value_id))
rrd.bufferValue(self.time, self.value_value)
rrd.update()
print self.time, self.value_value
开发者ID:rrada,项目名称:HouseAgent,代码行数:8,代码来源:database.py
示例12: data
def data(req, rrd, ds, rra):
if os.path.isfile(rrdPath+rrd):
rrd = RRD(rrdPath+rrd, mode='r')
info = rrd.getData()
step = info[rra]['step']
start = info['lastupdate'] - info[rra]['rows']*step
data = rrd.fetch(resolution=step, start=start, end=info['lastupdate'])
return HttpResponse(simplejson.dumps(data))
开发者ID:zuoxiaosheng,项目名称:DjangoRRD,代码行数:8,代码来源:views.py
示例13: main
def main(self, argv):
"""
Create an RRD file with values 0-9 entered at 1 second intervals from
1980-01-01 00:00:00 (the first date that rrdtool allows)
"""
from pyrrd.rrd import DataSource, RRA, RRD
start = int(datetime(1980, 1, 1, 0, 0).strftime('%s'))
dss = []
rras = []
filename = os.path.join(self.build_dir, 'test.rrd')
rows = 12
step = 10
dss.append(
DataSource(dsName='speed', dsType='GAUGE', heartbeat=2 * step))
rras.append(RRA(cf='AVERAGE', xff=0.5, steps=1, rows=rows))
rras.append(RRA(cf='AVERAGE', xff=0.5, steps=12, rows=rows))
my_rrd = RRD(filename, ds=dss, rra=rras, start=start, step=step)
my_rrd.create()
for i, t in enumerate(
range(start + step, start + step + (rows * step), step)):
self.log.debug(
'DATA: %s %s (%s)' % (t, i, datetime.fromtimestamp(t)))
my_rrd.bufferValue(t, i)
# Add further data 1 second later to demonstrate that the rrd
# lastupdatetime does not necessarily fall on a step boundary
t += 1
i += 1
self.log.debug('DATA: %s %s (%s)' % (t, i, datetime.fromtimestamp(t)))
my_rrd.bufferValue(t, i)
my_rrd.update()
开发者ID:binarytemple,项目名称:jarmon,代码行数:35,代码来源:commands.py
示例14: RrdProcess
def RrdProcess(rrdfile, samples):
'''Reads given samples and stores them in the RRD database.'''
# TODO: Optionally update the database only periodically.
rrd = RRD(rrdfile)
for sample in samples:
logging.debug("Saving sample %s", sample)
rrd.bufferValue(sample.time, sample.temperature, sample.humidity,
sample.mq9, sample.dust_pc, sample.dust_raw)
rrd.update(debug=True)
# Flush the print statements executed so far.
sys.stdout.flush()
开发者ID:ppetr,项目名称:particulate-matter-meter,代码行数:11,代码来源:collect.py
示例15: dumpfileinfo
def dumpfileinfo(self):
#rrds = os.walk(self.path)
mylist = []
for root, dir, files in os.walk(self.path):
for sfile in files:
filename = os.path.join(root, sfile)
subpath = filename[len(self.path):]
rrd = RRD(filename, mode='r')
info = rrd.getData()
for i in rrd.ds:
mylist.append((self,subpath,sfile,i.name),)
return mylist
开发者ID:misterstrogg,项目名称:pydRRAw,代码行数:12,代码来源:models.py
示例16: create_rrd
def create_rrd(filename, args):
dses = []
rras = []
for ds in args['ds']:
dses.append(
DataSource( dsName=ds, dsType=args['ds'][ds], heartbeat=600))
rras.append(RRA(cf='AVERAGE', xff=0.5, steps=1, rows=288))
rras.append(RRA(cf='AVERAGE', xff=0.5, steps=12, rows=744))
rras.append(RRA(cf='AVERAGE', xff=0.5, steps=24, rows=1116))
rras.append(RRA(cf='AVERAGE', xff=0.5, steps=48, rows=2191))
myRRD = RRD(
filename, ds=dses, rra=rras, start=int(now)-60)
myRRD.create()
开发者ID:tuxis-ie,项目名称:olb,代码行数:15,代码来源:olb-stats.py
示例17: create_db
def create_db(cls, filename, step, start,
interface_speeds={"eth0": 6 * 1024**2 / 8, # 6Mbit/s
"wlan0": 300 * 1024**2 / 8 }):
dss = []
for iface, speed in interface_speeds.items():
dss.extend([
DataSource(dsName="%s_out" % iface, dsType='COUNTER',
heartbeat=3*step, minval=0, maxval=speed),
DataSource(dsName="%s_in" % iface, dsType='COUNTER',
heartbeat=3*step, minval=0, maxval=speed)
])
db = RRD(filename, ds=dss, rra=cls.generate_archives(step),
start=start, step=step)
db.create()
return db
开发者ID:rodolf0,项目名称:bs-bots,代码行数:15,代码来源:grumnus.py
示例18: render_GET
def render_GET(self, request):
self.request = request
type = request.args["type"][0]
period = request.args["period"][0]
history_id = request.args["history_id"][0]
if type == "gauge":
rrd = RRD("history/%s.rrd" % history_id)
result = rrd.fetch(resolution=60, start=period, end='now')
clockfix = (datetime.datetime.now().hour - datetime.datetime.utcnow().hour) * 3600
series = [((ts + clockfix) * 1000, val) for ts, val in result["data"]]
return json.dumps(series)
开发者ID:hadara,项目名称:HouseAgent,代码行数:16,代码来源:web.py
示例19: rrdtool_create
def rrdtool_create(self, filename):
""" Create an rrdtool database if it doesn't exist """
# Create the directory if it doesn't exist.
directory = "/".join(filename.split("/")[:-1])
if not os.path.isdir(directory):
os.makedirs(directory)
# Step interval for Primary Data Points (pdp)
pdp_step = self.frequency.seconds + (self.frequency.days * 86400)
# Heartbeat can be 'whatev', but twice the pdpd_step is good
heartbeat = 2 * pdp_step
# We only keep a single simple datasource.
sources = [DataSource(dsName="sum", dsType="GAUGE", heartbeat=heartbeat)]
# TODO -- this should be a user-definable number. It is equivalent to
# "how many data points do I want to see on any one graph at any given
# time." The higher it is, the cooler your graphs look. The higher it
# is, the more disk space is consumed. The higher it is, the more
# memory is consumed client-side.
target_resolution = 60
# This function calculates how many PDP steps should be involved in the
# calculation of a single Consolidated Data Point (CDP).
cdp_steps = lambda tspan: (tspan / pdp_step) / target_resolution
# Just a lookup of how many seconds per 'timespan'
timespans = {"hour": 3600, "day": 86400, "week": 604800, "month": 2629744, "quarter": 7889231, "year": 31556926}
self.log.info("Building rrd %s. %i cdp steps per hour." % (filename, cdp_steps(timespans["hour"])))
# Here we build a series of round robin Archives of various resolutions
# and consolidation functions
archives = []
for consolidation_function in ["AVERAGE", "MAX"]:
archives += [
RRA(cf=consolidation_function, xff=0.5, rows=target_resolution, steps=cdp_steps(seconds_per_timespan))
for name, seconds_per_timespan in timespans.iteritems()
]
# Actually build the round robin database from the parameters we built
rrd = RRD(filename, start=int(time.time()), step=pdp_step, ds=sources, rra=archives)
rrd.create()
开发者ID:ralphbean,项目名称:narcissus,代码行数:45,代码来源:consumers.py
示例20: setUp
def setUp(self):
ds = [
DataSource(dsName="speed", dsType="COUNTER", heartbeat=600)]
rra = [
RRA(cf="AVERAGE", xff=0.5, steps=1, rows=24),
RRA(cf="AVERAGE", xff=0.5, steps=6, rows=10)]
self.rrdfile = tempfile.NamedTemporaryFile()
self.rrd = RRD(self.rrdfile.name, ds=ds, rra=rra, start=920804400)
self.rrd.create()
开发者ID:BnY,项目名称:HouseAgent,代码行数:9,代码来源:test_external.py
注:本文中的pyrrd.rrd.RRD类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论