• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rrdtool.info函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: isVMDead

def isVMDead(hostname):
    #assuming that it is a storage VM
    dead=False
    path_id=get_host_path_id(hostname)
    try:
        #try two files
        rrd_file=config['rrd_path_vms_prefix']+"/"+path_id+"/"+config['vm_bytes_out_filename']
        dead=((long(time.time())-(rrdtool.info(rrd_file)["last_update"]))>DEATH_TIME)
        if not dead:
            rrd_file=config['rrd_path_vms_prefix']+"/"+path_id+"/"+config['load_one_filename']
            dead=((long(time.time())-(rrdtool.info(rrd_file)["last_update"]))>DEATH_TIME)
    except:
        dead=True
    if dead:
        return True
    else:
        #supposing now that it is a workload VM
        try:
            rrd_file=config['rrd_path_workload_hosts_prefix']+"/"+path_id+"/"+config['slo_throughput_filename']
            return ((long(time.time())-(rrdtool.info(rrd_file)["last_update"]))>DEATH_TIME)
        except:
            dead=True
    if dead:
        return True
    else:
        #supposing now that it is a monitor VM
        try:
            rrd_file=config['rrd_path_monitor_prefix']+"/"+path_id+"/"+config['load_one_filename']
            return ((long(time.time())-(rrdtool.info(rrd_file)["last_update"]))>DEATH_TIME)
        except:
            return True
开发者ID:guthemberg,项目名称:tejo,代码行数:31,代码来源:liveness.py


示例2: run

	def run(self,ctx,**k):
		event = self.params(ctx)
		if len(event) < 3:
			raise SyntaxError(u'Usage: var rrd ‹variable› ‹item› ‹name…›')
		s = RRDs[Name(*event[2:])]
		try:
			setattr(self.parent.ctx,event[0],rrdtool.info(s.upath)["ds"][s.dataset][event[1]])
		except KeyError:
			setattr(self.parent.ctx,event[0],rrdtool.info(s.upath)["ds[%s].%s" % (s.dataset,event[1])])
开发者ID:pombreda,项目名称:MoaT,代码行数:9,代码来源:rrd.py


示例3: setupRRD

def setupRRD(filename, data_sources, consolidation="AVERAGE"):
    step = 20
    try:
        RRD.info(filename)
    except RRD.error:
        RRD.create( filename,
                    '--start', str(long(time.time())),
                    '--step', str(step),
                    data_sources,
                    'RRA:%s:0.5:1:8640' % (consolidation),
                    'RRA:%s:0.5:3:10080' % (consolidation),
                    'RRA:%s:0.5:180:43830' % (consolidation))
开发者ID:ebilling,项目名称:pi-pool-control,代码行数:12,代码来源:poold.py


示例4: list

	def list(self):
		yield ("name",self.name)
		yield ("file",self.path)
		yield ("dataset",self.dataset)
		try:
			for k,v in rrdtool.info(self.upath)["ds"][self.udataset].iteritems():
				yield (k,v)
		except KeyError:
			s="ds[%s]." % (self.udataset)
			d=rrdtool.info(self.upath)
			# mainly for testing
			for k in sorted(x for x in d.keys() if x.startswith(s)):
				yield (k[len(s):],d[k])
开发者ID:pombreda,项目名称:MoaT,代码行数:13,代码来源:rrd.py


示例5: isPeerAlive

def isPeerAlive(path_to_rrd,rrd_filename,peer):
    path_id=get_host_path_id(peer)    
    try:
        rrd_file=path_to_rrd+"/"+path_id+"/"+rrd_filename
        return ((long(time.time())-(rrdtool.info(rrd_file)["last_update"]))<=ALIVE_TIME)
    except:
        return False
开发者ID:guthemberg,项目名称:tejo,代码行数:7,代码来源:save_vm_slo_measurements.py


示例6: getLoadWeek

def getLoadWeek(server_id):
    ''' get server current load and one week load'''
    import rrdtool
    try:
        rrdPath = s_service.objects.get(server__id = server_id,category__title__contains = "Perfmon").rrd.path()
    except:
        return "</td><td>"
    
    info = rrdtool.info(rrdPath)
    last_update = str(info["last_update"])
    current = rrdtool.fetch(rrdPath, "-s", last_update + "-604801", "-e", last_update, "LAST")
    load = "";ls = [];loadAvg = ""
    for i in range(len(current[1])):
        if current[1][i] == "load":
            for l in current[2][-10:]:
                if l[i] != None and l[i] != "nan":
                    load = l[i]
            for l in current[2]:
                try:
                    ls.append(float(l[i]))
                except:
                    pass
    if load == "nan":load = ""
    try:
        load = int(load)
    except:
        pass
    if ls != []:
        loadAvg = str(sum(ls)/len(ls))[:5]
    return str(load)+"</td><td>"+loadAvg
开发者ID:Wuvist,项目名称:angelbot,代码行数:30,代码来源:cmdb_extras.py


示例7: rrdupdate

def rrdupdate(owdata):
    if config.rrdenable:
	stime = int(time.mktime(time.localtime()))
	path = config.rrdpath
	step = 300
	hb = 3600
	xff = 0.5
	HOUR = 3600
	YEAR = 31536000
	steps1 = 1
	rows1 = YEAR // step
	for sensor in owdata:
	    (value, timestamp) = owdata[sensor]
	    if value == config.owfail:
		continue
	    rrdfile = '%s/%s.rrd' % (path, sensor.upper())
	    if not os.path.isfile(rrdfile):
		try:
		    rrdtool.create(rrdfile, '--step', '%d' % step,
			'DS:data:GAUGE:%d:U:U' % hb,
			'RRA:AVERAGE:%d:%d:%d' % (xff, steps1, rows1))
		except rrdtool.error, e:
		    logger.warning(e)
	        logger.debug("RRD %s created" % sensor)
	    info = rrdtool.info(rrdfile)
	    if ((stime - info['last_update']) > step):
	        try:
		    rrdtool.update(rrdfile,'%s:%s' % (timestamp, value))
		except rrdtool.error, e:
		    logger.warning(e)
	        logger.debug("RRD %s updated" % sensor)
开发者ID:4mig4,项目名称:modbus,代码行数:31,代码来源:modbus.py


示例8: show_widget_with_current_and_past_value

def show_widget_with_current_and_past_value(widget):
    rrd_path = widget.rrd.path()
    info = rrdtool.info(rrd_path)
    #last_update = datetime.datetime.fromtimestamp(info["last_update"]).strftime("%m-%d %H:%M")
    last_update = str(info["last_update"])
    
    current = rrdtool.fetch(rrd_path, "-s", last_update + "-1", "-e", "s+0", "LAST")  
    yesterday = rrdtool.fetch(rrd_path, "-s", last_update + "-1d", "-e", "s+1", "LAST")
    lastweek = rrdtool.fetch(rrd_path, "-s", last_update + "-1w", "-e", "s+1", "LAST")
    
    current_value = current[2][0][0]
    field_def = None
    if widget.data_def:
        try:
            data_def = eval(widget.data_def.replace("\n", "").replace("\r", ""))
            ds = (current[1][0])
            if data_def.has_key(ds):
                field_def = data_def[ds]
                try:
                    data_rrd = rrdtool.fetch(rrd_path, "-s", str(int(last_update)-int(field_def[3]) * 60), "-e", last_update + "-1", "LAST")
                    data_rrd = map(lambda x:x[0],data_rrd[2])
                    current_value = format_value_def(field_def,data_rrd)
                except:
                    current_value = format_value(field_def, current_value)
            else:
                current_value = get_last_value(current)
        except:
            raise
            return widget.data_def
    else:
        current_value = get_last_value(current)
    
    return "<td>" + "</td><td>".join([current_value, get_last_value(yesterday, field_def) , get_last_value(lastweek, field_def)]) + "</td>"
开发者ID:Wuvist,项目名称:angelbot,代码行数:33,代码来源:rrd_extras.py


示例9: getPeriodCF

    def getPeriodCF(self, start):
        """
        Retourne la fonction de calcul à appliquer
        pour la période commençant à la date donnée.

        @param start: Date de début de la période considérée.
        @type start: C{int}
        @return: Fonction de calcul à utiliser ("LAST" ou "AVERAGE").
        @rtype: C{str}
        """
        infos = rrdtool.info(self.filename)
        step = infos['step']
        now = time.mktime(datetime.datetime.utcnow().timetuple())
        i = 0
        rras = []
        while ('rra[%d].cf' % i) in infos:
            # Date de la 1ère valeur possible dans ce RRA.
            first = now - infos['rra[%d].rows' % i] * step
            # Si la date demandée n'appartient pas
            # à ce RRA, on l'ignore.
            if start < first:
                i += 1
                continue

            rras.append({
                'cf': infos['rra[%d].cf' % i],
                'first': first,
            })
            i += 1
        # On trie les RRA restants par granularité décroissante.
        rras.sort(cmp=lambda a, b: int(b['first'] - a['first']))
        if not rras:
            return "AVERAGE"
        return rras[0]['cf']
开发者ID:vigilo,项目名称:vigirrd,代码行数:34,代码来源:rrd.py


示例10: getDataSources

 def getDataSources(self):
   try:
     info = rrdtool.info(self.fs_path)
     return [RRDDataSource(self, source) for source in info['ds']]
   except:
     raise
     return []
开发者ID:ZachGoldberg,项目名称:Graphite,代码行数:7,代码来源:storage.py


示例11: info

    def info(self, context, target=None):
        # Figure out the target.
        if target == None:
            target = socket.getfqdn()
        rrdpath = os.path.join(FLAGS.canary_rrdpath, target)

        # Grab available metrics.
        available = glob.glob(os.path.join(rrdpath, "*/*.rrd"))
        metrics = {}

        for filename in available:
            # NOTE: Not sure quite why, but it seems like
            # the rrdtool commands below barf unless they
            # this happens -- maybe barfing on unicode?
            filename = str(filename)

            m = re.match("^%s/([^\/-]+)(-([^\/]+))?/([^\.]+)\.rrd$" % rrdpath, filename)
            if m:
                plugin = m.group(1)
                unit = m.group(3)
                key = m.group(4)

                # NOTE: At this point we construct a metric name that is
                # equivilant to how we deconstruct the name above. It's
                # important that these two operations are symmetric for
                # the sake of a user's sanity.
                if unit:
                    metric = "%s[%s].%s" % (plugin, unit, key)
                else:
                    metric = "%s.%s" % (plugin, key)
                if not (metric in metrics):
                    metrics[metric] = {}

                metrics[metric]["from_time"] = rrdtool.first(filename)
                metrics[metric]["to_time"] = rrdtool.last(filename)

                step = 1
                pdps = []
                cfs = []
                for (k, v) in rrdtool.info(filename).items():
                    if re.match("^step$", k):
                        step = int(v)
                        continue
                    elif re.match("^rra\[\d+\]\.pdp_per_row$", k):
                        pdps.append(int(v))
                        continue
                    elif re.match("^rra\[\d+\]\.cf", k):
                        cfs.append(v)
                        continue

                pdps = list(set(pdps))
                cfs = list(set(cfs))
                cfs.sort()
                resolutions = map(lambda x: step * x, pdps)
                resolutions.sort()

                metrics[metric]["cfs"] = cfs
                metrics[metric]["resolutions"] = resolutions

        return metrics
开发者ID:rmahmood,项目名称:canary,代码行数:60,代码来源:manager.py


示例12: TuneHoltData

    def TuneHoltData(self, dp):
        # Alpha
        rrdtool.tune(self.context().path(dp),'--alpha',str(self.alpha))

        # Beta
        rrdtool.tune(self.context().path(dp),'--beta',str(self.beta))

        # Gamma
        rrdtool.tune(self.context().path(dp),'--gamma',str(self.gamma))
        rrdtool.tune(self.context().path(dp),'--gamma-deviation',str(self.gamma))

        # Delta
        rrdtool.tune(self.context().path(dp),'--deltapos',str(self.delta))
        rrdtool.tune(self.context().path(dp),'--deltaneg',str(self.delta))


        # Check that these actually changed otherwise we will reset
        # violation counts to 0
        data = rrdtool.info(self.context().path(dp))
        rrasearch = re.compile('^rra\[(\d+)\]\.(\S+)')
        sorted_keys=data.keys()
        sorted_keys.sort()
        for key in sorted_keys:
            value=data[key]
            rra_match=rrasearch.search(key)
            if rra_match:
                rranum,rraprop=rra_match.groups()

                # Failure Threshold
                if rraprop == 'failure_threshold' and value != self.threshold:
                    rrdtool.tune(self.context().path(dp),'--failure-threshold',str(self.threshold))

                # Window Length
                if rraprop == 'window_length' and value != self.window:
                    rrdtool.tune(self.context().path(dp),'--window-length',str(self.window))
开发者ID:alecsandrb,项目名称:Community-Zenpacks,代码行数:35,代码来源:PredictiveThreshold.py


示例13: listSources

def listSources():
  hwid = request.args.get('hwid')
  device = ceresdb.devices.find_one({'hwid' : hwid})
  if device['username'] != session['username']:
    flash('Wrong username [' + session['username'] + '] for device [' + hwid + ']')
    return redirect(url_for('myceres'))

  info = rrdtool.info(str(device['file']))
  step = int(info['step'])

  # Pull out all of the source names (e.g. temperature, light, etc..)
  r = re.compile('ds\[(.*)\]\.type')
  sourcenames = [match.group(1) for match in [r.match(key) for key in info if r.match(key)]]

  RRAs = []
  # Extract the info about the RRAs
  r = re.compile('rra\[(.*)\]\.cf')
  for RRAid in sorted([int(match.group(1)) for match in [r.match(key) for key in info if r.match(key)]]):
    rra = 'rra['+str(RRAid)+']'

    if info[rra + '.cf'] != 'AVERAGE':
      continue

    RRAs.append({
        'resolution' : info[rra + '.pdp_per_row'] * step,
        'totaltime'  : info[rra + '.pdp_per_row'] * step * info[rra + '.rows']
    })

  RRAs = sorted(RRAs, key=lambda k: k['resolution'])
  return jsonify(data={'RRAs' : RRAs, 'sources' : sourcenames})
开发者ID:randvoorhies,项目名称:Ceres,代码行数:30,代码来源:DisplayServer.py


示例14: show_widget_with_current_value

def show_widget_with_current_value(widget):
    rrd_path = widget.rrd.path()
    info = rrdtool.info(rrd_path)
    last_update = str(info["last_update"])
    
    current = rrdtool.fetch(rrd_path, "-s", last_update + "-1", "-e", "s+0", "LAST")
    
    if widget.data_def:
        try:
            data_def = eval(widget.data_def.replace("\n", "").replace("\r", ""))
            data = list(current[2][0])
            ds = current[1]
            for i in range(0, len(ds)):
                if data_def.has_key(ds[i]):
                    field_def = data_def[ds[i]]
                    try:
                        data_rrd = rrdtool.fetch(rrd_path, "-s", str(int(last_update)-int(field_def[3]) * 60), "-e", last_update + "-1", "LAST")
                        data_rrd = map(lambda x:x[i],data_rrd[2])
                        data[i] = format_value_def(field_def,data_rrd)
                    except:
                        data[i] = format_value(field_def, data[i])
                else:
                    data[i] = str(data[i])
        except:
            return widget.data_def
            #raise
    else:
        data = map(str, current[2][0])
    
    #return check_date(info) + get_last_value(current) + "</td>"
    
    return "<td>" + "</td><td>".join(data) + "</td>"
开发者ID:Wuvist,项目名称:angelbot,代码行数:32,代码来源:rrd_extras.py


示例15: rrd_info

def rrd_info(rrd_file, raw=False):
    """ 
    Intended use is from shell. If you want the whole dict returned by
    rrdtool.info, set raw to true.
    """
    file_info = rrdtool.info(rrd_file)

    if raw:
        return file_info

    if not file_info.has_key('ds'):
        #=======================================================================
        # In version 1.3 the output from info is totally different. We just 
        # print a key/value output.
        #=======================================================================
        for key in sorted(file_info.keys()):
            print "%s: %s" % (key, file_info[key])
        return

    print "%s last updated %s" % (file_info['filename'],
                                 time.ctime(file_info['last_update']))
    print "Datasources (datasource: datasourcename):"
    for datasource in sorted(file_info['ds'].items()):
        print "  %s: %s" % (datasource[0], datasource[1]['ds_name'])

    print "RRA's (Step = %s):" % (file_info['step'])

    for rra in file_info['rra']:
        print "  %s: %s/%s" % (rra['cf'], rra['pdp_per_row'], rra['rows'])
开发者ID:alexanderfefelov,项目名称:nav,代码行数:29,代码来源:rrdtool_utils.py


示例16: getDataSources

 def getDataSources(self):
   info = rrdtool.info(self.fs_path)
   if 'ds' in info:
     return [RRDDataSource(self, datasource_name) for datasource_name in info['ds']]
   else:
     ds_keys = [ key for key in info if key.startswith('ds[') ]
     datasources = set( key[3:].split(']')[0] for key in ds_keys )
     return [ RRDDataSource(self, ds) for ds in datasources ]
开发者ID:fatihzkaratana,项目名称:graphite,代码行数:8,代码来源:storage.py


示例17: isPeerDead

def isPeerDead(path_to_rrd,rrd_filename,peer):
    #assuming that it is a storage VM
    path_id=get_host_path_id(peer)
    try:
        rrd_file=path_to_rrd+"/"+path_id+"/"+rrd_filename
        return ((long(time.time())-(rrdtool.info(rrd_file)["last_update"]))>DEATH_TIME)
    except:
        return True
开发者ID:guthemberg,项目名称:tejo,代码行数:8,代码来源:save_vm_slo_measurements.py


示例18: show_widget_header

def show_widget_header(widget):
    rrd_path = widget.rrd.path()
    info = rrdtool.info(rrd_path)
    last_update = str(info["last_update"])

    current = rrdtool.fetch(rrd_path, "-s", last_update, "-e", "s+1", "LAST")
    titles = map(lambda x: x.replace("_", " "), current[1])
    return "<th>" + "</th><th>".join(titles) + "</th>"
开发者ID:Wuvist,项目名称:angelbot,代码行数:8,代码来源:rrd_extras.py


示例19: build_from_file

    def build_from_file(self, fname):
        """
        Build RRD info from the given filename
        """
        info = rrdtool.info(fname)

        for (key, val) in info.iteritems():
            #ignore RRAs, and only examine ds[***] entries
            self.push_item(key, val)
开发者ID:cmiller8,项目名称:rainmon,代码行数:9,代码来源:rrdindex.py


示例20: get_datasources

    def get_datasources(fs_path):
        info = rrdtool.info(fs_path)

        if "ds" in info:
            return [datasource_name for datasource_name in info["ds"]]
        else:
            ds_keys = [key for key in info if key.startswith("ds[")]
            datasources = set(key[3:].split("]")[0] for key in ds_keys)
            return list(datasources)
开发者ID:oibe,项目名称:graphite-web,代码行数:9,代码来源:readers.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rrdtool.update函数代码示例发布时间:2022-05-26
下一篇:
Python rrdtool.graph函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap