본문 바로가기

리눅스

[리눅스] zabbix(zabbix-agent) php-fpm의 성능 상태를 모니터링하는 방법

반응형

zabbix(zabbix-agent) php-fpm의 성능 상태를 모니터링하는 방법

php-fpm(www.conf) 설정

$ cat /etc/php-fpm.d/www.conf | grep pm.status_path
pm.status_path = /status

nginx(default.conf) 설정

$ cat /etc/nginx/conf.d/default.conf
...
    # nginx, php-fpm status
    location ~ ^/(status|ping)$ {
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_index index.php;
        include fastcgi_params;
        allow 127.0.0.1;
        deny all;
        access_log off;
    }
...

curl 테스트

curl -s http://127.0.0.1/status?xml
curl -s http://127.0.0.1/status
$ curl -s http://127.0.0.1/status
pool:                 www
process manager:      dynamic
start time:           14/Mar/2023:14:35:44 +0900
start since:          4231
accepted conn:        7048
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       15
active processes:     1
total processes:      16
max active processes: 6
max children reached: 0
slow requests:        0

zabbix agent 설정

zabbix_agentd.conf 설정 확인

$ cat /etc/zabbix_agentd.conf | grep ^Include
Include=/etc/zabbix_agentd.conf.d/*.conf

userparameter_phpfpm.conf 파일 생성

cd /etc/zabbix_agentd.conf.d
vim userparameter_phpfpm.conf
UserParameter=php-fpm.status[*],/usr/bin/curl -s "http://127.0.0.1/status?xml" | grep "<$1>" | awk -F'>'awk -F'<|>' '{print $$3}'

zabbix-agent 재시작

systemctl restart zabbix-agent

item(zabbix_agentd) 테스트

$ curl http://127.0.0.1/status?xml
<?xml version="1.0" ?>
<status>
<pool>www</pool>
<process-manager>dynamic</process-manager>
<start-time>1678772144</start-time>
<start-since>5313</start-since>
<accepted-conn>9572</accepted-conn>
<listen-queue>0</listen-queue>
<max-listen-queue>0</max-listen-queue>
<listen-queue-len>0</listen-queue-len>
<idle-processes>14</idle-processes>
<active-processes>2</active-processes>
<total-processes>16</total-processes>
<max-active-processes>6</max-active-processes>
<max-children-reached>0</max-children-reached>
<slow-requests>0</slow-requests>
zabbix_agentd -t php-fpm.status[active-processes]
$ zabbix_agentd -t php-fpm.status[active-processes]
php-fpm.status[active-processes]              [t|2]

zabbix server(UI) 설정

템플릿 추가

모니터링 화면

 

참고URL

- Zabbix + PHP-FPM : https://www.zabbix.com/la/integrations/phpfpm

 

728x90
반응형