def add_set(i): global G, schema _set = ldms.Set("node-1/set{}".format(i), schema) _set.transaction_begin() _set.transaction_end() _set.publish() G.sets[_set.name] = _set
def do_samp(samp_port, *args, **kwargs): global D # samp routine D.grp = grp = ldms.Grp(name="grp") grp.publish() sets = [ ldms.Set(name=s, schema=schema) for s in SET_NAMES ] samp_update(sets) for s in sets: s.publish() grp.transaction_begin() for m in GRP_MEMBERS: grp.add(m) grp.transaction_end() do_listen(samp_port) while True: time.sleep(1) samp_update(sets)
def add_set(name, array_card=1): SCHEMA.set_array_card(array_card) _set = ldms.Set(name, SCHEMA) _set.publish() return _set
ldms.init(16*1024*1024) def on_SIGTERM(*args): os._exit(0) signal.signal(signal.SIGTERM, on_SIGTERM) # Request SIGHUP our process when parent exited libc = ctypes.CDLL(None) # prctl(PR_SET_PDEATHSIG, SIGHUP) libc.prctl(1, 1) # create the transport lx = ldms.Xprt() # listen lx.listen(port=10001) # create and publish set set_name = "sync/" + set_test.SET_NAME lset = ldms.Set(name=set_name, schema=set_test.SCHEMA) lset.producer_name = "sync" lset.publish() # populate set data set_test.populate_data(lset) while True: x = lx.accept() # client will close the connection
p.add_argument("--schema-number", "-S", type=int) args = p.parse_args() x = ldms.Xprt(name="sock") def listen_cb(ep, ev, arg): G.ep = ep G.ev = ev SCHEMA = ldms.Schema( name="schema", metric_list=[ ("component_id", "u64", 1), ("job_id", "u64", 1), ("app_id", "u64", 1), ("m0", "u32", 1), ("m1", "u32", 1), ], ) if args.schema_number == 2: SCHEMA.add_metric("m2", "u32") _set = ldms.Set("port_{}".format(args.port), SCHEMA) _set.publish() rc = x.listen(host="0.0.0.0", port=args.port, cb=listen_cb) while True: time.sleep(1)
LOG_FMT = "%(asctime)s.%(msecs)03d %(levelname)s %(module)s %(message)s" logging.basicConfig(datefmt="%F-%T", format=LOG_FMT, level=logging.INFO) log = logging.getLogger() class Global(object): pass G = Global() ldms.init(16*1024*1024) schema = ldms.Schema("test", metric_list = [ ("x", int), ("y", int), ("z", int), ]) set0 = ldms.Set("node-1/set0", schema) set0.transaction_begin() set0.transaction_end() set0.publish() G.sets = { set0.name: set0 } def add_set(i): global G, schema _set = ldms.Set("node-1/set{}".format(i), schema) _set.transaction_begin() _set.transaction_end() _set.publish() G.sets[_set.name] = _set def rm_set(i):
LOG_FMT = "%(asctime)s.%(msecs)03d %(levelname)s %(module)s %(message)s" logging.basicConfig(datefmt="%F-%T", format=LOG_FMT, level=logging.INFO) log = logging.getLogger() ldms.init(16 * 1024 * 1024) SCHEMA = ldms.Schema("set_array", metric_list=[ ("x", ldms.V_S64), ("y", ldms.V_S64), ("z", ldms.V_S64), ]) SCHEMA.set_array_card(1) s1 = ldms.Set("set1", SCHEMA) s1.publish() SCHEMA.set_array_card(3) s3 = ldms.Set("set3", SCHEMA) s3.publish() x = ldms.Xprt(name="sock") def listen_cb(ep, ev, arg): log.debug("{}: {}".format(ev.type.name, ep)) G.ep = ep G.ev = ev rc = x.listen(host="0.0.0.0", port=PORT, cb=listen_cb)