本文整理汇总了Python中cloud.Compute.publish_stats_multi方法的典型用法代码示例。如果您正苦于以下问题:Python Compute.publish_stats_multi方法的具体用法?Python Compute.publish_stats_multi怎么用?Python Compute.publish_stats_multi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloud.Compute
的用法示例。
在下文中一共展示了Compute.publish_stats_multi方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: publish_perf_counters
# 需要导入模块: from cloud import Compute [as 别名]
# 或者: from cloud.Compute import publish_stats_multi [as 别名]
def publish_perf_counters():
""" Publish performance counters. Used for status monitoring and auto scaling. """
VolMgr.refresh_disk_use_status()
nactive = BaseContainer.num_active(BaseContainer.SFX_INT)
stats = []
stats.append(("NumActiveContainers", "Count", nactive))
nactive_api = BaseContainer.num_active(BaseContainer.SFX_API)
stats.append(("NumActiveAPIContainers", "Count", nactive_api))
curr_cpu_used_pct = psutil.cpu_percent()
last_cpu_used_pct = curr_cpu_used_pct if BaseContainer.LAST_CPU_PCT is None else BaseContainer.LAST_CPU_PCT
BaseContainer.LAST_CPU_PCT = curr_cpu_used_pct
cpu_used_pct = int((curr_cpu_used_pct + last_cpu_used_pct) / 2)
stats.append(("CPUUsed", "Percent", cpu_used_pct))
mem_used_pct = psutil.virtual_memory().percent
stats.append(("MemUsed", "Percent", mem_used_pct))
disk_used_pct = 0
for x in psutil.disk_partitions():
if not VolMgr.is_mount_path(x.mountpoint):
try:
disk_used_pct = max(psutil.disk_usage(x.mountpoint).percent, disk_used_pct)
except:
pass
if BaseContainer.INITIAL_DISK_USED_PCT is None:
BaseContainer.INITIAL_DISK_USED_PCT = disk_used_pct
disk_used_pct = max(0, (disk_used_pct - BaseContainer.INITIAL_DISK_USED_PCT))
stats.append(("DiskUsed", "Percent", disk_used_pct))
cont_load_pct = min(100, max(0, nactive * 100 / SessContainer.MAX_CONTAINERS))
stats.append(("ContainersUsed", "Percent", cont_load_pct))
api_cont_load_pct = min(100, max(0, nactive_api * 100 / APIContainer.MAX_CONTAINERS))
stats.append(("APIContainersUsed", "Percent", api_cont_load_pct))
stats.append(("DiskIdsUsed", "Percent", VolMgr.used_pct()))
overall_load_pct = max(
cont_load_pct, api_cont_load_pct, disk_used_pct, mem_used_pct, cpu_used_pct, VolMgr.used_pct()
)
stats.append(("Load", "Percent", overall_load_pct))
Compute.publish_stats_multi(stats)