mozartk / process-checker
Get list of running processes by process name, supports Windows and unix, macOS
v1.0.1
2018-05-16 13:44 UTC
Requires
- php: >=5.3.0
- hassankhan/config: ~0.11
- matomo/ini: ~2.0
- mozartk/process-finder: ~1.0
- symfony/yaml: ~2.8
Requires (Dev)
- phpunit/phpunit: ^3.7|~4|~5|~6
This package is auto-updated.
Last update: 2025-01-10 05:10:42 UTC
README
Now you can easily check the process information with php.
Installation
$ composer require mozartk/process-checker
Basic Usage
How to run
First, you need a config file in JSON format.
{ "processList":[ "php-fpm", "httpd" ], "outputMode":"array" //or json,yaml,ini }
And run the php script :
<?php require "vendor/autoload.php"; use mozartk\ProcessChecker\ProcessChecker; $processHandler = new ProcessChecker(); $processHandler->setConfigPath("config.json"); $data = $processHandler->run(); print_r($data);
or you can try without a config file.
<?php require_once "vendor/autoload.php"; use 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);
Results
Array
(
[php-fpm] => Array
(
[0] => Array
(
[name] => /bin/php-fpm
[name_w] =>
[cputime] => 0:22.74
[pid] => 65843
[running] => 1
)
[1] => Array
(
[name] => /bin/php-fpm
[name_w] =>
[cputime] => 0:00.01
[pid] => 65846
[running] => 1
)
...
)
)
If you wants to get Yaml Results, change the outputMode value in config.json to 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 ...
And you can get json results
{ "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 } ] }
And you can get ini type results too
[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
License
Made by mozartk.
The MIT License (MIT). Please see License File for more information.