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


Python rrd.RRD类代码示例

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


在下文中一共展示了RRD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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