當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。