コード例 #1
0
def lttng_stop():
	ret = lttng.stop(session_name)
	if ret < 0:
		raise RuntimeError("LTTng: " + lttng.strerror(ret))

	ret = lttng.destroy(session_name)
	if ret < 0:
		raise RuntimeError("LTTng: " + lttng.strerror(ret))
コード例 #2
0
def cleanup():
	lttng.stop(session_name)
	lttng.destroy(session_name)

	try:
		f = open(sessiond_pidfile, "r")
		pid = int(f.readline())
		f.close()
		os.kill(pid, signal.SIGTERM)
	except (OSError, IOError) as e:
		# Nothing to do: we may not have launched the sessiond
		pass

	# Ignore errors when deleting the temporary directory (otherwise
	# an exception may be raised if the sessiond removes its pidfile
	# while rmtree() is running).
	shutil.rmtree(tmp_dir, True)
コード例 #3
0
def lttng_stop():
    ret = lttng.stop(session_name)
    if ret < 0:
        raise RuntimeError("LTTng: " + lttng.strerror(ret))

    ret = lttng.destroy(session_name)
    if ret < 0:
        raise RuntimeError("LTTng: " + lttng.strerror(ret))
コード例 #4
0
def stop(session_name: str, ) -> None:
    """
    Stop LTTng session, and check for errors.

    :param session_name: the name of the session
    """
    result = lttng.stop(session_name)
    if result < 0:
        raise RuntimeError(f'failed to stop tracing: {lttng.strerror(result)}')
コード例 #5
0
def cleanup():
    lttng.stop(session_name)
    lttng.destroy(session_name)
    lttng_kernel_benchmark.unload_modules()

    try:
        f = open(sessiond_pidfile, "r")
        pid = int(f.readline())
        f.close()
        os.kill(pid, signal.SIGTERM)
    except (OSError, IOError) as e:
        # Nothing to do: we may not have launched the sessiond
        pass

    # Ignore errors when deleting the temporary directory (otherwise
    # an exception may be raised if the sessiond removes its pidfile
    # while rmtree() is running).
    shutil.rmtree(tmp_dir, True)
コード例 #6
0
    def __exit__(self, exc_type, exc_val, exc_tb):
        r = lttng.stop(session_name=self.sess_name)
        if r < 0:
            raise Exception("lttng.stop({nm}) return code {code}".format(
                nm=self.sess_name, code=r))

        r = lttng.destroy(name=self.sess_name)
        if r < 0:
            raise Exception("lttng.destroy({nm}) return code {code}".format(
                nm=self.sess_name, code=r))
コード例 #7
0
ファイル: lttng-interface.py プロジェクト: mogeb/benchtrace
def stop_tracing_binding(tracename):
    lttng.stop(tracename)
    lttng.destroy(tracename)
コード例 #8
0
# Enabling all events
event = lttng.Event()
event.type = lttng.EVENT_ALL
event.loglevel_type = lttng.EVENT_LOGLEVEL_ALL
ret = lttng.enable_event(han, event, None)
if ret < 0:
    raise LTTngError(lttng.strerror(ret))

# Start, wait, stop
ret = lttng.start(ses_name)
if ret < 0:
    raise LTTngError(lttng.strerror(ret))
print("Tracing...")
time.sleep(2)
print("Stopped.")
ret = lttng.stop(ses_name)
if ret < 0:
    raise LTTngError(lttng.strerror(ret))

# Destroying tracing session
ret = lttng.destroy(ses_name)
if ret < 0:
    raise LTTngError(lttng.strerror(ret))

# BABELTRACE

# Create TraceCollecion and add trace:
traces = babeltrace.reader.TraceCollection()
ret = traces.add_trace(trace_path + "/kernel", "ctf")
if ret is None:
    raise BabeltraceError("Error adding trace")
コード例 #9
0
def lttng_session(session_name, command, names, analyzer):
    ts = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d-%H-%M-%S-%f')
    tracedir = os.environ['HOME'] + "/lttng-traces/" + session_name + "-" + ts
    print('Writing trace to ' + tracedir)
    lttng.destroy(session_name)
    res = lttng.create(session_name, tracedir)
    if res<0:
        raise Exception("Failed to create lttng session")

    dom = lttng.Domain()
    dom.type = lttng.DOMAIN_UST

    han = None
    han = lttng.Handle(session_name, dom)
    if han is None:
        raise Exception("Handle not created")

    channel = lttng.Channel()
    channel.name = "channel0"
    channel.attr.overwrite = 0
    channel.attr.subbuf_size = 1048576
    channel.attr.num_subbuf = 8
    channel.attr.switch_timer_interval = 0
    channel.attr.read_timer_interval = 0
    channel.attr.output = lttng.EVENT_MMAP

    res = lttng.enable_channel(han, channel)
    if res<0:
        raise Exception("Failed to enable channel")
    
    for n in names:
        # lttng enable-event -u 'memcached:*'
        event = lttng.Event()
        event.type = lttng.EVENT_TRACEPOINT
        event.name = n
        lttng.enable_event(han, event, "channel0")

    os.system("lttng add-context -s" + session_name + " -u -t perf:thread:cycles -t pthread_id")

#    ctx = lttng.EventContext()
#    ctx.type = EVENT_CONTEXT_PTHREAD_ID
#    res = lttng.add_context(han, ctx, None, None)
#    assert res >= 0  
#
#    ctx.type = EVENT_CONTEXT_PERF_COUNTER
#    ctx.u.perf_counter.name = "cpu-cycles"
#    res = lttng.add_context(han, ctx, None, None)
#    assert res >= 0  

    lttng.start(session_name)

    print("running ", command)
    os.system(command)

    lttng.stop(session_name)
    lttng.destroy(session_name)
    
    subdir = subprocess.check_output(['ls', tracedir+'/ust/pid/']).decode("utf-8").rstrip()

    babeldir = tracedir+'/ust/pid/'+subdir
    print("analyzing trace in", babeldir)

    col = babeltrace.TraceCollection()
    if col.add_trace(babeldir, 'ctf') is None:
        raise RuntimeError('Cannot add trace')
    return analyzer(col)
コード例 #10
0
# Enabling all events
event = lttng.Event()
event.type = lttng.EVENT_ALL
event.loglevel_type = lttng.EVENT_LOGLEVEL_ALL
ret = lttng.enable_event(han, event, None)
if ret < 0:
    raise LTTngError(lttng.strerror(ret))

# Start, wait, stop
ret = lttng.start(ses_name)
if ret < 0:
    raise LTTngError(lttng.strerror(ret))
print("Tracing...")
time.sleep(2)
print("Stopped.")
ret = lttng.stop(ses_name)
if ret < 0:
    raise LTTngError(lttng.strerror(ret))


# Destroying tracing session
ret = lttng.destroy(ses_name)
if ret < 0:
    raise LTTngError(lttng.strerror(ret))


# BABELTRACE

# Create TraceCollecion and add trace:
traces = babeltrace.TraceCollection()
ret = traces.add_trace(trace_path + "/kernel", "ctf")
コード例 #11
0
	def stop(self):
		ret = lttng.stop(self.name)
		if ret < 0:
			raise LTTngError(lttng.strerror(ret))
コード例 #12
0
ファイル: ctl.py プロジェクト: mogeb/tracers-benchmark
    channel.attr.overwrite = 0
    channel.attr.subbuf_size = 4096
    channel.attr.num_subbuf = 8
    channel.attr.switch_timer_interval = 0
    channel.attr.read_timer_interval = 200
    channel.attr.output = lttng.EVENT_SPLICE

    event = lttng.Event()
    event.name = "sched_switch"
    event.type = lttng.EVENT_TRACEPOINT
    event.loglevel_type = lttng.EVENT_LOGLEVEL_ALL

    ret = lttng.create(sess_name, trace_dest)
    assert ret == 0

    han = None
    han = lttng.Handle(sess_name, dom)
    assert han != None

    lttng.enable_channel(han, channel)
    lttng.enable_event(han, event, channel.name)

    print(lttng.list_channels(han))

    lttng.start(sess_name)
    time.sleep(0.1)
    lttng.stop(sess_name)

    ret = lttng.destroy(sess_name)
    assert ret == 0