I have a vps with DirectAdmin installed on it. today my server went down for an hour and when I checked the notification center I saw that some of the httpd instance are using a lot of my cpu power.
you can check a part top command below.
what I want to know is which one of my domains are causing this?
top
command result:
top – 07:52:54 up 21:08, 0 users, load average: 61.00, 19.79, 6.98
Tasks: 223 total, 5 running, 218 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.7%us, 0.3%sy, 0.0%ni, 95.6%id, 0.3%wa, 0.0%hi, 0.0%si,
0.0%st Mem: 1026200k total, 1014088k used, 12112k free, 764k buffers Swap: 3002360k total, 1166920k used, 1835440k free,
14084k cachedPID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
12684 apache 20 0 55192 15m 1044 D 2.9 1.5 0:01.10
/usr/sbin/httpd -k start -DSSL
12660 apache 20 0 50248 15m 1324 D 2.7 1.6 0:01.13
/usr/sbin/httpd -k start -DSSL
10782 apache 20 0 58860 15m 1456 R 2.5 1.5 0:37.45
/usr/sbin/httpd -k start -DSSL
12686 apache 20 0 55144 17m 1044 D 2.2 1.7 0:01.04
/usr/sbin/httpd -k start -DSSL
28 root 20 0 0 0 0 R 2.0 0.0 0:00.60 [kswapd0]
12654 apache 20 0 55144 14m 1044 D 2.0 1.5 0:01.03
/usr/sbin/httpd -k start -DSSL
12658 apache 20 0 55144 11m 1044 D 2.0 1.1 0:00.94
/usr/sbin/httpd -k start -DSSL
12669 apache 20 0 55144 18m 1044 D 1.7 1.8 0:01.03
/usr/sbin/httpd -k start -DSSL
12695 apache 20 0 55144 18m 1044 D 1.7 1.8 0:01.05
/usr/sbin/httpd -k start -DSSL
12681 apache 20 0 55176 15m 1044 D 1.5 1.5 0:00.94
/usr/sbin/httpd -k start -DSSL
12670 apache 20 0 55184 13m 1044 D 1.2 1.3 0:00.85
/usr/sbin/httpd -k start -DSSL
12692 apache 20 0 55144 16m 1044 D 1.0 1.7 0:01.00
/usr/sbin/httpd -k start -DSSL
12696 apache 20 0 55144 19m 1044 D 1.0 1.9 0:01.00
/usr/sbin/httpd -k start -DSSL
12700 apache 20 0 56304 7296 1028 D 1.0 0.7 0:00.79
/usr/sbin/httpd -k start -DSSL
12719 apache 20 0 54812 11m 1216 S 0.7 1.2 0:00.60
/usr/sbin/httpd -k start -DSSL
12734 apache 20 0 54804 12m 1212 R 0.7 1.3 0:00.62
/usr/sbin/httpd -k start -DSSL
12772 apache 20 0 54812 20m 1724 R 0.7 2.1 0:00.63
/usr/sbin/httpd -k start -DSSL
Best Answer
As mentioned by the previous answer, looking at a specific Apache process doesn't have a lot of value.
I might suggest that you should alter your httpd.conf settings - either using more efficient processes (e.g. PHP-FPM instead of mod_php) or altering the number of servers/clients/requests).
Typically, in an environment with multiple domains, each domain gets it own user. (This is typically seen if you are running PHP in FastCGI mode, and makes it easy to see which PHP process is using significant resources).
The following is simply for interest sake - it serves little useful purpose in this case:
Should you really want to determine what site a particular process is serving at any given instant, you could run a trace looking for file access. Be advised however, that significant quantities of output will generated very rapidly on a high traffic server.
For instance, the following will show file opens (typically only .htaccess files if you use FastCGI), as well as directory listings, and is enough to identify which domain the process is serving right now:
strace -p PID -e trace=open,lstat64
Example Output:
Alternatively, you can look at the process reads, and grep for 'Host':
strace -p PID -e trace=read -s 100 2>&1 | grep "Host:"
Example Output:
(You might need to make the 'string length' (s) value longer)
Once again, keep in mind that both of these are an 'instant in time' look at what a given process is serving - in the next instant that will change - it is therefore useless for anything beyond curiosity.