本文整理汇总了Python中lib.membase.api.rest_client.RestConnection.fetch_system_stats方法的典型用法代码示例。如果您正苦于以下问题:Python RestConnection.fetch_system_stats方法的具体用法?Python RestConnection.fetch_system_stats怎么用?Python RestConnection.fetch_system_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.membase.api.rest_client.RestConnection
的用法示例。
在下文中一共展示了RestConnection.fetch_system_stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ns_server_stats
# 需要导入模块: from lib.membase.api.rest_client import RestConnection [as 别名]
# 或者: from lib.membase.api.rest_client.RestConnection import fetch_system_stats [as 别名]
def ns_server_stats(self, interval=60):
self._task["ns_server_stats"] = []
self._task["ns_server_stats_system"] = []
nodes_iterator = (node for node in self.nodes)
node = nodes_iterator.next()
retries = 0
not_null = lambda v: v if v is not None else 0
rest = RestConnection(node)
while not self._aborted():
time.sleep(interval)
log.info("collecting ns_server_stats")
try:
# Bucket stats
ns_server_stats = rest.fetch_bucket_stats(bucket=self.bucket)
for key, value in ns_server_stats["op"]["samples"].iteritems():
ns_server_stats["op"]["samples"][key] = not_null(value)
self._task["ns_server_stats"].append(ns_server_stats)
# System stats
ns_server_stats_system = rest.fetch_system_stats()
self._task["ns_server_stats_system"].append(ns_server_stats_system)
except (ValueError, TypeError), e:
retries += 1
log.error("unable to parse json object {0}: {1}".format(node, e))
log.warning("retries: {0} of {1}".format(retries, RETRIES))
if retries == RETRIES:
try:
node = nodes_iterator.next()
rest = RestConnection(node)
retries = 0
except StopIteration:
log.error("no nodes available: stop collecting ns_server_stats")
return