<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/fpm.observability.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'fpm.status.php',
    1 => 'Status Page',
    2 => 'Status Page',
  ),
  'up' => 
  array (
    0 => 'fpm.observability.php',
    1 => 'Observability',
  ),
  'prev' => 
  array (
    0 => 'fpm.observability.php',
    1 => 'Observability',
  ),
  'next' => 
  array (
    0 => 'ref.fpm.php',
    1 => 'FPM Functions',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/fpm/status.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="fpm.status" class="sect1">
 <h2 class="title">Status Page</h2>

 <p class="simpara">
  This page provides information on the setup and contents of the FPM status page. See also
  <span class="function"><a href="function.fpm-get-status.php" class="function">fpm_get_status()</a></span>.
 </p>

 <div class="sect2" id="fpm.status.configuration">
  <h3 class="title">Configuration</h3>

  <p class="simpara">
   The FPM status page can be enabled by setting the
   <a href="install.fpm.configuration.php#pm.status-path" class="link">pm.status_path</a> configuration parameter in the FPM pool
   configuration.
  </p>

  <div class="caution"><strong class="caution">Caution</strong>
   <p class="simpara">
    For security the FPM status page should be restricted to internal requests or known client IPs
    only as the page reveals request URLs and information about available resources.
   </p>
  </div>

  <p class="simpara">
   Depending on the web server configuration it might be needed to configure the web server to
   allow requests directly to this path, bypassing any PHP scripts. An example of a configuration
   for Apache with FPM listening on UDS and <code class="literal">pm.status_path</code> set to
   <code class="literal">/fpm-status</code> would look like:
  </p>

  <div class="informalexample">
   <div class="example-contents">
    <div class="apache-confcode"><pre class="apache-confcode">&lt;LocationMatch &quot;/fpm-status&quot;&gt;
 Require local
 ProxyPass &quot;unix:/var/run/php-fpm.sock|fcgi://localhost/&quot;
&lt;/LocationMatch&gt;</pre>
</div>
   </div>

  </div>

  <p class="simpara">
   After reloading or restarting both FPM and the web server the status page will be accessible from
   the browser (as long as the request comes from an allowed IP address if the IP restriction was
   configured).
  </p>
 </div>

 <div class="sect2" id="fpm.status.parameters">
  <h3 class="title">Query Parameters</h3>

  <p class="simpara">
   The format of the status page output can be altered by specifying one of the following query
   parameters:
  </p>

  <ul class="simplelist">
   <li><code class="literal">html</code></li>
   <li><code class="literal">json</code></li>
   <li><code class="literal">openmetrics</code></li>
   <li><code class="literal">xml</code></li>
  </ul>

  <p class="simpara">
   Additional information can also be returned using the <code class="literal">full</code> query parameter.
  </p>

  <p class="simpara">
   Example status page URLs:
  </p>

  <ul class="simplelist">
   <li>
    <code class="literal">https://localhost/fpm-status</code>
    - Brief output in the default text format
   </li>
   <li>
    <code class="literal">https://localhost/fpm-status?full</code>
    - Full output in the default text format
   </li>
   <li>
    <code class="literal">https://localhost/fpm-status?json</code>
    - Brief output in JSON format
   </li>
   <li>
    <code class="literal">https://localhost/fpm-status?html&amp;full</code>
    - Full output in HTML format
   </li>
  </ul>
 </div>

 <div class="sect2" id="fpm.status.contents">
  <h3 class="title">Displayed Information</h3>

  <p class="simpara">
   Date/Time values use the unix timestamp format in JSON and XML output, otherwise they use
   the format resulting in the following example date
   <code class="literal">&quot;03/Jun/2021:07:21:46 +0100&quot;</code>.
  </p>

  <table class="doctable table">
   <caption><strong>Basic information - Always displayed on the status page</strong></caption>
   
    <thead>
     <tr>
      <th>Parameter</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>pool</td>
      <td>The name of the FPM process pool.</td>
     </tr>

     <tr>
      <td>proccess manager</td>
      <td>The process manager type - static, dynamic or ondemand.</td>
     </tr>

     <tr>
      <td>start time</td>
      <td>The date/time that the process pool was last started.</td>
     </tr>

     <tr>
      <td>start since</td>
      <td>The time in seconds since the process pool was last started.</td>
     </tr>

     <tr>
      <td>accepted conn</td>
      <td>The total number of accepted connections.</td>
     </tr>

     <tr>
      <td>listen queue</td>
      <td>The number of requests (backlog) currently waiting for a free process.</td>
     </tr>

     <tr>
      <td>max listen queue</td>
      <td>The maximum number of requests seen in the listen queue at any one time.</td>
     </tr>

     <tr>
      <td>listen queue len</td>
      <td>The maximum allowed size of the listen queue.</td>
     </tr>

     <tr>
      <td>idle processes</td>
      <td>The number of processes that are currently idle (waiting for requests).</td>
     </tr>

     <tr>
      <td>active processes</td>
      <td>The number of processes that are currently processing requests.</td>
     </tr>

     <tr>
      <td>total processes</td>
      <td>The current total number of processes.</td>
     </tr>

     <tr>
      <td>max active processes</td>
      <td>The maximum number of concurrently active processes.</td>
     </tr>

     <tr>
      <td>max children reached</td>
      <td>
       Has the maximum number of processes ever been reached? If so the displayed value is greater than or equal to
       <code class="literal">1</code> otherwise the value is <code class="literal">0</code>.
      </td>
     </tr>

     <tr>
      <td>slow requests</td>
      <td>
       The total number of requests that have hit the configured
       <code class="literal">request_slowlog_timeout</code>.
      </td>
     </tr>

     <tr>
      <td>memory peak</td>
      <td>
       The memory usage peak since FPM started.
      </td>
     </tr>

    </tbody>
   
  </table>


  <table class="doctable table">
   <caption><strong>Per-process information - only displayed in <code class="literal">full</code> output mode</strong></caption>
   
    <thead>
     <tr>
      <th>Parameter</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>pid</td>
      <td>The system PID of the process.</td>
     </tr>

     <tr>
      <td>state</td>
      <td>The state of the process - Idle, Running, ...</td>
     </tr>

     <tr>
      <td>start time</td>
      <td>The date/time at which the process started.</td>
     </tr>

     <tr>
      <td>start since</td>
      <td>The number of seconds since the process started.</td>
     </tr>

     <tr>
      <td>requests</td>
      <td>The total number of requests served.</td>
     </tr>

     <tr>
      <td>request duration</td>
      <td>The total time in microseconds spent serving last request.</td>
     </tr>

     <tr>
      <td>request method</td>
      <td>The HTTP method of the last served request.</td>
     </tr>

     <tr>
      <td>request uri</td>
      <td>
       The URI of the last served request (after webserver processing, it may always be
       <code class="literal">/index.php</code> if you use a front controller pattern redirect).
      </td>
     </tr>

     <tr>
      <td>content length</td>
      <td>The length of the request body, in bytes, of the last request.</td>
     </tr>

     <tr>
      <td>user</td>
      <td>The HTTP user (<code class="literal">PHP_AUTH_USER</code>) of the last request.</td>
     </tr>

     <tr>
      <td>script</td>
      <td>
       The full path of the script executed by the last request. This will be
       <code class="literal">&#039;-&#039;</code> if not applicable (eg. status page requests).
      </td>
     </tr>

     <tr>
      <td>last request cpu</td>
      <td>
       The %cpu of the last request. This will be 0 if the process is not Idle because the
       calculation is done when the request processing is complete.
       The value can exceed 100%, because metric will tell which percentage of the total cpu time was used in the last request -
       takes processes on all cores into account, whereas the 100% is for one core only.
      </td>
     </tr>

     <tr>
      <td>last request memory</td>
      <td>
       The maximum amount of memory consumed by the last request. This will be 0 if the process is
       not Idle because the calculation is done when the request processing is complete.
      </td>
     </tr>

    </tbody>
   
  </table>


  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    All values are specific to the pool and are reset when FPM is restarted.
   </span>
  </p></blockquote>

  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    OpenMetrics format output uses different parameter types to better suit the OpenMetrics format.
    The parameters and descriptions of their values are included in the OpenMetrics format output.
   </span>
  </p></blockquote>
 </div>

 <div class="sect2">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.1.0</td>
      <td>The openmetrics format was added.</td>
     </tr>

    </tbody>
   
  </table>

 </div>
</div><?php manual_footer($setup); ?>