當前位置: 首頁>>代碼示例>>Python>>正文


Python collectd.error方法代碼示例

本文整理匯總了Python中collectd.error方法的典型用法代碼示例。如果您正苦於以下問題:Python collectd.error方法的具體用法?Python collectd.error怎麽用?Python collectd.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在collectd的用法示例。


在下文中一共展示了collectd.error方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: read

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def read(self):
        try:
            params = {"filters": '{"name": ["rebellion.service"]}'}
            containers = requests.get(
                "{}/containers/json".format(self.DOCKER_URL_PREFIX),
                params=params,
                timeout=self.TIMEOUT).json()
            metric = collectd.Values()
            metric.plugin = self.NAME
            metric.plugin_instance = "rebellion_service"
            metric.type = "val"
            metric.values = [len(containers)]
            metric.dispatch()
        except Exception as e:
            collectd.error(
                "rebellion_monitor.read() failed, exception: {}".format(e)) 
開發者ID:laincloud,項目名稱:lain,代碼行數:18,代碼來源:rebellion_monitor.py

示例2: read_swift_stat

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [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

示例3: run_command

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def run_command(self, command, check_output=True):
        """Run a command for this collectd plugin. Returns a tuple with command
        success and output or False and None for output.
        """
        output = None
        try:
            if check_output:
                output = subprocess.check_output(command)
            else:
                stdin, stdout, stderr = os.popen3(' '.join(command))
                output = stdout.read()
        except Exception as exc:
            collectd.error(
                'collectd-ceph-storage: {} exception: {}'.format(command, exc))
            collectd.error(
                'collectd-ceph-storage: {} traceback: {}'
                .format(command, traceback.format_exc()))
            return False, None

        if output is None:
            collectd.error(
                'collectd-ceph-storage: failed to {}: output is None'
                .format(command))
            return False, None
        return True, output 
開發者ID:cloud-bulldozer,項目名稱:browbeat,代碼行數:27,代碼來源:collectd_ceph_storage.py

示例4: get_stats

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def get_stats(self):
        """Retrieves stats from ceph mons"""

        ceph_cluster = "%s-%s" % (self.prefix, self.cluster)

        data = { ceph_cluster: { 'mon': { 'number': 0, 'quorum': 0 } } }
        output = None
        try:
            cephmoncmdline='ceph mon dump --format json --cluster ' + self.cluster
            output = subprocess.check_output(cephmoncmdline, shell=True)
        except Exception as exc:
            collectd.error("ceph-mon: failed to ceph mon dump :: %s :: %s"
                    % (exc, traceback.format_exc()))
            return

        if output is None:
            collectd.error('ceph-mon: failed to ceph mon dump :: output was None')

        json_data = json.loads(output)

        data[ceph_cluster]['mon']['number'] = len(json_data['mons'])
        data[ceph_cluster]['mon']['quorum'] = len(json_data['quorum'])

        return data 
開發者ID:rochaporto,項目名稱:collectd-ceph,代碼行數:26,代碼來源:ceph_monitor_plugin.py

示例5: read_callback

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def read_callback():
    """ Get stats for all the servers in the cluster """
    for host in ZK_HOSTS:
        try:
            zk = ZooKeeperServer(host)
            stats = zk.get_stats()
            for k, v in stats.items():
                try:
                    val = collectd.Values(plugin='zookeeper', meta={'0':True})
                    val.type = "counter" if k in COUNTERS else "gauge"
                    val.type_instance = k
                    val.values = [v]
                    val.dispatch()
                except (TypeError, ValueError):
                    collectd.error('error dispatching stat; host=%s, key=%s, val=%s' % (host, k, v))
                    pass
        except socket.error, e:
            # ignore because the cluster can still work even
            # if some servers fail completely

            # this error should be also visible in a variable
            # exposed by the server in the statistics

            log('unable to connect to server "%s"' % (host)) 
開發者ID:mantl,項目名稱:mantl,代碼行數:26,代碼來源:zookeeper-collectd-plugin.py

示例6: read

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def read(self):
        try:
            container_ids = self.__get_all_container_ids()
            self.read_docker_used_cpu_cores(container_ids)
            time.sleep(10)
            self.read_docker_reserved_cpu_cores(container_ids)
        except Exception as e:
            collectd.error("read() failed, exception: {}".format(e)) 
開發者ID:laincloud,項目名稱:lain,代碼行數:10,代碼來源:node_monitor.py

示例7: fetch_json

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def fetch_json(url):
    """Fetch json from url"""
    try:
        return json.load(urllib2.urlopen(url, timeout=5))
    except urllib2.URLError, e:
        collectd.error("mesos-tasks plugin: Error connecting to %s - %r" % (url, e))
        return None 
開發者ID:bobrik,項目名稱:collectd-mesos-tasks,代碼行數:9,代碼來源:mesos-tasks.py

示例8: get_stats

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [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

示例9: error

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def error(self, msg):
        pass 
開發者ID:awslabs,項目名稱:collectd-cloudwatch,代碼行數:4,代碼來源:logger.py

示例10: error

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def error(self, message):
        """Log an error message to the collectd logger. """

        collectd.error('%s plugin: %s' % (self.name, message)) 
開發者ID:openstack,項目名稱:vitrage,代碼行數:6,代碼來源:plugin.py

示例11: read

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def read(data=None):
    starttime = time.time()

    gnocchi = client.Client(session=keystone_session)
    try:
        status = gnocchi.status.get()
        metric = collectd.Values()
        metric.plugin = 'gnocchi_status'
        metric.interval = INTERVAL
        metric.type = 'gauge'
        metric.type_instance = 'measures'
        metric.values = [status['storage']['summary']['measures']]
        metric.dispatch()

        metric = collectd.Values()
        metric.plugin = 'gnocchi_status'
        metric.interval = INTERVAL
        metric.type = 'gauge'
        metric.type_instance = 'metrics'
        metric.values = [status['storage']['summary']['metrics']]
        metric.dispatch()
    except Exception as err:
        collectd.error(
            'gnocchi_status: Exception getting status: {}'
            .format(err))

    timediff = time.time() - starttime
    if timediff > INTERVAL:
        collectd.warning(
            'gnocchi_status: Took: {} > {}'
            .format(round(timediff, 2), INTERVAL)) 
開發者ID:cloud-bulldozer,項目名稱:browbeat,代碼行數:33,代碼來源:collectd_gnocchi_status.py

示例12: dispatch

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def dispatch(self, stats):
        """
        Dispatches the given stats.

        stats should be something like:

        {'plugin': {'plugin_instance': {'type': {'type_instance': <value>, ...}}}}
        """
        if not stats:
            collectd.error("%s: failed to retrieve stats" % self.prefix)
            return

        self.logdebug("dispatching %d new stats :: %s" % (len(stats), stats))
        try:
            for plugin in stats.keys():
                for plugin_instance in stats[plugin].keys():
                    for type in stats[plugin][plugin_instance].keys():
                        type_value = stats[plugin][plugin_instance][type]
                        if not isinstance(type_value, dict):
                            self.dispatch_value(plugin, plugin_instance, type, None, type_value)
                        else:
                          for type_instance in stats[plugin][plugin_instance][type].keys():
                                self.dispatch_value(plugin, plugin_instance,
                                        type, type_instance,
                                        stats[plugin][plugin_instance][type][type_instance])
        except Exception as exc:
            collectd.error("%s: failed to dispatch values :: %s :: %s"
                    % (self.prefix, exc, traceback.format_exc())) 
開發者ID:rochaporto,項目名稱:collectd-openstack,代碼行數:30,代碼來源:base.py

示例13: read_callback

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def read_callback(self):
        try:
            start = datetime.datetime.now()
            stats = self.get_stats()
            self.logverbose("collectd new data from service :: took %d seconds"
                    % (datetime.datetime.now() - start).seconds)
        except Exception as exc:
            collectd.error("%s: failed to get stats :: %s :: %s"
                    % (self.prefix, exc, traceback.format_exc()))
        self.dispatch(stats) 
開發者ID:rochaporto,項目名稱:collectd-openstack,代碼行數:12,代碼來源:base.py

示例14: get_stats

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def get_stats(self):
        collectd.error('Not implemented, should be subclassed') 
開發者ID:rochaporto,項目名稱:collectd-openstack,代碼行數:4,代碼來源:base.py

示例15: dispatch

# 需要導入模塊: import collectd [as 別名]
# 或者: from collectd import error [as 別名]
def dispatch(self, stats):
        """
        Dispatches the given stats.

        stats should be something like:

        {'plugin': {'plugin_instance': {'type': {'type_instance': <value>, ...}}}}
        """
        if not stats:
            collectd.error("%s: failed to retrieve stats" % self.prefix)
            return

        self.logdebug("dispatching %d new stats :: %s" % (len(stats), stats))
        try:
            for plugin in stats.keys():
                for plugin_instance in stats[plugin].keys():
                    for type in stats[plugin][plugin_instance].keys():
                        type_value = stats[plugin][plugin_instance][type]
                        if not isinstance(type_value, dict):
                            self.dispatch_value(plugin, plugin_instance, type, None, type_value)
                        else:
                          for type_instance in stats[plugin][plugin_instance][type].keys():
                              self.dispatch_value(plugin, plugin_instance,
                                      type, type_instance,
                                      stats[plugin][plugin_instance][type][type_instance])
        except Exception as exc:
            collectd.error("%s: failed to dispatch values :: %s :: %s"
                    % (self.prefix, exc, traceback.format_exc())) 
開發者ID:rochaporto,項目名稱:collectd-ceph,代碼行數:30,代碼來源:base.py


注:本文中的collectd.error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。