Forum Moderators: phranque
Sample top output below -- this isn't a particularly bad case -- when it really gets going the server's load flies up to the 80s and 90s, but this is indicative of the problem:
[root@server1 mytop-1.6]# top
top - 05:29:30 up 5 days, 8:42, 1 user, load average: 1.87, 2.16, 2.02
Tasks: 137 total, 11 running, 126 sleeping, 0 stopped, 0 zombie
Cpu(s): 59.0% us, 41.0% sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 1035704k total, 808868k used, 226836k free, 56724k buffers
Swap: 2096472k total, 129108k used, 1967364k free, 457532k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15974 create99 19 0 17080 5704 3892 R 4.8 0.6 0:00.15 php
15977 create99 19 0 51908 34m 31m R 4.2 3.4 0:00.13 php
15979 create99 19 0 51140 32m 30m R 4.2 3.2 0:00.13 php
15981 create99 19 0 51604 35m 33m R 4.2 3.5 0:00.13 php
15984 create99 19 0 51532 31m 28m R 3.9 3.1 0:00.12 php
15986 create99 19 0 50868 34m 32m R 3.9 3.4 0:00.12 php
4007 nobody 15 0 8556 4256 1484 S 3.6 0.4 1:23.19 httpd
15975 create99 19 0 50828 27m 25m R 3.6 2.8 0:00.11 php
15987 create99 19 0 52516 8712 4388 R 3.6 0.8 0:00.11 php
15983 create99 19 0 51568 26m 24m R 3.2 2.6 0:00.10 php
3931 nobody 15 0 8484 4308 1572 S 2.6 0.4 1:24.89 httpd
15988 create99 18 0 51956 8304 4336 S 2.6 0.8 0:00.08 php
3922 nobody 16 0 8688 4412 1516 S 1.9 0.4 1:25.20 httpd
3923 nobody 15 0 8804 4664 1572 S 1.6 0.5 1:23.41 httpd
3929 nobody 15 0 8796 4516 1528 S 1.6 0.4 1:22.90 httpd
3933 nobody 17 0 9680 5060 1508 S 1.6 0.5 1:26.23 httpd
3942 nobody 15 0 8636 4324 1516 S 1.6 0.4 1:20.91 httpd
4006 nobody 15 0 8928 4704 1528 S 1.6 0.5 1:27.78 httpd
4008 nobody 15 0 8648 4388 1564 S 1.6 0.4 1:26.51 httpd
12455 nobody 15 0 8000 3320 1120 S 1.6 0.3 0:04.37 httpd
3932 nobody 15 0 10648 5480 1388 S 1.3 0.5 1:26.14 httpd
3945 nobody 15 0 8252 3956 1528 S 1.3 0.4 1:23.05 httpd
6455 mysql 15 0 168m 59m 3668 S 1.3 5.9 1:53.38 mysqld
15985 create99 19 0 49524 5404 3520 R 1.0 0.5 0:00.03 php
3920 nobody 16 0 8396 3760 1068 S 0.6 0.4 1:26.29 httpd
13380 root 16 0 3236 916 468 R 0.6 0.1 1:18.96 top
3937 nobody 15 0 8692 4368 1500 S 0.3 0.4 1:25.95 httpd
3944 nobody 15 0 9704 5076 1516 S 0.3 0.5 1:27.47 httpd
15438 nobody 15 0 7880 3032 1108 S 0.3 0.3 0:00.69 httpd
The user in question is create99 and I'm trying to find out how I can find which PHP script is being caused by each of the above processes -- eg 15974. If I try to trace it I get a message saying the process doesn't exist anymore.
Perhaps a bit more explanation on what I'm trying to do would help!
Using the top output I posted in the OP as an example, what I'd like to do is find out what PHP scripts are being called in process 15974 (for example), as I'm hoping by doing that I'll be able to isolate which scripts are causing the problems, and fix them. Narrowing it down just to the user hasn't helped as create99's site has hundreds of diff scripts -- each (or many) of which may be the culprit.
If this is the wrong way to approach this type of troubleshooting, and alternative suggestions would be welcome.
Tks
you might try adding something to log the script name (using the appropriate php server variable [php.net]) and process id [php.net] for each script and then you can consult the log file and search for your process id...
I added a script into a across-the-site include file that wrote all the page addresses and their respective process ID to a logfile. Then I scanned top for processes from the same user that consumed more than 4% of the CPU and then looked for the corresponding entries in the logfile.
Result has been that the majority of the pIDs listed in top are not making it to the logfile, and those that are correspond to a wide variety of scripts, from very simple scripts doing next to nothing to others that are considerably more complicated.
It's all left me a bit more confused, though I think I'm learning...
Result has been that the majority of the pIDs listed in top are not making it to the logfile, and those that are correspond to a wide variety of scripts, from very simple scripts doing next to nothing to others that are considerably more complicated.
it is likely that each included php file spawns a new process.
are you logging all included files or just the top level scripts?
you should be able to access separate environment variables that indicate both top and lowest level included file names and/or paths.