Example #1
0
File: cpu.py Project: 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()



Example #2
0
File: proc.py Project: 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()