差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

最後一次修改 兩邊的下次修訂版
tech:librenms:php-fpm_agent [2020/07/05 00:07] – 建立 jonathan_tsaitech:librenms:php-fpm_agent [2020/07/05 17:54] jonathan_tsai
行 1: 行 1:
 +====== 安裝 PHP-FPM Agent 的方式 ======
 +  * 返回 [[tech:librenms]]
  
 +  * 這是 SNMP Extend
 +
 +  * 設定啟動 PHP-FPM 的狀態頁面<code sh>
 +vi /etc/php-fpm.d/www.conf</code><file>
 +:
 +pm.status_path = /status
 +:
 +</file>檢查沒問題就重新啟動 php-fpm 服務<code sh>
 +php-fpm -t</code><xtermrtf>
 +[04-Jul-2020 23:56:30] NOTICE: configuration file /etc/php-fpm.conf test is successful
 +</xtermrtf><code sh>
 +systemctl restart php-fpm
 +</code>
 +  * 設定 nginx php-fpm status 頁面讀取方式<code sh>
 +vi /etc/nginx/conf.d/default.conf 
 +</code><file>
 +:
 +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;
 +}
 +:
 +</file>重新啟動 nginx <code sh>
 +systemctl restart nginx
 +</code>
 +  * 檢查讀取 PHP-FPM 狀態頁面<code sh>
 +curl http://localhost/status?full</code>正確結果會類似以下訊息<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 主機內安裝 <code sh>
 +wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpmsp -O /etc/snmp/phpfpmsp
 +chmod +x /etc/snmp/phpfpmsp
 +</code>
 +  * 確認 phpfpmsp 可以正確執行<code sh>
 +/etc/snmp/phpfpmsp</code> 如果正確執行應該可以看到類似的訊息<xtermrtf>
 +www
 +04/Jul/2020:23:57:38 +0800
 +534
 +150
 +0
 +0
 +511
 +6
 +1
 +7
 +2
 +0
 +0
 +</xtermrtf>
 +  * 修改 snmpd 設定<code>
 +vi /etc/snmp/snmpd.conf</code><file>
 +:
 +extend phpfpmsp /etc/snmp/phpfpmsp
 +</file>重新啟動 snmpd <code sh>
 +systemctl restart snmpd
 +</code>
 +
 +===== 參考網址 =====
 +  * https://docs.librenms.org/Extensions/Applications/#php-fpm
 +  * https://www.tecmint.com/enable-monitor-php-fpm-status-in-nginx/
 +
 +{{tag>librenms agent snmp_ext}}
  • tech/librenms/php-fpm_agent.txt
  • 上一次變更: 2021/01/16 14:41
  • jonathan