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


Python collectd.warning方法代码示例

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


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

示例1: handle_config

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def handle_config(root):
    for child in root.children:
        instance_name = None

        if child.key == 'Instance':
            instance_name = child.values[0]
            url = None
            for ch2 in child.children:
                if ch2.key == 'URL':
                    url = ch2.values[0]
            if not url:
                collectd.warning('No URL found in dump1090 Instance ' + instance_name)
            else:
                collectd.register_read(callback=handle_read,
                                       data=(instance_name, urlparse.urlparse(url).hostname, url),
                                       name='dump1090.' + instance_name)
                collectd.register_read(callback=handle_read_1min,
                                       data=(instance_name, urlparse.urlparse(url).hostname, url),
                                       name='dump1090.' + instance_name + '.1min',
                                       interval=60)

        else:
            collectd.warning('Ignored config entry: ' + child.key) 
开发者ID:mutability,项目名称:dump1090-tools,代码行数:25,代码来源:dump1090.py

示例2: init_callback

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def init_callback(self):
        self.client = docker.Client(
            base_url=self.docker_url,
            version=DockerPlugin.MIN_DOCKER_API_VERSION)
        self.client.timeout = self.timeout

        # Check API version for stats endpoint support.
        try:
            version = self.client.version()['ApiVersion']
            if StrictVersion(version) < \
                    StrictVersion(DockerPlugin.MIN_DOCKER_API_VERSION):
                raise Exception
        except:
            collectd.warning(('Docker daemon at {url} does not '
                              'support container statistics!')
                             .format(url=self.docker_url))
            return False

        collectd.register_read(self.read_callback)
        collectd.info(('Collecting stats about Docker containers from {url} '
                       '(API version {version}; timeout: {timeout}s).')
                      .format(url=self.docker_url,
                              version=version,
                              timeout=self.timeout))
        return True 
开发者ID:lebauce,项目名称:docker-collectd-plugin,代码行数:27,代码来源:dockerplugin.py

示例3: configure_callback

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def configure_callback(conf):
    """Receive configuration"""

    host = "127.0.0.1"
    port = 5051

    for node in conf.children:
        if node.key == "Host":
            host = node.values[0]
        elif node.key == "Port":
            port = int(node.values[0])
        else:
            collectd.warning("mesos-tasks plugin: Unknown config key: %s." % node.key)

    CONFIGS.append({
        "host": host,
        "port": port,
    }) 
开发者ID:bobrik,项目名称:collectd-mesos-tasks,代码行数:20,代码来源:mesos-tasks.py

示例4: config

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def config(config_values):
    """
    A callback method that  loads information from the HaProxy collectd plugin config file.
    Args:
    config_values (collectd.Config): Object containing config values
    """

    global PROXY_MONITORS, HAPROXY_SOCKET
    PROXY_MONITORS = [ ]
    HAPROXY_SOCKET = DEFAULT_SOCKET
    for node in config_values.children:
        if node.key == "ProxyMonitor":
              PROXY_MONITORS.append(node.values[0].lower())
        elif  node.key == "Socket":
            HAPROXY_SOCKET = node.values[0]
        else:
            collectd.warning('Unknown config key: %s' % node.key)
    if not PROXY_MONITORS:
        PROXY_MONITORS += DEFAULT_PROXY_MONITORS
    PROXY_MONITORS = [ p.lower() for p in PROXY_MONITORS ] 
开发者ID:BeyondTheClouds,项目名称:enos,代码行数:22,代码来源:haproxy.py

示例5: read_swift_stat

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def read_swift_stat(self, data=None):
        starttime = time.time()

        stats = self.swift_conn.head_account()

        for m_instance, name in CollectdSwiftStat.SWIFT_STATS.iteritems():
            if m_instance in stats:
                metric = collectd.Values()
                metric.plugin = 'swift_stat'
                metric.interval = self.interval
                metric.type = 'gauge'
                metric.type_instance = '{}-{}'.format(self.prefix, name)
                metric.values = [stats[m_instance]]
                metric.dispatch()
            else:
                collectd.error(
                    'swift_stat: Can not find: {}'.format(m_instance))

        timediff = time.time() - starttime
        if timediff > self.interval:
            collectd.warning(
                'swift_stat: Took: {} > {}'
                .format(round(timediff, 2), self.interval)) 
开发者ID:cloud-bulldozer,项目名称:browbeat,代码行数:25,代码来源:collectd_swift_stat.py

示例6: config_callback

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def config_callback(self, conf):
        """Takes a collectd conf object and fills in the local config."""
        for node in conf.children:
            if node.key == "Verbose":
                if node.values[0] in ['True', 'true']:
                    self.verbose = True
            elif node.key == "Debug":
                if node.values[0] in ['True', 'true']:
                    self.debug = True
            elif node.key == "Prefix":
                self.prefix = node.values[0]
            elif node.key == 'Cluster':
                self.cluster = node.values[0]
            elif node.key == 'TestPool':
                self.testpool = node.values[0]
            elif node.key == 'Interval':
                self.interval = float(node.values[0])
            else:
                collectd.warning("%s: unknown config key: %s" % (self.prefix, node.key)) 
开发者ID:rochaporto,项目名称:collectd-ceph,代码行数:21,代码来源:base.py

示例7: dispatch_stat

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def dispatch_stat(result, name, key, conf):
    """Read a key from info response data and dispatch a value"""
    if result is None:
        collectd.warning('mesos-master plugin: Value not found for %s' % name)
        return
    estype = key.type
    value = result
    log_verbose(conf['verboseLogging'], 'Sending value[%s]: %s=%s for instance:%s' % (estype, name, value, conf['instance']))

    val = collectd.Values(plugin='mesos-master')
    val.type = estype
    val.type_instance = name
    val.values = [value]
    val.plugin_instance = conf['instance']
    # https://github.com/collectd/collectd/issues/716
    val.meta = {'0': True}
    val.dispatch() 
开发者ID:mantl,项目名称:mantl,代码行数:19,代码来源:mesos-master.py

示例8: dispatch_stat

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def dispatch_stat(result, name, key, conf):
    """Read a key from info response data and dispatch a value"""
    if result is None:
        collectd.warning('mesos-slave plugin: Value not found for %s' % name)
        return
    estype = key.type
    value = result
    log_verbose(conf['verboseLogging'], 'Sending value[%s]: %s=%s for instance:%s' % (estype, name, value, conf['instance']))

    val = collectd.Values(plugin='mesos-slave')
    val.type = estype
    val.type_instance = name
    val.values = [value]
    val.plugin_instance = conf['instance']
    # https://github.com/collectd/collectd/issues/716
    val.meta = {'0': True}
    val.dispatch() 
开发者ID:mantl,项目名称:mantl,代码行数:19,代码来源:mesos-agent.py

示例9: read

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def read(cls, container, stats, t):
        blkio_stats = stats['blkio_stats']
        for key, values in blkio_stats.items():
            # Block IO stats are reported by block device (with major/minor
            # numbers). We need to group and report the stats of each block
            # device independently.
            device_stats = {}
            for value in values:
                k = '{key}-{major}-{minor}'.format(key=key,
                                                   major=value['major'],
                                                   minor=value['minor'])
                if k not in device_stats:
                    device_stats[k] = []
                device_stats[k].append(value['value'])

            for type_instance, values in device_stats.items():
                if len(values) == 5:
                    cls.emit(container, 'blkio', values,
                             type_instance=type_instance, t=t)
                elif len(values) == 1:
                    # For some reason, some fields contains only one value and
                    # the 'op' field is empty. Need to investigate this
                    cls.emit(container, 'blkio.single', values,
                             type_instance=key, t=t)
                else:
                    collectd.warning(('Unexpected number of blkio stats for '
                                   'container {container}!')
                                  .format(container=_c(container))) 
开发者ID:lebauce,项目名称:docker-collectd-plugin,代码行数:30,代码来源:dockerplugin.py

示例10: run

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def run(self):
        collectd.info('Starting stats gathering for {container}.'
                      .format(container=_c(self._container)))

        failures = 0
        while not self.stop:
            try:

                if not self._stream:
                    if not self._feed:
                        self._feed = self._client.stats(self._container,
                                                        decode=True)
                    self._stats = self._feed.next()
                else:
                    self._stats = self._client.stats(self._container,
                                                     decode=True, stream=False)
                # Reset failure count on successfull read from the stats API.
                failures = 0
            except Exception, e:
                collectd.warning('Error reading stats from {container}: {msg}'
                                 .format(container=_c(self._container), msg=e))

                # If we encounter a failure, wait a second before retrying and
                # mark the failures. After three consecutive failures, we'll
                # stop the thread. If the container is still there, we'll spin
                # up a new stats gathering thread the next time read_callback()
                # gets called by CollectD.
                time.sleep(1)
                failures += 1
                if failures > 3:
                    self.stop = True

                # Marking the feed as dead so we'll attempt to recreate it and
                # survive transient Docker daemon errors/unavailabilities.
                self._feed = None 
开发者ID:lebauce,项目名称:docker-collectd-plugin,代码行数:37,代码来源:dockerplugin.py

示例11: read_callback

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def read_callback(self):
        containers = [c for c in self.client.containers()
                      if c['Status'].startswith('Up')]

        # Terminate stats gathering threads for containers that are not running
        # anymore.
        for cid in set(self.stats) - set(map(lambda c: c['Id'], containers)):
            self.stats[cid].stop = True
            del self.stats[cid]

        for container in containers:
            try:
                for name in container['Names']:
                    # Containers can be linked and the container name is not
                    # necessarly the first entry of the list
                    if not re.match("/.*/", name):
                        container['Name'] = name[1:]

                # Start a stats gathering thread if the container is new.
                if container['Id'] not in self.stats:
                    self.stats[container['Id']] = ContainerStats(container,
                                                                 self.client,
                                                                 self.stream)

                # Get and process stats from the container.
                stats = self.stats[container['Id']].stats
                t = stats['read']
                for klass in self.CLASSES:
                    klass.read(container, stats, t)
            except Exception, e:
                collectd.warning(('Error getting stats for container '
                                  '{container}: {msg}')
                                 .format(container=_c(container), msg=e))


# Command-line execution 
开发者ID:lebauce,项目名称:docker-collectd-plugin,代码行数:38,代码来源:dockerplugin.py

示例12: warning

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def warning(self, msg):
            print 'WARNING:', msg 
开发者ID:lebauce,项目名称:docker-collectd-plugin,代码行数:4,代码来源:dockerplugin.py

示例13: get_stats

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def get_stats():
    """
        Makes two calls to haproxy to fetch server info and server stats.
        Returns the dict containing metric name as the key and a tuple of metric value and the dict of dimensions if any
    """
    if HAPROXY_SOCKET is None:
        collectd.error("Socket configuration parameter is undefined. Couldn't get the stats")
        return
    stats = []
    haproxy = HAProxySocket(HAPROXY_SOCKET)

    try:
        server_info = haproxy.get_server_info()
        server_stats = haproxy.get_server_stats()
    except socket.error:
        collectd.warning(
            'status err Unable to connect to HAProxy socket at %s' %
            HAPROXY_SOCKET)
        return stats

    for key, val in server_info.iteritems():
        try:
            stats.append((key, int(val), None))
        except (TypeError, ValueError):
            pass
    for statdict in server_stats:
        if not (statdict['svname'].lower() in PROXY_MONITORS or statdict['pxname'].lower() in PROXY_MONITORS):
              continue
        for metricname, val in statdict.items():
            try:
                stats.append((metricname, int(val), {'proxy_name': statdict['pxname'], 'service_name': statdict['svname']}))
            except (TypeError, ValueError):
                pass
    return stats 
开发者ID:BeyondTheClouds,项目名称:enos,代码行数:36,代码来源:haproxy.py

示例14: collect_metrics

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def collect_metrics():
    collectd.debug('beginning collect_metrics')
    """
        A callback method that gets metrics from HAProxy and records them to collectd.
    """

    info = get_stats()

    if not info:
        collectd.warning('%s: No data received' % PLUGIN_NAME)
        return

    for metric_name, metric_value, dimensions in info:
        if not metric_name.lower() in METRIC_TYPES:
            collectd.debug("Metric %s is not in the metric types" % metric_name)
            continue

        translated_metric_name, val_type = METRIC_TYPES[metric_name.lower()]

        collectd.debug('Collecting {0}: {1}'.format(translated_metric_name, metric_value))
        datapoint = collectd.Values()
        datapoint.type = val_type
        datapoint.type_instance = translated_metric_name
        datapoint.plugin = PLUGIN_NAME
        if dimensions:
            datapoint.plugin_instance = _format_dimensions(dimensions)
        datapoint.values = (metric_value,)
        pprint_dict = {
                    'plugin': datapoint.plugin,
                    'plugin_instance': datapoint.plugin_instance,
                    'type': datapoint.type,
                    'type_instance': datapoint.type_instance,
                    'values': datapoint.values
                }
        collectd.debug(pprint.pformat(pprint_dict))
        datapoint.dispatch() 
开发者ID:BeyondTheClouds,项目名称:enos,代码行数:38,代码来源:haproxy.py

示例15: configure_callback

# 需要导入模块: import collectd [as 别名]
# 或者: from collectd import warning [as 别名]
def configure_callback(conf):
    """Received configuration information"""
    zk_hosts = ZK_HOSTS
    zk_port = ZK_PORT
    zk_instance = ZK_INSTANCE
    for node in conf.children:
        if node.key == "Hosts":
            if len(node.values[0]) > 0:
                zk_hosts = [host.strip() for host in node.values[0].split(",")]
            else:
                log(("ERROR: Invalid Hosts string. " "Using default of %s") % zk_hosts)
        elif node.key == "Port":
            if isinstance(node.values[0], (float, int)) and node.values[0] > 0:
                zk_port = node.values[0]
            else:
                log(("ERROR: Invalid Port number. " "Using default of %s") % zk_port)
        elif node.key == "Instance":
            if len(node.values[0]) > 0:
                zk_instance = node.values[0]
            else:
                log(("ERROR: Invalid Instance string. " "Using default of %s") % zk_instance)
        else:
            collectd.warning("zookeeper plugin: Unknown config key: %s." % node.key)
            continue

    config = {"hosts": zk_hosts, "port": zk_port, "instance": zk_instance}
    log("Configured with %s." % config)
    CONFIGS.append(config) 
开发者ID:signalfx,项目名称:collectd-zookeeper,代码行数:30,代码来源:zk-collectd.py


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