我的学期项目是网络级反恶意软件 S/W。它的主要组件是 Manager 和 Agent。 代理向管理器提供:
1. CPU usage, Memory usage and B/W usage information
2. Network related Information -
Network Profiling
Function calls from Network Sockets
TCP packets related information
3. Disk Related Information -
I/O monitoring
File Read/Writes
File Attribute changes
4. General Profiling
Function calls
Call Graph
Frequently used system calls
call volume per process
这四个功能中的每一个都以线程的形式实现。我们的平台是 Linux。我们找到了一个名为 systemtap 的工具...
http://sourceware.org/systemtap/SystemTap_Beginners_Guide/useful-systemtap-scripts.html
我们发现这是一个更好的选择,而不是利用 top、ifstat、tcpdump 等 linux 命令。实际上,所有要做的就是从 Agent Java 程序调用脚本或可执行文件。
“systemtap”使用的所有脚本都是用systemtap脚本语言编写的。前端工具(stap)将该脚本转换为C代码,然后将其编译为内核文件。
stap --tmpdir=/home/test/nettop.stp
通过上面的命令,我成功地获得了转换后的C代码文件。但由于依赖性问题,该文件未被编译。
gcc nettop.c nettop.c:10:29: fatal error : runtime_defines.h: 没有那个文件或目录 编译终止。
gcc -B/usr/share/systemtap/runtime/-B/usr/src/kernels/3.3.1-3.fc16.x86_64/include/nettop.c nettop.c:10:29: fatal error : runtime_defines.h: 没有那个文件或目录 编译终止。
gcc --sysroot=/usr/nettop.c nettop.c:10:29: fatal error : runtime_defines.h: 没有那个文件或目录 编译终止。
systemtap 运行时 header 都使用 linux/header 格式,表示 systemtap 的类路径设置为/usr/../../../。 。/包括。将所有标题复制到特定文件夹很容易,但编辑它们以反射(reflect)正确的路径名是不可能的。有 106 个运行时 header 引用了超过一千个 linux header 。
一个。 如何让 gcc 使用特定文件夹作为库?
是否有比此代理架构更好的替代方案?
PS:希望问题不是太含糊。感谢您提前回复。
最佳答案
不要尝试手动编译 systemtap 的中间 C 代码。相反,通过 stap(或通过 staprun 编译的 .ko)运行脚本,并通过 stdout 使用它们的输出。
关于linux - Systemtap 脚本到 C 代码的转换和编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10094468/