how to view all the php processes running? i need to see the example.php files names

Discussion in 'PHP' started by w47w47, Sep 30, 2010.

  1. #1
    w47w47, Sep 30, 2010 IP
  2. TDub

    TDub Peon

    Messages:
    30
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'd just do something like this:

    
    <?php
    
    $strOutputArray = array();
    $strProcessArray = explode("\n", trim(`ps -ef`));
    
    for ($i = 0; $i < sizeof($strProcessArray); $i++) {
      if ($i == 0)
        $strFieldNameArray = preg_split("#[[:space:]]+#", $strProcessArray[$i]);
      else {
        $strFieldValueArray = preg_split("#[[:space:]]+#", $strProcessArray[$i]);
        $strOutputArray[$i - 1] = array();
        for ($j = 0; $j < sizeof($strFieldNameArray); $j++)
          $strOutputArray[$i - 1][$strFieldNameArray[$j]] = @$strFieldValueArray[$j];
      }
    }
    
    echo '<pre>' . print_r($strOutputArray, true) . '</pre>';
    
    Code (markup):
     
    TDub, Oct 3, 2010 IP
  3. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Use ps - its the same as what WHM uses.

    You can also use "top" if you want to interactively monitor current processes.
    If in doubt, "man ps" will give you the syntax you need to follow

    However, you should also bear in mind that PHP will not run as a process (unless its CLI) as it will be invoked from apache, or your web server
     
    lukeg32, Oct 4, 2010 IP
  4. w47w47

    w47w47 Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    the problem with ps and top is that i get just something like this:


    15414 ? 00:00:00 php-cgi
    15416 ? 00:00:00 php-cgi
    15417 ? 00:00:00 php-cgi
    15418 ? 00:00:00 php-cgi
    15419 ? 00:00:00 php-cgi
    15420 ? 00:00:00 php-cgi
    15421 ? 00:00:00 php-cgi
    15422 ? 00:00:00 php-cgi
    15423 ? 00:00:00 php-cgi
    15424 ? 00:00:00 php-cgi
    15425 ? 00:00:00 php-cgi
    15426 ? 00:00:00 php-cgi
    15427 ? 00:00:00 php-cgi
    15428 ? 00:00:00 php-cgi
    15429 ? 00:00:00 php-cgi
    15430 ? 00:00:01 php-cgi
    15431 ? 00:00:00 php-cgi
    15432 ? 00:00:00 php-cgi
    15433 ? 00:00:01 php-cgi
    15434 ? 00:00:00 php-cgi
    15435 ? 00:00:00 php-cgi
    15436 ? 00:00:00 php-cgi
    15437 ? 00:00:06 php-cgi
    15439 ? 00:00:06 php-cgi
    15440 ? 00:00:06 php-cgi
    15441 ? 00:00:06 php-cgi
    15442 ? 00:00:06 php-cgi
    15443 ? 00:00:00 php-cgi
    23858 ? 00:00:05 php-cgi

    but i want to see which .php files are running. :S

    any ideas?
     
    w47w47, Oct 9, 2010 IP
  5. JoelLarson

    JoelLarson Peon

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Setup a MySQL database and create a memory table? You could insert when the user starts a page execution and have the record removed when it's done being executed. It might take a small performance hit (and fill up your memory really fast if you have a high amount of traffic and low memory), but you can't see what specific pages are running explicitly through PHP.
     
    JoelLarson, Oct 9, 2010 IP