PHP Function who returns linux processlist

function getProcessList()                                                                                                                                                    
{                                                                               
     exec("ps ax",$processes); unset($processes[0]);                         
                                                                                       
     foreach ($processes as $_)                                              
     {                                                                       
          preg_match("/[ ]*([0-9]+)[ ]*(.+? )[ ]*(.+? )[ ]*([0-9]+:[0-9]+)[ ]*(.+)/",$_,$matches);
          $return[] = array(                                              
                 "pid" => $matches[1],                                   
                 "tty" => $matches[2],                                   
                 "stat" => $matches[3],                                  
                 "time" => $matches[4],                                  
                 "command" => $matches[5]                                
          );                                                              
     }                                                                       
     return $return;                                                         
}

 

Dette indlæg blev udgivet i Knowledge Base, Old Base, Programmering. Bogmærk permalinket.

Skriv et svar