Welcome to Centmin Mod Community
Become a Member

Featured PHP-FPM How to configure PHP-FPM Status Monitoring with Nixstats & Nginx Amplify

Discussion in 'Centmin Mod Insights' started by eva2000, Feb 19, 2018.

Thread Status:
Not open for further replies.
  1. eva2000

    eva2000 Administrator Staff Member

    53,771
    12,155
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,704
    Local Time:
    1:19 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    This guide explains how to configure and setup PHP-FPM status monitoring with Nixstats and Nginx Amplify monitoring service. Centmin Mod installed PHP-FPM server has support for PHP-FPM status monitoring via 127.0.0.1/phpstatus within SSH but you need to enable it first before following the respective setup and configuration guides by Nixstats and Nginx Amplify.

    PHP-FPM Status Metrics Setup


    • PHP-FPM status is disabled by default so you need to enable it as per official instructions here.
    • Nginx Amplify official PHP-FPM status monitoring instructions are located here and on official Githut repo here.
    • Nixstats official PHP-FPM status monitoring instructions are located here. Only difference is the port used 80 vs 8080 and the location path to where PHP-FPM status is in Centmin Mod vs Nixstats documentation is /phpstatus vs /status_phpfpm
      example config at /etc/nixstats.ini
      Code (Text):
      ;[phpfpm]
      ;enabled = yes
      ;status_page_url = http://127.0.0.1:8080/status_phpfpm?json
      

      change to
      Code (Text):
      [phpfpm]
      enabled = yes
      status_page_url = http://127.0.0.1:80/phpstatus?json
      

      run test command
      Code (Text):
      nixstatsagent --test phpfpm

      output
      Code (Text):
      nixstatsagent --test phpfpm
      phpfpm:
      {
          "accepted_conn": 476, 
          "accepted_conn_per_second": 0.0, 
          "active_processes": 1, 
          "idle_processes": 15, 
          "listen_queue": 0, 
          "listen_queue_len": 511, 
          "max_active_processes": 36, 
          "max_children_reached": 0, 
          "max_listen_queue": 0, 
          "pool": "www", 
          "process_manager": "static", 
          "slow_requests": 0, 
          "start_since": 286949, 
          "start_time": 1554703827, 
          "total_processes": 16
      }
      

      then restart service
      Code (Text):
      service nixstatsagent restart

      check direct /phpstatus is working
      i.e.
      Code (Text):
      wget -qO- http://127.0.0.1:80/phpstatus?json 
      {"pool":"www","process manager":"ondemand","start time":1518976087,"start since":38,"accepted conn":1,"listen queue":0,"max listen queue":0,"listen queue len":511,"idle processes":0,"active processes":1,"total processes":1,"max active processes":1,"max children reached":0,"slow requests":0}
      
    Once PHP-FPM status is enabled on Centmin Mod server, you can query it in SSH session via curl, wget or lynx. Examples:
    Code (Text):
    curl -s http://127.0.0.1/phpstatus
    pool:                 www
    process manager:      ondemand
    start time:           18/Feb/2018:17:48:07 +0000
    start since:          14028
    accepted conn:        5036156
    listen queue:         0
    max listen queue:     29
    listen queue len:     511
    idle processes:       0
    active processes:     1
    total processes:      1
    max active processes: 17
    max children reached: 1
    slow requests:        0
    

    Code (Text):
    lynx --dump  http://127.0.0.1/phpstatus
    pool:                 www
    process manager:      ondemand
    start time:           18/Feb/2018:17:48:07 +0000
    start since:          14066
    accepted conn:        5036160
    listen queue:         0
    max listen queue:     29
    listen queue len:     511
    idle processes:       0
    active processes:     1
    total processes:      1
    max active processes: 17
    max children reached: 1
    slow requests:        0
    

    Then follow either Nginx Amplify official PHP-FPM status monitoring or Nixstats official PHP-FPM status monitoring configuration instructions paying attention to your correct /phpstatus path and correct port = 80 set in Nixstats config file at /etc/nixstats.ini.


    Checking Nixstats PHP-FPM Monitoring Status



    Then to check if Nixstats PHP-FPM monitoring is working as per documentation run the test PHP-FPM command.
    Code (Text):
    nixstatsagent --test phpfpm
    phpfpm:
    {
        "accepted_conn": 3,
        "accepted_conn_per_second": 0.0,
        "active_processes": 1,
        "idle_processes": 0,
        "listen_queue": 0,
        "listen_queue_len": 511,
        "max_active_processes": 1,
        "max_children_reached": 0,
        "max_listen_queue": 0,
        "pool": "www",
        "process_manager": "ondemand",
        "slow_requests": 0,
        "start_since": 821,
        "start_time": 1518976087,
        "total_processes": 1
    }
    


    Then once confirmed working, you need create a new custom dashboard and then assign and setup custom plugin metrics graphs for your PHP-FPM status metrics to that newly created custom dashboard.

    upload_2018-2-19_6-6-51.png

    nixstats-phpfpm-01.png

    nixstats-phpfpm-02.png

    Checking Nginx Amplify PHP-FPM Monitoring Status



    Then to check if Nginx Amplify PHP-FPM monitoring just log into your Amplify dashboard and check out the php-fpm dashboard tab. The default PHP-FPM dashboard doesn't show all PHP-FPM status metrics.

    So you need to create your own custom dashboards and add your own graphs to them.

    upload_2018-2-19_4-40-35.png

    Custom Nginx Amplify dashboard focusing on Nginx, PHP-FPM and system stats

    nginx-amplify-dbd1-01.png

    nginx-amplify-dbd1-02.png
     
    Last edited: Sep 29, 2018
  2. eva2000

    eva2000 Administrator Staff Member

    53,771
    12,155
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,704
    Local Time:
    1:19 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+

    Nginx Amplify Metric Alerts



    Nginx Amplify monitoring service also supports setting on individual metric alerts which you can setup to email and notify you once a threshold is reached. I usually setup an email contact and a pushover email for mobile device notifications.

    For example get notified when PHP-FPM max children goes over 0 in past 10 minutes.

    nginx-amplify-dbd1-metric-alerts-00.png
    nginx-amplify-dbd1-metric-alerts-01.png

    nginx-amplify-dbd1-metric-alerts-02.png
     
Thread Status:
Not open for further replies.