I just encountered an odd situation on a webserver where the load had
become rather high, and top was showing me two apache processes each
consuming > 45% of CPU. Running strace on one of the processes I saw
that it was doing the below (and nothing else, or nothing else strace-
able) in a loop:
open("/etc/hosts", O_RDONLY) = 55
fcntl64(55, F_GETFD) = 0
fcntl64(55, F_SETFD, FD_CLOEXEC) = 0
fstat64(55, {st_mode=S_IFREG|0644, st_size=300, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb6477000
read(55, "127.0.0.1 localhost loc"..., 4096) = 300
read(55, "", 4096) = 0
close(55) = 0
munmap(0xb6477000, 4096) = 0
So, I killed it whereupon the CPU usage of its partner in crime jumped
to over 90% and strace revealed it to be engaged in the same
behaviour, which got it the same treatment, and load is back down to a
sensible figure.
In all likelihood, this was caused by some piece of PHP gone mad but
the question is, what, and how to find out? Given such a situation, is
there any way of mapping a particular apache process to a request?
Niall
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!