Exemplo n.º 1
0
Arquivo: proc.py Projeto: jul/dsat
                sum_file += dict({key :x.get_num_fds()})
            except:
                pass

            try:
                sum_connection += dict({ key: sum(x.get_num_ctx_switches())})
            except:
                pass
            try:
                percent_mem += dict({key : x.get_memory_percent() })
                if carbon_key:
                    carbon_measure += { carbon_key: x.get_memory_percent() }
            except:
                pass
        except NoSuchProcess:
            pass 
    try:
        send(carbon_measure)
    except Exception as e:
        ctx.log.error('Carbon is not very liking that %r' % e)
    ratio = lambda d : min(1,1.0 *d.get("me", 0)/max(.0001,d.get("other",0)))
    absol = lambda d : d.get("me", 0) + d.get("other", 0)
    res=dict(sum_file= sum_file, percent_mem= percent_mem, all_proc =len(all_proc))
    res["data"] = map(ratio, [ sum_file, sum_connection, percent_mem, procc])
    res["data"] += map(absol, [sum_file, sum_connection, percent_mem, procc])
    del all_proc
    return res

connect_me.func = proc
connect_me.turbine()
Exemplo n.º 2
0
Arquivo: cpu.py Projeto: jul/dsat
                task_id = next_tick())
            )

        sleep( (float(_5) ** 2 ) * .01 )
    except Exception as e:
        connector.log.exception(e)
        raise Exception("AARG %r" % e)





connector = Connector("cpu")

carbon_send = carbon_maker(connector)
def cpu(connector, payload, vector):
    cpu_f.seek(0)
    _5,_10,_15 = cpu_f.read().split(" ")[:3]
  #  cpu_clock(connector,_5 , vector)
    reroute_to(connector, frequency, vector)
    if int(vector["task_id"]) % 100 == 0:
        carbon_send( { "5m" : float(_5), "10m" : float(_10), "15m" :  float(_15) })
    return { "data" : [ _5,_10,_15], "load" : _5, "5min" : _5, "10min" : _10, "15min" :  _15 }

connector.func = cpu

connector.turbine()



Exemplo n.º 3
0
Arquivo: master.py Projeto: jul/dsat


#ticker = sched.scheduler(time, sleep)


#CFG, L_CFG, ID = construct_info(sys.argv, "master")
#cnx = get_connection(CFG, L_CFG)
#task_id = int(time())



def master(ctx, payload, msg):
    ctx.log.debug("I received %r" % msg)

ctx = Connector(master)

ev = {
    "seq":0, "type" : "cpu","when" : 0, "event" : "INIT", 
    "next":"cpu", "job_id": "0",
    "task_id":0,"seq":0,
    "emitter" : "me(%d)" % os.getpid(),
    "serialization": "simplejson",
    "arg" : '{"load" : 0, "5min" : 0}', "where" : "localhost", 
    "step" :"master", "wid":"0", "pid":ctx.local_info["pid"] ,"retry":2 }

send_vector( ctx.cnx["orchester_out"], ev)

ctx.turbine()