How to get a free amount of free apaches in php

In php, how can I get the number of currently available apache children ( status = SERVER_READYon the apache board)?

I really hope there is an easy way to do this in php that I am missing.

+3
source share
2 answers

You can execute a shell command ps aux | grep httpdor ps aux | grep apacheand count the number of lines in the output.

exec('ps aux | grep apache', $output);
$processes = count($output);

I'm not sure what status in the status column indicates that it is ready to accept the connection, but you can filter it to get the number of ready-made processes.

+2
source

If you have access to the Apache server status page, try using the "auto" flag:

http://yourserver/server-status?auto

. , "IdleWorkers". PHP5 , . , , cURL , , .

<?php

$status = file('http://yourserver/server-status?auto');
foreach ($status as $line) {
  if (substr($line, 0, 10) == 'IdleWorkers') {
    $idle_workers = trim(substr($line, 12));
    print $idle_workers;
    break;
  }
}

?>
+1

Source: https://habr.com/ru/post/1696908/


All Articles