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


Python Compute.publish_stats方法代碼示例

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


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

示例1: publish_anticipated_load

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import publish_stats [as 別名]
 def publish_anticipated_load(session_name=None):
     iid = Compute.get_instance_id()
     if session_name is None:
         nactive = BaseContainer.num_active(BaseContainer.SFX_INT)
     else:
         JBoxSessionProps.attach_instance(Compute.get_install_id(), session_name, iid, "Preparing")
         nactive = BaseContainer.num_active(BaseContainer.SFX_INT) + 1
     cont_load_pct = min(100, max(0, nactive * 100 / SessContainer.MAX_CONTAINERS))
     self_load = max(Compute.get_instance_stats(iid, 'Load'), cont_load_pct)
     Compute.publish_stats("Load", "Percent", self_load)
     accept = Compute.should_accept_session(is_proposed_cluster_leader())
     JBoxInstanceProps.set_props(Compute.get_install_id(), iid, load=self_load, accept=accept)
開發者ID:nkottary,項目名稱:JuliaBox,代碼行數:14,代碼來源:srvr_jboxd.py

示例2: publish_perf_counters

# 需要導入模塊: from cloud import Compute [as 別名]
# 或者: from cloud.Compute import publish_stats [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)
        Compute.publish_stats("NumActiveContainers", "Count", nactive)

        nactive_api = BaseContainer.num_active(BaseContainer.SFX_API)
        Compute.publish_stats("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)
        Compute.publish_stats("CPUUsed", "Percent", cpu_used_pct)

        mem_used_pct = psutil.virtual_memory().percent
        Compute.publish_stats("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))
        Compute.publish_stats("DiskUsed", "Percent", disk_used_pct)

        cont_load_pct = min(100, max(0, nactive * 100 / SessContainer.MAX_CONTAINERS))
        Compute.publish_stats("ContainersUsed", "Percent", cont_load_pct)

        api_cont_load_pct = min(100, max(0, nactive_api * 100 / APIContainer.MAX_CONTAINERS))
        Compute.publish_stats("APIContainersUsed", "Percent", api_cont_load_pct)

        Compute.publish_stats("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())
        Compute.publish_stats("Load", "Percent", overall_load_pct)
開發者ID:Emram,項目名稱:JuliaBox,代碼行數:43,代碼來源:srvr_jboxd.py


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