Strace is quite simply a tool that traces the execution of system calls. It can trace the execution of a binary from start to end, and output a line of text with the name of the system call, the arguments and the return value for every system call over the lifetime of the process.
1.Find out which config files a program reads on startup
strace
php 2>&1 | grep php.ini
open("/usr/local/bin/php.ini",
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/php.ini",
O_RDONLY) = 4
lstat64("/usr/local/lib/php.ini",
{st_mode=S_IFLNK|0777, st_size=27, ...}) = 0
readlink("/usr/local/lib/php.ini",
"/usr/local/Zend/etc/php.ini", 4096) = 27
lstat64("/usr/local/Zend/etc/php.ini",
{st_mode=S_IFREG|0664, st_size=40971, ...}) = 0
2.What
is that process doing RIGHT NOW?
Ever had a process suddenly eating lots
of CPU? Or had a process seem to be hanging? Then you find the pid, and do
this:
root@dev:~#
strace -p 15427
Process
15427 attached - interrupt to quit
futex(0x402f4900,
FUTEX_WAIT, 2, NULL
Process
15427 detached
3.MySQL with strace
Start MySQL Daemon
service mysqld start
Connect strace to mysqld
ps -elf | grep mysqld (and find out that mysqld is PID 1234)
sudo strace -p 1234 -f
0 comments:
Post a Comment