linux-bpf 工具

文件删除监控:

#include <linux/sched.h>
#include <linux/dcache.h>
    BEGIN
    {
        printf("%-15s %-10s %-20s %-20s %10s %s\n","TIME", "USERNAME", "PID","COMM", "PPCOMM", "FNAME");
    }
    tracepoint:syscalls:sys_enter_unlinkat,tracepoint:syscalls:sys_enter_unlink
    {
        $pp = curtask->real_parent;
        time("%H:%M:%S\t");
        printf("%-10s %-10u %-10u %-20s %-20s %s    ",  username, uid, pid, comm,  $pp->comm, str(args->pathname));
        $ppp = $pp->parent;
        printf("%-10s\n", $ppp->comm);
    }

Kprobe 版:

#include <linux/dcache.h>
kprobe:vfs_unlink {
    printf("%-10s %-10u %-10u %-20s %s\n", username, uid, pid, comm, str(((struct dentry *)arg1)->d_name.name))
}

kprobe:vfs_rmdir {
    printf("%-10s %-10u %-10u %-20s %s\n", username, uid, pid, comm, str(((struct dentry *)arg1)->d_name.name))
}

参考:https://blog.51cto.com/helloween/5011426

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
BPF and related observability tools give software professionals unprecedented visibility into software, helping them analyze operating system and application performance, troubleshoot code, and strengthen security. BPF Performance Tools: Linux System and Application Observability is the industry’s most comprehensive guide to using these tools for observability. Brendan Gregg, author of the industry’s definitive guide to system performance, introduces powerful new methods and tools for doing analysis that leads to more robust, reliable, and safer code. This authoritative guide: Explores a wide spectrum of software and hardware targets Thoroughly covers open source BPF tools from the Linux Foundation iovisor project’s bcc and bpftrace repositories Summarizes performance engineering and kernel internals you need to understand Provides and discusses 150+ bpftrace tools, including 80 written specifically for this book: tools you can run as-is, without programming — or customize and develop further, using diverse interfaces and the bpftrace front-end You’ll learn how to use BPF (eBPF) tracing tools to analyze CPUs, memory, disks, file systems, networking, languages, applications, containers, hypervisors, security, and the Linux kernel. You’ll move from basic to advanced tools and techniques, producing new metrics, stack traces, custom latency histograms, and more. It’s like having a superpower: with Gregg’s guidance and tools, you can analyze virtually everything that impacts system performance, so you can improve virtually any Linux operating system or application.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值