Chapter 2. Monitoring and benchmark tools 59
Draft Document for Review May 4, 2007 11:35 am 4285ch02.fm
Example 2-23 Using nmon to record performance data
# nmon -f -s 30 -c 120
The output of the above command will be stored in a text file in the current directory named
<hostname>_date_time.nmon.
For more information on nmon we suggest you visit
http://www-941.haw.ibm.com/collaboration/wiki/display/WikiPtype/nmon
In order to download nmon, visit
http://www.ibm.com/collaboration/wiki/display/WikiPtype/nmonanalyser
2.3.15 strace
The strace command intercepts and records the system calls that are called by a process, as
well as the signals that are received by a process. This is a useful diagnostic, instructional,
and debugging tool. System administrators find it valuable for solving problems with
programs.
To trace a process, specify the process ID (PID) to be monitored:
strace -p <pid>
Example 2-24 shows an example of the output of strace.
Example 2-24 Output of strace monitoring httpd process
[root@x232 html]# strace -p 815
Process 815 attached - interrupt to quit
semop(360449, 0xb73146b8, 1) = 0
poll([{fd=4, events=POLLIN}, {fd=3, events=POLLIN, revents=POLLIN}], 2, -1) = 1
accept(3, {sa_family=AF_INET, sin_port=htons(52534), sin_addr=inet_addr("192.168.1.1")}, [16]) = 13
semop(360449, 0xb73146be, 1) = 0
getsockname(13, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("192.168.1.2")}, [16]) = 0
fcntl64(13, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(13, F_SETFL, O_RDWR|O_NONBLOCK) = 0
read(13, 0x8259bc8, 8000) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=13, events=POLLIN, revents=POLLIN}], 1, 300000) = 1
read(13, "GET /index.html HTTP/1.0\r\nUser-A"..., 8000) = 91
gettimeofday({1084564126, 750439}, NULL) = 0
stat64("/var/www/html/index.html", {st_mode=S_IFREG|0644, st_size=152, ...}) = 0
open("/var/www/html/index.html", O_RDONLY) = 14
mmap2(NULL, 152, PROT_READ, MAP_SHARED, 14, 0) = 0xb7052000
writev(13, [{"HTTP/1.1 200 OK\r\nDate: Fri, 14 M"..., 264}, {"<html>\n<title>\n RedPaper Per"...,
152}], 2) = 416
munmap(0xb7052000, 152) = 0
socket(PF_UNIX, SOCK_STREAM, 0) = 15
connect(15, {sa_family=AF_UNIX, path="/var/run/.nscd_socket"}, 110) = -1 ENOENT (No such file or directory)
close(15) = 0
Here’s another interesting usage. This command reports how much time has been consumed
in the kernel by each system call to execute a command.
strace -c <command>
Attention: While the strace command is running against a process, the performance of
the PID is drastically reduced and should only be run for the time of data collection.