You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.2 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # GPTtrace 🤖
  2. [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
  3. [![Actions Status](https://github.com/eunomia-bpf/eunomia-bpf/workflows/Ubuntu/badge.svg)](https://github.com/eunomia-bpf/eunomia-bpf/actions)
  4. [![DeepSource](https://deepsource.io/gh/eunomia-bpf/eunomia-bpf.svg/?label=active+issues&show_trend=true&token=rcSI3J1-gpwLIgZWtKZC-N6C)](https://deepsource.io/gh/eunomia-bpf/eunomia-bpf/?ref=repository-badge)
  5. [![CodeFactor](https://www.codefactor.io/repository/github/eunomia-bpf/eunomia-bpf/badge)](https://www.codefactor.io/repository/github/eunomia-bpf/eunomia-bpf)
  6. Generate eBPF programs and tracing with ChatGPT and natural language
  7. ## Key Features 💡
  8. ### Interact and Tracing your Linux with natural language, it can tell how to write eBPF programs in `BCC`, `libbpf` styles.
  9. example: tracing with Count page faults by process
  10. ![result](doc/result.gif)
  11. ### Generate eBPF programs with natural language
  12. ![generate](doc/generate.png)
  13. For detail documents and tutorials about how we train ChatGPT to write eBPF programs, please refer to: [`https://github.com/eunomia-bpf/bpf-developer-tutorial`](https://github.com/eunomia-bpf/bpf-developer-tutorial) (基于 CO-RE (一次编写,到处运行) libbpf 的 eBPF 开发者教程:通过 20 个小工具一步步学习 eBPF(尝试教会 ChatGPT 编写 eBPF 程序)
  14. ## Usage and Setup 🛠
  15. ```console
  16. $ ./GPTtrace.py
  17. usage: GPTtrace [-h] [-i | -v | -e TEXT | -g TEXT] [-u UUID] [-t ACCESS_TOKEN]
  18. Use ChatGPT to write eBPF programs (bpftrace, etc.)
  19. optional arguments:
  20. -h, --help show this help message and exit
  21. -i, --info Let ChatGPT explain what's eBPF
  22. -v, --verbose Print the prompt and receive message
  23. -e TEXT, --execute TEXT
  24. Generate commands using your input with ChatGPT, and run it
  25. -g TEXT, --generate TEXT
  26. Generate eBPF programs using your input with ChatGPT
  27. -u UUID, --uuid UUID Conversion UUID to use, or passed through environment variable `GPTTRACE_CONV_UUID`
  28. -t ACCESS_TOKEN, --access-token ACCESS_TOKEN
  29. ChatGPT access token, see `https://chat.openai.com/api/auth/session` or passed through
  30. `GPTTRACE_ACCESS_TOKEN`
  31. ```
  32. ### First: login to ChatGPT
  33. - get the `Conversion ID` from ChatGPT, and then set it to the environment variable `GPTTRACE_CONV_UUID` or use the `-u` option. The `Conversion ID` is the last part of the URL of the conversation, for example, the `Conversion ID` of `https://chat.openai.com/conv/1a2b3c4d-0000-0000-0000-1k2l3m4n5o6p` is `1a2b3c4d-0000-0000-0000-1k2l3m4n5o6p`(example, not usable).
  34. - get the `access token` from ChatGPT, and then set it to the environment variable `GPTTRACE_ACCESS_TOKEN` or use the `-t` option. see `https://chat.openai.com/api/auth/session` for the access token.
  35. ### Use prompts to teach ChatGPT to write eBPF programs
  36. ```sh
  37. ./GPTtrace.py -t
  38. ```
  39. This will use the material in the `prompts` directory to teach ChatGPT to write eBPF programs in bpftrace, libbpf, and BCC styles. You can also do that manually by sending the prompts to ChatGPT in the Website.
  40. ### start your tracing! 🚀
  41. For example:
  42. ```sh
  43. ./GPTtrace.py -e "Count page faults by process"
  44. ```
  45. ## Installation 🔧
  46. ```sh
  47. ./install.sh
  48. ```
  49. ## Examples
  50. - Files opened by process
  51. - Syscall count by program
  52. - Read bytes by process:
  53. - Read size distribution by process:
  54. - Show per-second syscall rates:
  55. - Trace disk size by process
  56. - Count page faults by process
  57. - Count LLC cache misses by process name and PID (uses PMCs):
  58. - Profile user-level stacks at 99 Hertz, for PID 189:
  59. - Files opened, for processes in the root cgroup-v2
  60. ## LICENSE
  61. MIT
  62. ## 🔗 Links
  63. - detail documents and tutorials about how we train ChatGPT to write eBPF programs: https://github.com/eunomia-bpf/bpf-developer-tutorial (基于 CO-RE (一次编写,到处运行) libbpf 的 eBPF 开发者教程:通过 20 个小工具一步步学习 eBPF(尝试教会 ChatGPT 编写 eBPF 程序)
  64. - bpftrace: https://github.com/iovisor/bpftrace
  65. - ChatGPT: https://chat.openai.com/

Generate eBPF programs and tracing with ChatGPT and natural language