這是本文件的舊版!


安裝 PHP-FPM Agent 的方式

  • 這是 SNMP Extend
  • 設定啟動 PHP-FPM 的狀態頁面
    vi /etc/php-fpm.d/www.conf
    :
    pm.status_path = /status
    :

    檢查沒問題就重新啟動 php-fpm 服務

    php-fpm -t

    <xtermrtf>

[04-Jul-2020 23:56:30] NOTICE: configuration file /etc/php-fpm.conf test is successful </xtermrtf>

systemctl restart php-fpm
  • 設定 nginx php-fpm status 頁面讀取方式
    vi /etc/nginx/conf.d/default.conf 
    :
    location ~ ^/(status|ping)$ {
            allow 127.0.0.1;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
    }
    :

    重新啟動 nginx

    systemctl restart nginx
  • 檢查讀取 PHP-FPM 狀態頁面
    curl http://localhost/status?full

    正確結果會類似以下訊息<xtermrtf>

pool: www process manager: dynamic start time: 04/Jul/2020:23:57:38 +0800 start since: 433 accepted conn: 117 listen queue: 0 max listen queue: 0 listen queue len: 511 idle processes: 6 active processes: 1 total processes: 7 max active processes: 2 max children reached: 0 slow requests: 0

pid: 13849 state: Idle start time: 04/Jul/2020:23:57:38 +0800 start since: 433 : : last request cpu: 0.00 last request memory: 0

pid: 13863 state: Idle start time: 04/Jul/2020:23:58:05 +0800 start since: 406 requests: 15 request duration: 438334 request method: GET request URI: /index.php content length: 0 user: - script: /var/www/html/index.php last request cpu: 43.35 last request memory: 2097152 </xtermrtf>

  • 至 PHP-FPM 主機內安裝
    wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O /etc/snmp/phpfpmsp
    chmod +x /etc/snmp/phpfpmsp
  • 確認 phpfpmsp 可以正確執行
    /etc/snmp/phpfpmsp

    如果正確執行應該可以看到類似的訊息<xtermrtf>

www 04/Jul/2020:23:57:38 +0800 534 150 0 0 511 6 1 7 2 0 0 </xtermrtf>

  • 修改 snmpd 設定
    vi /etc/snmp/snmpd.conf
    :
    extend phpfpmsp /etc/snmp/phpfpmsp

    重新啟動 snmpd

    systemctl restart snmpd
  • tech/librenms/php-fpm_agent.1593942861.txt.gz
  • 上一次變更: 2020/07/05 17:54
  • jonathan_tsai