strace

Linux strace命令

我怕爱的太早我们不能终老 提交于 2019-11-27 05:07:48
简介 strace常用来跟踪进程执行时的系统调用和所接收的信号。 在Linux世界,进程不能直接访问硬件设备,当进程需要访问硬件设备(比如读取磁盘文件,接收网络数据等等)时,必须由用户态模式切换至内核态模式,通 过系统调用访问硬件设备。strace可以跟踪到一个进程产生的系统调用,包括参数,返回值,执行消耗的时间。 输出参数含义 root@ubuntu:/usr# strace cat /dev/ null execve( " /bin/cat ", [ " cat ", " /dev/null "], [ /* 22 vars */]) = 0 brk( 0) = 0xab1000 access( " /etc/ld.so.nohwcap ", F_OK) = - 1 ENOENT (No such file or directory) mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, - 1, 0) = 0x7f29379a7000 access( " /etc/ld.so.preload ", R_OK) = - 1 ENOENT (No such file or directory) ... brk( 0) = 0xab1000 brk( 0xad2000) = 0xad2000 fstat(

How to solve “ptrace operation not permitted” when trying to attach GDB to a process?

那年仲夏 提交于 2019-11-27 05:02:53
问题 I'm trying to attach a program with gdb but it returns: Attaching to process 29139 Could not attach to process. If your uid matches the uid of the target process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf ptrace: Operation not permitted. gdb-debugger returns "Failed to attach to process, please check privileges and try again." strace returns "attach: ptrace(PTRACE_ATTACH, ...): Operation not

Centos下的IO监控与分析

╄→尐↘猪︶ㄣ 提交于 2019-11-26 23:54:36
近期要在公司内部做个Linux IO方面的培训, 整理下手头的资料给大家分享下 各种IO监视工具在Linux IO 体系结构中的位置 源自 Linux Performance and Tuning Guidelines.pdf 1 系统级IO监控 iostat   iostat -xdm 1 # 个人习惯 %util 代表磁盘繁忙程度。100% 表示磁盘繁忙, 0%表示磁盘空闲。但是注意,磁盘繁忙不代表磁盘(带宽)利用率高 argrq-sz 提交给驱动层的IO请求大小,一般不小于4K,不大于max(readahead_kb, max_sectors_kb) 可用于判断当前的IO模式,一般情况下,尤其是磁盘繁忙时, 越大代表顺序,越小代表随机 svctm 一次IO请求的服务时间,对于单块盘,完全随机读时,基本在7ms左右,既寻道+旋转延迟时间 注: 各统计量之间关系 ======================================= %util = ( r/s + w/s) * svctm / 1000 # 队列长度 = 到达率 * 平均服务时间 avgrq-sz = ( rMB/s + wMB/s) * 2048 / (r/s + w/s) # 2048 为 1M / 512 ======================================= 总结:

Centos下的IO监控与分析

让人想犯罪 __ 提交于 2019-11-26 23:54:19
近期要在公司内部做个Linux IO方面的培训, 整理下手头的资料给大家分享下 各种IO监视工具在Linux IO 体系结构中的位置 源自 Linux Performance and Tuning Guidelines.pdf 1 系统级IO监控 iostat   iostat -xdm 1 # 个人习惯 %util 代表磁盘繁忙程度。100% 表示磁盘繁忙, 0%表示磁盘空闲。但是注意,磁盘繁忙不代表磁盘(带宽)利用率高 argrq-sz 提交给驱动层的IO请求大小,一般不小于4K,不大于max(readahead_kb, max_sectors_kb) 可用于判断当前的IO模式,一般情况下,尤其是磁盘繁忙时, 越大代表顺序,越小代表随机 svctm 一次IO请求的服务时间,对于单块盘,完全随机读时,基本在7ms左右,既寻道+旋转延迟时间 注: 各统计量之间关系 ======================================= %util = ( r/s + w/s) * svctm / 1000 # 队列长度 = 到达率 * 平均服务时间 avgrq-sz = ( rMB/s + wMB/s) * 2048 / (r/s + w/s) # 2048 为 1M / 512 ======================================= 总结:

Linux下的IO监控与分析

佐手、 提交于 2019-11-26 23:53:41
原文链接 近期要在公司内部做个Linux IO方面的培训, 整理下手头的资料给大家分享下 各种IO监视工具在Linux IO 体系结构中的位置 源自 Linux Performance and Tuning Guidelines.pdf 1 系统级IO监控 iostat   iostat -xdm 1 # 个人习惯 %util 代表磁盘繁忙程度。100% 表示磁盘繁忙, 0%表示磁盘空闲。但是注意,磁盘繁忙不代表磁盘(带宽)利用率高 argrq-sz 提交给驱动层的IO请求大小,一般不小于4K,不大于max(readahead_kb, max_sectors_kb) 可用于判断当前的IO模式,一般情况下,尤其是磁盘繁忙时, 越大代表顺序,越小代表随机 svctm 一次IO请求的服务时间,对于单块盘,完全随机读时,基本在7ms左右,既寻道+旋转延迟时间 注: 各统计量之间关系 ======================================= %util = ( r/s + w/s) * svctm / 1000 # 队列长度 = 到达率 平均服务时间 avgrq-sz = ( rMB/s + wMB/s) 2048 / (r/s + w/s) # 2048 为 1M / 512 ======================================= 总结:

Linux下的IO监控与分析

我怕爱的太早我们不能终老 提交于 2019-11-26 23:53:21
近期要在公司内部做个Linux IO方面的培训, 整理下手头的资料给大家分享下 各种IO监视工具在Linux IO 体系结构中的位置 源自 Linux Performance and Tuning Guidelines.pdf 1 系统级IO监控 iostat   iostat -xdm 1 # 个人习惯 %util 代表磁盘繁忙程度。100% 表示磁盘繁忙, 0%表示磁盘空闲。但是注意,磁盘繁忙不代表磁盘(带宽)利用率高 argrq-sz 提交给驱动层的IO请求大小,一般不小于4K,不大于max(readahead_kb, max_sectors_kb) 可用于判断当前的IO模式,一般情况下,尤其是磁盘繁忙时, 越大代表顺序,越小代表随机 svctm 一次IO请求的服务时间,对于单块盘,完全随机读时,基本在7ms左右,既寻道+旋转延迟时间 注: 各统计量之间关系 ======================================= %util = ( r/s + w/s) * svctm / 1000 # 队列长度 = 到达率 * 平均服务时间 avgrq-sz = ( rMB/s + wMB/s) * 2048 / (r/s + w/s) # 2048 为 1M / 512 ======================================= 总结:

How to trace system calls of a program in Mac OS X

穿精又带淫゛_ 提交于 2019-11-26 19:57:22
问题 I wanted to trace the system calls made by the find command to debug some performance issues however I could not figure out how to do this on Mac OS X Yosemite. How can I trace system calls for an arbitrary program similarly to what strace does on FreeBSD? I am especially interested in tracing file-system related calls. 回答1: You can use dtruss like in sudo dtruss find ~/repo -depth 2 -type d -name '.git' The manual page of that utility will help you to tailor the use of the tool to your needs

Systrace for Windows

这一生的挚爱 提交于 2019-11-26 19:31:59
I'm looking for a Windows equivalent of Systrace or at least strace . I'm aware of StraceNT , but wondering if there are any more alternatives out there. Specifically, I'm looking for a specific way to programmatically enforce system call policies, though this can be after the fact rather than actively stopping them. Is there a good way to do this currently? WinDbg's Logger.exe is the closest to strace: http://msdn.microsoft.com/en-us/library/windows/hardware/ff552060(v=vs.85).aspx EDIT: There's also windbg's wt: http://blogs.msdn.com/b/debuggingtoolbox/archive/2009/10/12/special-command

How should strace be used?

孤者浪人 提交于 2019-11-26 11:26:42
A colleague once told me that the last option when everything has failed to debug on Linux was to use strace . I tried to learn the science behind this strange tool, but I am not a system admin guru and I didn’t really get results. So, What is it exactly and what does it do? How and in which cases should it be used? How should the output be understood and processed? In brief, in simple words , how does this stuff work? John Mulder Strace Overview strace can be seen as a light weight debugger. It allows a programmer / user to quickly find out how a program is interacting with the OS. It does

磁盘优化思路

折月煮酒 提交于 2019-11-26 10:14:31
磁盘优化思路 性能定位套路 和之前类似,我们不可能出现性能问题就把所有工具都跑一遍,而是先运行那几个支持指标较多的工具,如 top,iostat,vmstat等来缩小范围 先用top, iostat 发现磁盘 I/O 性能瓶颈; 再借助 iotop, pidstat 等定位出导致瓶颈的进程; 随后用strace, lsof等分析进程的 I/O 行为; 最后,结合应用程序的原理,分析这些 I/O 的来源。 性能优化思路 由于影响磁盘I/O性能的因素众多,我们对磁盘I/O优化分应用程序,文件系统,磁盘三方面来说 1.应用程序优化 应用程序处于整个 I/O 栈的最上端,它可以通过系统调用,来调整 I/O 模式(如顺序还是随机、同步还是异步), 同时,它也是 I/O 数据的最终来源。 在我看来,可以有这么几种方式来优化应用程序的 I/O 性能: 1).可以用追加写代替随机写,减少寻址开销,加快 I/O 写的速度。 2).可以借助缓存 I/O ,充分利用系统缓存,降低实际 I/O 的次数。 3).可以在应用程序内部构建自己的缓存,或者用 Redis 这类外部缓存系统。这样,一方面,能在应用程序内部,控制缓存的数据和生命周期;另一方面,也能降低其他应用程序使用缓存对自身的影响。 4).在需要频繁读写同一块磁盘空间时,可以用 mmap 代替 read/write,减少内存的拷贝次数。 5)