Ejemplo n.º 1
0
    def update_juliabox_status():
        in_error = len(
            JBoxInstanceProps.get_stale_instances(Compute.get_install_id()))
        instance_status = JBoxInstanceProps.get_instance_status(
            Compute.get_install_id())

        HTML = "<html><body><center><pre>\nJuliaBox is Up.\n\nLast updated: " + datetime.datetime.now(
        ).isoformat() + " UTC\n\nLoads: "
        for iid in instance_status:
            HTML += (str(instance_status[iid]['load']) + '% ')

        HTML += (
            "\n\nErrors: " + str(in_error) +
            "\n\nAWS Status: <a href='http://status.aws.amazon.com/'>status.aws.amazon.com</a></pre></center></body></html>"
        )

        plugin = JBPluginCloud.jbox_get_plugin(JBPluginCloud.JBP_BUCKETSTORE)
        bkt = JBoxCfg.get("cloud_host.status_bucket")
        if plugin is not None and bkt is not None:
            try:
                f = open("/tmp/index.html", "w")
                f.write(HTML)
                f.close()
                plugin.push(bkt, "/tmp/index.html")
            finally:
                os.remove("/tmp/index.html")
        else:
            JBox.log_debug("Status: %s", HTML)

        return None
Ejemplo n.º 2
0
    def schedule_housekeeping(cmd, is_leader):
        JBoxd.publish_perf_counters()
        JBoxd.publish_sessions()
        JBoxd.publish_instance_state()
        features = [JBPluginTask.JBP_NODE]
        if is_leader is True:
            JBoxInstanceProps.purge_stale_instances(Compute.get_install_id())
            features.append(JBPluginTask.JBP_CLUSTER)

        for feature in features:
            for plugin in JBPluginTask.jbox_get_plugins(feature):
                JBoxd.schedule_thread(cmd, plugin.do_periodic_task, (feature,))
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
    def schedule_housekeeping(cmd, is_leader):
        JBoxd.publish_perf_counters()
        JBoxd.publish_sessions()
        JBoxd.publish_instance_state()
        features = [JBPluginTask.JBP_NODE]
        if is_leader is True:
            JBoxInstanceProps.purge_stale_instances(Compute.get_install_id())
            features.append(JBPluginTask.JBP_CLUSTER)

        for feature in features:
            for plugin in JBPluginTask.jbox_get_plugins(feature):
                JBoxd.schedule_thread(cmd, plugin.do_periodic_task, (feature,))
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
    def publish_instance_state():
        iid = Compute.get_instance_id()
        api_status = dict()
        for c in BaseContainer.api_containers(allcontainers=True):
            name = c["Names"][0] if (("Names" in c) and (c["Names"] is not None)) else c["Id"][0:12]
            api_name = APIContainer.get_api_name_from_container_name(name)
            if api_name is None:
                continue
            cnt = api_status.get(api_name, 0)
            api_status[api_name] = cnt + 1
        self_load = Compute.get_instance_stats(iid, 'Load')
        accept = Compute.should_accept_session(is_proposed_cluster_leader())

        JBoxInstanceProps.set_props(Compute.get_install_id(), iid, load=self_load, accept=accept, api_status=api_status)
Ejemplo n.º 7
0
    def publish_instance_state():
        iid = Compute.get_instance_id()
        api_status = dict()
        for c in BaseContainer.api_containers(allcontainers=True):
            name = c["Names"][0] if (("Names" in c) and (c["Names"] is not None)) else c["Id"][0:12]
            api_name = APIContainer.get_api_name_from_container_name(name)
            if api_name is None:
                continue
            cnt = api_status.get(api_name, 0)
            api_status[api_name] = cnt + 1
        self_load = Compute.get_instance_stats(iid, 'Load')
        accept = Compute.should_accept_session(is_proposed_cluster_leader())

        JBoxInstanceProps.set_props(Compute.get_install_id(), iid, load=self_load, accept=accept, api_status=api_status)
Ejemplo n.º 8
0
    def update_juliabox_status():
        in_error = len(JBoxInstanceProps.get_stale_instances(Compute.get_install_id()))
        instance_status = JBoxInstanceProps.get_instance_status(Compute.get_install_id())

        HTML = "<html><body><center><pre>\nJuliaBox is Up.\n\nLast updated: " + datetime.datetime.now().isoformat() + " UTC\n\nLoads: "
        for iid in instance_status:
            HTML += (str(instance_status[iid]['load']) + '% ')

        HTML += ("\n\nErrors: " + str(in_error) + "\n\nAWS Status: <a href='http://status.aws.amazon.com/'>status.aws.amazon.com</a></pre></center></body></html>")

        plugin = JBPluginCloud.jbox_get_plugin(JBPluginCloud.JBP_BUCKETSTORE)
        bkt = JBoxCfg.get("cloud_host.status_bucket")
        if plugin is not None and bkt is not None:
            try:
                f = open("/tmp/index.html", "w")
                f.write(HTML)
                f.close()
                plugin.push(bkt, "/tmp/index.html")
            finally:
                os.remove("/tmp/index.html")
        else:
            JBox.log_debug("Status: %s", HTML)

        return None