首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏绿盟科技研究通讯

    【云原生技术研究】 从bpftrace看如何利用eBPF实现内核追踪

    :syscalls:sys_enter_accept4 tracepoint:syscalls:sys_enter_accept tracepoint:syscalls:sys_enter_connect :syscalls:sys_exit_setuid tracepoint:syscalls:sys_exit_setfsuid tracepoint:syscalls:sys_exit_setresuid 5opensnoop.bttracepoint:syscalls:sys_enter_open tracepoint:syscalls:sys_enter_openat tracepoint:syscalls :syscalls:sys_exit_statfs, tracepoint:syscalls:sys_exit_statx, tracepoint:syscalls:sys_exit_newstat, 9syncsnoop.bttracepoint:syscalls:sys_enter_sync, tracepoint:syscalls:sys_enter_syncfs, tracepoint:syscalls

    3.2K30发布于 2020-09-01
  • 来自专栏云微的一点分享

    eBPF 入门开发实践指南四:在 eBPF 中捕获进程打开文件的系统调用集合,使用全局变量过滤进程 pid

    bpf_helpers.h> /// @description "Process ID to trace" const volatile int pid_target = 0; SEC("tracepoint/syscalls /sys_enter_openat") int tracepoint__syscalls__sys_enter_openat(struct trace_event_raw_sys_enter* ctx) ." char LICENSE[] SEC("license") = "GPL"; 上面的 eBPF 程序通过定义函数 tracepoint__syscalls__sys_enter_openat 并使用 在 tracepoint__syscalls__sys_enter_open 和 tracepoint__syscalls__sys_enter_openat 函数中,我们可以使用这个全局变量来过滤输出 在 eBPF 程序中,我们可以通过定义 tracepoint__syscalls__sys_enter_open 和 tracepoint__syscalls__sys_enter_openat 函数并使用

    2.5K10编辑于 2023-02-24
  • 来自专栏linux驱动个人学习

    Linux性能工具-bpftrace入门

    3.2.1 单行语句 如系统函数raw_syscalls:sys_enter的调用统计,语法为:bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[comm 其他单行函数示例如下: # Files opened by process bpftrace -e 'tracepoint:syscalls:sys_enter_open { printf("%s %s \n", comm, str(args->filename)); }' # Syscall count by program bpftrace -e 'tracepoint:raw_syscalls: sys_enter { @[comm] = count(); }' # Read bytes by process: bpftrace -e 'tracepoint:syscalls:sys_exit_read ->ret/ { @[comm] = sum(args->ret); }' # Read size distribution by process: bpftrace -e 'tracepoint:syscalls

    3.8K21编辑于 2022-11-23
  • 来自专栏云计算与大数据

    bpf| 系统分析工具

    ] = count(); }' count syscalls by process name bpftrace -e 'tracepoint:syscalls:sys_enter_open { syscalls:sys_enter_open_by_handle_at tracepoint:syscalls:sys_enter_open_tree tracepoint:syscalls:sys_enter_open tracepoint:syscalls:sys_enter_openat tracepoint:syscalls:sys_enter_openat2 root@heidsoft-dev:~# bpftrace -e 'tracepoint:syscalls:sys_enter_open* { @[probe] = count(); }' Attaching 5 probes... Tracing open syscalls... Hit Ctrl-C to end.

    1.6K10编辑于 2022-04-18
  • 来自专栏mazhen.tech

    从源码构建 perf

    另外一个例子,按类型统计整个系统的系统调用,持续 5 秒钟: $ sudo perf stat -e 'syscalls:sys_enter_*' -a sleep 5 Performance counter 0 syscalls:sys_enter_signalfd4 0 syscalls:sys_enter_signalfd 0 syscalls:sys_enter_epoll_create1 0 syscalls 80 syscalls:sys_enter_epoll_pwait

    2.4K21编辑于 2023-11-24
  • 来自专栏Linux内核及编程语言底层相关技术研究

    Linux内核源码分析 - 系统调用

    count) { return ksys_write(fd, buf, count); } 这里主要看下SYSCALL_DEFINE3这个宏定义: // include/linux/syscalls.h 根据arch/x86/entry/syscalls/Makefile我们可以知道,是有对应的shell脚本,根据上面的文件来生成c版的头文件,比如下面两个。 接着用#include <asm/syscalls_64.h>的方式再初始化存在的系统调用。 该include的文件就是上面生成的arch/x86/include/generated/asm/syscalls_64.h,syscalls_64.h文件里调用__SYSCALL_64,为对应的系统下标赋值 if (likely(nr < NR_syscalls)) { nr = array_index_nospec(nr, NR_syscalls);

    6.7K22发布于 2019-05-30
  • 来自专栏嵌入式与Linux那些事

    38.Linux应用调试-初步制作系统调用(用户态->内核态)

    其中CALL定义如下所示: .equ NR_syscalls,0 //将NR_syscalls=0 #define CALL(x) .equ NR_syscalls,NR_syscalls+1 //将CALL(x) 定义为:NR_syscalls=NR_syscalls+1 ,也就是每有一个CALL(),则该CALL值则+1 #include "calls.S" count : 100); ker_buf[99]='\0'; printk("sys_hello:%s\n",ker_buf); } } 3.4 include\linux\syscalls.h

    1.2K30发布于 2021-05-20
  • 来自专栏全栈程序员必看

    ebpf监控_链路追踪命令

    现在让我们转向一个更有用的例子: $ sudo bpftrace -e 't:syscalls:sys_enter_execve { printf("%s called %s\n", comm, str t:syscalls:sys_enter_execve 是一个内核追踪点,是 tracepoint:syscalls:sys_enter_execve 的简写,两种形式都可以使用。 comm 是一个 bpftrace 内建指令,代表进程名;filename 是 t:syscalls:sys_enter_execve 追踪点的一个字段,这些字段可以通过 args 内建指令访问。 上面的例子中,操作块连接到了所有名称以 t:syscalls:sysenter_ 开头的追踪点,即所有可用的系统调用。 下面的例子统计所有的系统调用,然后通过 bpftrace 过滤语法使用 PID 过滤出某个特定进程调用的系统调用: $ sudo bpftrace -e 't:syscalls:sys_enter_*

    1.9K30编辑于 2022-10-05
  • 来自专栏FreeBuf

    SysWhispers:如何通过直接系统调用实现AVEDR绕过

    \syswhispers.py --preset all -o syscalls_all 仅导出Windows 7、8和10支持的常用功能: py . \syswhispers.py --preset common -o syscalls_common 导出NtProtectVirtualMemory和NtWriteVirtualMemory函数: py \syswhispers.py --functions NtProtectVirtualMemory,NtWriteVirtualMemory -o syscalls_mem 导出Windows 7、8 \syswhispers.py --versions 7,8,10 -o syscalls_78X 脚本输出 PS C:\Projects\SysWhispers> py . \syswhispers.py -f NtAllocateVirtualMemory,NtWriteVirtualMemory,NtCreateThreadEx -o syscalls #include

    2.1K10发布于 2020-02-20
  • 来自专栏爱可生开源社区

    技术译文 | MySQL 引入 innodb_flush_method 等新参数的系统调用分析

    下面是从官方文档中摘录的 InnoDB 架构: 在支持 fdatasync() 的平台上执行系统调用(System calls,以下简称 Syscalls),MySQL 8.0.26 中引入的 innodb_use_fdatasync 要操作文件,MySQL 和任何其他软件都必须调用 Syscalls。每当进程需要系统资源时,它都会通过 Syscalls 向内核发送对该资源的请求。 问题:如何检查我的操作系统是否支持特定的 Syscalls? $ man syscalls 它将列出可用的 Syscalls 以及其中出现的 Linux 内核。 /strace.out -p <pid> # Once you exit strace (CTRL+C), a summary of syscalls is written in the strace.out 100.00 491.324073 590620 52679 total 即使没有启用 innodb_use_fdatasync,您也会在 strace 输出中注意到 Syscalls

    81310编辑于 2024-01-30
  • 来自专栏山河已无恙

    Linux 可观测性 BPF&eBPF 以及 BCC&bpftrace 认知

    :sys_enter_open tracepoint:syscalls:sys_enter_open_by_handle_at tracepoint:syscalls:sys_enter_open_tree tracepoint:syscalls:sys_enter_openat tracepoint:syscalls:sys_enter_openat2 ┌──[root@liruilongs.github.io :syscalls:sys_exit_open, tracepoint:syscalls:sys_exit_openat /@filename[tid]/ { $ret = args-> tracepoint:syscalls:sys_enter_open和tracepoint:syscalls:sys_enter_openat是用于跟踪open()和openat()系统调用的进入跟踪点 tracepoint:syscalls:sys_exit_open和tracepoint:syscalls:sys_exit_openat是用于跟踪open()和openat()系统调用的退出跟踪点。

    1.2K10编辑于 2024-01-17
  • 来自专栏Postgresql源码分析

    linux性能命令总结

    sleep 10 perf stat -e LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches -a sleep 10 perf stat -e 'syscalls specification: perf stat -e cycles -e cpu/event=0x0e,umask=0x01,inv,cmask=0x01/ -a sleep 5 # Count syscalls per-second system-wide: perf stat -e raw_syscalls:sys_enter -I 1000 -a # Count system calls by type for the specified PID, until Ctrl-C: perf stat -e 'syscalls:sys_enter_*' -p PID # Count system calls by type for the entire system, for 5 seconds: perf stat -e 'syscalls:sys_enter_*' -a sleep 5 # Count

    1K10编辑于 2022-05-12
  • 技术实践 | 如何用 libbpf 来开发一个 eBPF 程序

    __uint(value_size, sizeof(u32)); } events SEC(".maps"); // sys_enter_execve跟踪点 SEC("tracepoint/syscalls /sys_enter_execve") int tracepoint__syscalls__sys_enter_execve(struct trace_event_raw_sys_enter *ctx) { // 待实现处理逻辑 } // sys_exit_execve跟踪点 SEC("tracepoint/syscalls/sys_exit_execve") int tracepoint__syscalls SEC("tracepoint/syscalls/sys_enter_execve") int tracepoint__syscalls__sys_enter_execve(struct trace_event_raw_sys_enter SEC("tracepoint/syscalls/sys_exit_execve") int tracepoint__syscalls__sys_exit_execve(struct trace_event_raw_sys_exit

    60710编辑于 2025-07-27
  • 来自专栏云微的一点分享

    三分钟学会编写 eBPF 程序:使用 eBPF 程序监控打开文件路径并使用 Prometheus 可视化

    = uid) { return false; } } return true; } SEC("tracepoint/syscalls/sys_enter_open") int tracepoint __syscalls__sys_enter_open(struct trace_event_raw_sys_enter* ctx) { u64 id = bpf_get_current_pid_tgid /sys_enter_openat") int tracepoint__syscalls__sys_enter_openat(struct trace_event_raw_sys_enter* ctx) /sys_exit_open") int tracepoint__syscalls__sys_exit_open(struct trace_event_raw_sys_exit* ctx) { return trace_exit(ctx); } SEC("tracepoint/syscalls/sys_exit_openat") int tracepoint__syscalls__sys_exit_openat

    1.3K20编辑于 2023-02-24
  • 来自专栏数据库相关

    高性能:BPF performance Tools 学习笔记-1

    •execsnoop:     Trace new processes via exec() syscalls.  •mountsnoop:     Trace mount and umount syscalls system-wide.  •opensnoop:     Trace open() syscalls.  •pidpersec:     Count new processes (via fork).  •shmsnoop:     Trace System V shared memory syscalls.  •ucalls:     Summarize method calls or Linux syscalls in high-level languages. 

    2.1K22发布于 2020-02-17
  • 来自专栏山河已无恙

    使用 BPF 监视 K8s 集群(k8s BPF 工具 kubectl-trace 认知

    an bpftrace inline program on a pod container kubectl trace run pod/nginx -c nginx -e "tracepoint:syscalls :sys_enter_* { @[probe] = count(); }" kubectl trace run pod/nginx nginx -e "tracepoint:syscalls:sys_enter Tracing open syscalls... Hit Ctrl-C to end. /usr/bin/bpftrace /* * opensnoop Trace open() syscalls. :syscalls:sys_exit_open, tracepoint:syscalls:sys_exit_openat /@filename[tid]/ { $ret = args->

    44110编辑于 2024-03-25
  • 来自专栏Linux驱动

    42.Linux应用调试-初步制作系统调用(用户态->内核态)

    3 仿照sys_hello() 3.1先来查找数组表,以sys_write为例,搜索找到位于arch/arm/kernel/calls.S,如下图所示: 其中CALL定义如下所示: .equ NR_syscalls ,0 //将NR_syscalls=0 #define CALL(x) .equ NR_syscalls,NR_syscalls+1 //将CALL(x) 定义为:NR_syscalls= NR_syscalls+1 ,也就是每有一个CALL(),则该CALL值则+1 #include "calls.S" //将calls.S的内容包进来,CALL(x)上面已经有了定义 : 100); ker_buf[99]='\0'; printk("sys_hello:%s\n",ker_buf); } } 3.4  include\linux\syscalls.h

    1.8K50发布于 2018-01-08
  • 来自专栏云微的一点分享

    eBPF 入门开发实践教程四:在 eBPF 中捕获进程打开文件的系统调用集合,使用全局变量过滤进程 pid

    bpf_helpers.h>/// @description "Process ID to trace"const volatile int pid_target = 0;SEC("tracepoint/syscalls /sys_enter_openat")int tracepoint__syscalls__sys_enter_openat(struct trace_event_raw_sys_enter* ctx){ 使用 SEC 宏定义一个 eBPF 程序,关联到 tracepoint "tracepoint/syscalls/sys_enter_openat"。 实现 eBPF 程序 tracepoint__syscalls__sys_enter_openat,它接收一个类型为 struct trace_event_raw_sys_enter 的参数 ctx。 在 eBPF 程序中,我们可以通过定义 tracepoint__syscalls__sys_enter_open 和 tracepoint__syscalls__sys_enter_openat 函数并使用

    1.5K10编辑于 2023-08-14
  • 来自专栏鸿鹄实验室

    C2基石--syscall模块及amsi bypass

    PIMAGE_SECTION_HEADER pTextSection; PIMAGE_SECTION_HEADER pRdataSection; CHAR cSyscallStub; }; struct Syscalls syscall.h #include <windows.h> #include <ntdef.h> #include <tlhelp32.h> #include <winternl.h> #include "syscalls.h LPVOID)pcOverWrite, SYSCALL_STUB_SIZE); return; } VOID ParseNtdll(struct NtInfo *NtdllInfo, struct Syscalls RVAtoRawOffset((DWORD_PTR)NtdllInfo->lpRawData + dwExportDirRVA, NtdllInfo->pRdataSection); } 调用方法: #include "syscalls.h NULL, &sInfo, &pInfo); LPVOID rBuffer = NULL; struct NtInfo NtdllInfo; struct Syscalls

    83540发布于 2021-08-25
  • 来自专栏Rice嵌入式

    基于ebpf的性能工具-bpftrace

    单行指令,官方也提供了一些样例,如下: # Files opened by process $ bpftrace -e 'tracepoint:syscalls:sys_enter_open { printf "%s %s\n", comm, str(args->filename)); }' # Syscall count by program $ bpftrace -e 'tracepoint:raw_syscalls :sys_enter { @[comm] = count(); }' # Read bytes by process: $ bpftrace -e 'tracepoint:syscalls:sys_exit_read ret/ { @[comm] = sum(args->ret); }' # Read size distribution by process: $ bpftrace -e 'tracepoint:syscalls ustack] = count(); }' # Files opened, for processes in the root cgroup-v2 $ bpftrace -e 'tracepoint:syscalls

    1.4K30编辑于 2023-09-02
领券