Skip to main content

Python ftrace Library

ftrace is a python library to read ftrace data from the Linux Kernel.

At this time it is only compatible with Kernel Version <=4!

Installation

pip install ftrace

Example

When a new process is created the name, pid and parent pid will be printed.

import ftrace

def main():
    processes = {}

    ftrace = ftrace.FTrace()
    ftrace.tracer = ftrace.tracers.NopTracer()
    ftrace.reset()
    ftrace.setup()
    ftrace.tracer.syscalls = [
        ftrace.syscalls.Sys_Execve(),
        ftrace.syscalls.Sched_Process_Fork()
    ]

    print("pid  ppid: name")

    try:
        for data in ftrace.get_output():
            if (data is not None and data["kname"] == "sys_execve_kprobe"):
                print("{} {}: {}".format(data["caller_pid"], processes[data["caller_pid"]] if (data["caller_pid"] in processes) else "----", data["filename"]))
            elif (data["kname"] == "sched_process_fork"):
                processes[data["called_pid"]] = data["caller_pid"]
    except KeyboardInterrupt:
        print("\nstopping...")

    ftrace.reset()


if __name__ == "__main__":
    main()

Metadata

Release files for ftrace 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ftrace 0.0.1
File Size Uploaded
ftrace-0.0.1.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ftrace 0.0.1
File Interpreter ABI Platform
ftrace-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.6 kB

Release files / ftrace-0.0.1.tar.gz

Download URL ftrace-0.0.1.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
246875c6474bd49f4248b324b81821e7033d4cebcda1bee1a20115ceb332799b
BLAKE2b-256 checksum
How to use checksums
37ad963cd50e44f5da3f663d45f65b441c1038362ab03bd625816a66f6b5e85b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.5

Release files / ftrace-0.0.1-py3-none-any.whl

Download URL ftrace-0.0.1-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9527c05ed85b899b8483d11dcd04131972304007bd2d8f7b59507303e88214f0
BLAKE2b-256 checksum
How to use checksums
b90cb784c2430652efa6347694f60297dfa08cc024fa27395fccb2f99074186e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.5

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page