Announcement

Collapse
No announcement yet.

( Apache ) httpd Process Detail

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ( Apache ) httpd Process Detail

    Hi All,

    My server is running Apache and PHP. When I monitoring my CPU usage by top command, there has few httpd commands/processes consume high CPU usage. I am wondering is there any way can know the detail ( running which PHP ) of the process by referring to the process ID?

    Please help. Thanks.

  • #2
    Press "c"

    Comment


    • #3
      Press "c"?

      Comment


      • #4
        Yep, "top > c" shows you the cmd

        "top > ?" shows you available commands

        Originally posted by top
        Help for Interactive Commands - procps version 3.2.7
        Window 1: Def: Cumulative mode Off. System: Delay 3.0 secs; Secure mode Off.

        Z,B Global: 'Z' change color mappings; 'B' disable/enable bold
        l,t,m Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info
        1,I Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode

        f,o . Fields/Columns: 'f' add or remove; 'o' change display order
        F or O . Select sort field
        <,> . Move sort field: '<' next col left; '>' next col right
        R,H . Toggle: 'R' normal/reverse sort; 'H' show threads
        c,i,S . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time
        x,y . Toggle highlights: 'x' sort field; 'y' running tasks
        z,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')
        u . Show specific user only
        n or # . Set maximum tasks displayed

        k,r Manipulate tasks: 'k' kill; 'r' renice
        d or s Set update interval
        W Write configuration file
        q Quit
        ( commands shown with '.' require a visible task display window )
        Press 'h' or '?' for help with Windows,
        any other key to continue

        Comment


        • #5
          I try to make my question clear, which below is my top output

          PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
          60834 web 1 107 0 171M 152M RUN 6 238.5H 15.23% squid
          7435 web 1 -4 0 40740K 9156K RUN 5 0:00 9.00% httpd
          7395 web 1 97 0 40740K 9216K select 4 0:01 6.60% httpd
          7436 web 1 96 0 40740K 9108K select 3 0:00 6.00% httpd
          With above detail, process with PID 7435 is a Apache process, but is there possible that I can know the process is processing which PHP file?

          Comment


          • #6
            Maybe your setup's different to mine but here's a sample top after pressing "c"

            Originally posted by top
            13415 16454 99 nobody nobody ? 0:00.02 0.0 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13416 16454 99 nobody nobody ? 0:00.03 0.0 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13461 16454 99 nobody nobody ? 0:00.03 0.0 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13472 16454 99 nobody nobody ? 0:00.03 0.7 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13545 16454 99 nobody nobody ? 0:00.03 0.0 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13585 16454 99 nobody nobody ? 0:00.02 0.0 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13734 16454 99 nobody nobody ? 0:00.02 0.0 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13757 16454 99 nobody nobody ? 0:00.01 0.0 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13758 16454 99 nobody nobody ? 0:00.01 0.0 0.2 S /usr/local/apache/bin/httpd -k start -DSSL
            13958 16454 99 nobody nobody ? 0:00.00 0.0 0.1 S /usr/local/apache/bin/httpd -k start -DSSL
            13961 16454 99 nobody nobody ? 0:00.00 0.0 0.1 S /usr/local/apache/bin/httpd -k start -DSSL
            13962 13472 517 a-user a-user ? 0:00.28 9.3 0.8 S /usr/bin/php /home/a-user/public_html/index.php
            An alternative to try is,
            cat /proc/#####/cmdline
            Replace ##### with your PID

            Comment


            • #7
              Actually my server is running FreeBSD, which it is just very similar with Linux. However, I am just beginner level on server stuff thingy, and it is not setup by me too >.<.

              Regarding of your alternative solution, it is not work to me and I believe some configuration is missing. The server do have /proc directory, and I guess I need to proper mount since it is not show when I use command df? And when I use truss -p ##### command which I found on somewhere and it return below error:

              truss: cannot open2 /proc/19293/mem: No such file or directory
              Thanks for your help.

              Comment


              • #8
                /proc is mounted as part of / hence why you don't see it in "df -h".

                I've never heard of truss but I'm guessing that your process has terminated before you've managed to run the command, therefore /19293/ doesn't exist.

                Comment


                • #9
                  So in my case, there has /proc directory, but df -h doesn't show that, what should I do?

                  Thanks.

                  Comment


                  • #10
                    It's normal for it not to show in df -h.

                    Comment


                    • #11
                      Error as below:

                      cat /proc/31997/cmdline
                      cat: /proc/31997/cmdline: No such file or directory
                      ps: The process still exist after I enter above command.

                      I think I miss something since /proc not in the list when I type df. How I can fix it?

                      Thanks.

                      Comment


                      • #12
                        Take a look inside the directory and see what files are available

                        Code:
                        cd /proc/31997/
                        ls -lah | more
                        Replace 31997 with a live PID

                        Originally posted by My terminal
                        root@cl100 [/home]# cd /proc/2971
                        root@cl100 [/proc/2971]# ls -la
                        total 0
                        dr-xr-xr-x 5 avahi avahi 0 Dec 3 07:18 ./
                        dr-xr-xr-x 164 root root 0 Dec 3 07:16 ../
                        dr-xr-xr-x 2 avahi avahi 0 Apr 4 15:09 attr/
                        -r-------- 1 root root 0 Apr 4 15:09 auxv
                        -r--r--r-- 1 root root 0 Apr 4 04:23 cmdline
                        -rw-r--r-- 1 root root 0 Apr 4 15:09 coredump_filter
                        -r--r--r-- 1 root root 0 Apr 4 15:09 cpuset
                        lrwxrwxrwx 1 root root 0 Apr 4 15:09 cwd -> /etc/avahi/
                        -r-------- 1 root root 0 Apr 4 15:09 environ
                        lrwxrwxrwx 1 root root 0 Apr 4 04:25 exe -> /usr/sbin/avahi-daemon*
                        dr-x------ 2 root root 0 Apr 4 15:09 fd/
                        -r-------- 1 root root 0 Apr 4 15:09 limits
                        -rw-r--r-- 1 root root 0 Apr 4 15:09 loginuid
                        -r--r--r-- 1 root root 0 Apr 4 15:09 maps
                        -rw------- 1 root root 0 Apr 4 15:09 mem
                        -r--r--r-- 1 root root 0 Apr 4 15:09 mounts
                        -r-------- 1 root root 0 Apr 4 15:09 mountstats
                        -rw-r--r-- 1 root root 0 Apr 4 15:09 oom_adj
                        -r--r--r-- 1 root root 0 Apr 4 15:09 oom_score
                        lrwxrwxrwx 1 root root 0 Apr 4 15:09 root -> /etc/avahi/
                        -r--r--r-- 1 root root 0 Apr 4 15:09 schedstat
                        -r-------- 1 root root 0 Apr 4 15:09 smaps
                        -r--r--r-- 1 root root 0 Apr 4 04:23 stat
                        -r--r--r-- 1 root root 0 Apr 4 04:25 statm
                        -r--r--r-- 1 root root 0 Apr 4 04:23 status
                        dr-xr-xr-x 3 avahi avahi 0 Apr 4 15:09 task/
                        -r--r--r-- 1 root root 0 Apr 4 15:09 wchan
                        root@cl100 [/proc/2971]# cat /proc/2971/cmdline
                        avahi-daemon: running [cl100.local]
                        root@cl100 [/proc/2971]#

                        Comment


                        • #13
                          Do you have the WHM interface for you server, if so, you can check the Apache and PHP status with specific information.

                          Comment


                          • #14
                            Hm... may I have more information for WHM? Beside that, I found another way to get what I want. Just configure LogFormat to include %P in Apache configuration, then the PID will me recorded in every request.

                            Thanks for all information and advice.

                            Comment


                            • #15
                              I think an httpd process is created for each unique visitor on your page. Sometimes I see a few processes, which I think are equal to the number of people on my site at the time.

                              Comment

                              Working...
                              X