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


Python RRD.fetch方法代码示例

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


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

示例1: load_rrd

# 需要导入模块: from pyrrd.rrd import RRD [as 别名]
# 或者: from pyrrd.rrd.RRD import fetch [as 别名]
 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,代码行数:9,代码来源:plugin.py

示例2: data

# 需要导入模块: from pyrrd.rrd import RRD [as 别名]
# 或者: from pyrrd.rrd.RRD import fetch [as 别名]
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,代码行数:10,代码来源:views.py

示例3: render_GET

# 需要导入模块: from pyrrd.rrd import RRD [as 别名]
# 或者: from pyrrd.rrd.RRD import fetch [as 别名]
 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,代码行数:18,代码来源:web.py

示例4: fetch

# 需要导入模块: from pyrrd.rrd import RRD [as 别名]
# 或者: from pyrrd.rrd.RRD import fetch [as 别名]
 def fetch(self, start=None, end=None, resolution=None):
     """
     Fetch data from the RRD database.
     """
     rrd = RRD("history/108732.rrd")
     print rrd.fetch(resolution=300, start='-1h', end=self.epoch_now())         
开发者ID:rrada,项目名称:HouseAgent,代码行数:8,代码来源:database.py

示例5: RRDManip

# 需要导入模块: from pyrrd.rrd import RRD [as 别名]
# 或者: from pyrrd.rrd.RRD import fetch [as 别名]
class RRDManip(object):

    def __init__(self, filename, step=None,
                 dataSources=None, roundRobinArchives=None):
        """
        实例化 RRDManip 类对象。

        :param filename: the name of the RRD you to manipulative
        :param dataSources: 相关的 data Source 队列
        :param roundRobinArchives: 相关的 rra 队列
        """
        if not isinstance(dataSources, list) and \
                not isinstance(dataSources, tuple):
            dataSources = [dataSources]
        if not isinstance(roundRobinArchives, list) and \
                not isinstance(roundRobinArchives, tuple):
            roundRobinArchives = [roundRobinArchives]

        self.dataSources = dataSources
        self.roundRobinArchives = roundRobinArchives
        self.filename = filename
        self.step = step
        self.rrd = None

    def ensure_rrd(self):
        """
        Ensures that an RRD file is created.
        """
        if os.path.isfile(self.filename):
            # the rrd file alread exist
            self.rrd = RRD(self.filename)
        else:
            self.create_rrd()

    def create_rrd(self):
        """
        Creates an RRD file.
        """
        dataSources = [DataSource(**ds) for ds in self.dataSources]
        roundRobinArchives = [RRA(**rra) for rra in self.roundRobinArchives]
        # start 时间设定为当前时间的一天前,86400 即一天内包含的秒数
        past_one_day = int(time.time()) - 86400
        self.rrd = RRD(self.filename, start=past_one_day, step=self.step,
                       ds=dataSources, rra=roundRobinArchives)
        self.rrd.create()

    def update(self, timestamp, values):
        """
        Feeds data values into an RRD.
        """
        timestamp = int(timestamp)
        if not isinstance(values, list) and not isinstance(values, tuple):
            values = [values]
        self.rrd.bufferValue(timestamp, *values)
        try:
            self.rrd.update()
        except:
            # 防止 脏数据 污染 update vslues
            self.rrd.values = []

    def fetch(self, cf='AVERAGE', resolution=None, start=None, end=None, returnStyle="ds"):
        """
        Fetch data values from an RRD.

        :param returnStyle: 指定返回的数据格式,包括有'ds' 和 'time'
        """
        return self.rrd.fetch(cf, resolution, start, end, returnStyle)
开发者ID:JasonLai256,项目名称:rrdmanip,代码行数:69,代码来源:manipRRD.py


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