PHP code example of mozartk / process-checker

1. Go to this page and download the library: Download mozartk/process-checker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mozartk / process-checker example snippets



mozartk\ProcessChecker\ProcessChecker;

$processHandler = new ProcessChecker();
$processHandler->setConfigPath("config.json");
$data = $processHandler->run();

print_r($data); 


mozartk\ProcessChecker\ProcessChecker;

$processHandler = new ProcessChecker();
$processHandler->setOutputMode("array");
$processHandler->setProcessName(array("php", "httpd")); //Parameters must be an array.
$data = $processHandler->run();

print_r($data);

json  
{  
  "processList":[  
    "php-fpm",
    "httpd"
  ],
  "outputMode":"array" //or json,yaml,ini
}
yaml  
php-fpm:
    -
        name: '/bin/php-fpm'
        name_w: false
        cputime: '0:18.63'
        pid: 65843
        running: true
    -
        name: '/bin/php-fpm'
        name_w: false
        cputime: '0:00.00'
        pid: 65846
        running: true
httpd:
    -
        name: '/bin/httpd -D FOREGROUND'
        name_w: false
        cputime: '0:44.38'
        pid: 94
        running: true
...
json  
{  
  "php-fpm":[  
    {  
      "name":"/bin/php-fpm",
      "name_w":false,
      "cputime":"0:18.61",
      "pid":12345,
      "running":true
    }
  ],
  "httpd":[  
    {  
      "name":"/bin/httpd -D FOREGROUND",
      "name_w":false,
      "cputime":"0:44.37",
      "pid":3360,
      "running":true
    },
    {  
      "name":"/bin/httpd -D FOREGROUND",
      "name_w":false,
      "cputime":"0:00.00",
      "pid":8801,
      "running":true
    }
  ]
}
ini  
[php-fpm(65843)]  
name = "/bin/php-fpm"  
name_w = 0  
cputime = "0:18.63"  
pid = 65843  
running = 1  
  
[php-fpm(65846)]  
name = "/bin/php-fpm"  
name_w = 0  
cputime = "0:00.01"  
pid = 65846  
running = 1