search
HomeBackend DevelopmentPHP Tutorialzabbix 监控 nginx 跟 php-fpm

zabbix 监控 nginx 和 php-fpm

监控常规的任务自然少不了 nginx 和 php-fpm 的监控,最近也是重新开始整理 zabbix,重新学习之,里面的脚本,配置文件以及模板都来源《zabbix 企业级分布式监控系统》一书,根据自身环境适当修改

一、监控 nginx server

1.1 配置 nginx 和 php-fpm

php-fpm 中 [www] 段中配置文件新增

<span style="height: 20px;" class="line">1</span><span style="height: 20px;" class="line">2</span>
<span style="height: 20px;" class="line">[www]</span><span style="height: 20px;" class="line">pm<span class="class">.status_path</span> = /fpm_status.php</span>

?

nginx 配置新增 server 段

<span style="height: 20px;" class="line">1</span><span style="height: 20px;" class="line">2</span>3456789101112131415161718
<span style="height: 20px;" class="line"><span style="color: #3e999f;" class="title">server</span> {</span><span style="height: 20px;" class="line">    <span style="color: #3e999f;" class="title">listen</span>  <span style="color: #f5871f;" class="number">127.0.0.1:80</span>;</span><span style="height: 20px;" class="line">    <span style="color: #3e999f;" class="title">allow</span> <span style="color: #f5871f;" class="number">127.0.0.1</span>;</span><span style="height: 20px;" class="line">    <span style="color: #3e999f;" class="title">deny</span> all;			<span style="color: #8e908c;" class="comment"># 这里两行控制权限</span></span><span style="height: 20px;" class="line">    <span style="color: #8e908c;" class="comment"># 开启 nginx 状态页</span></span><span style="height: 20px;" class="line">    <span style="color: #3e999f;" class="title">location</span> /nginxstatus {</span><span style="height: 20px;" class="line">        <span style="color: #3e999f;" class="title">stub_status</span> <span style="color: #f5871f;" class="built_in">on</span>;</span><span style="height: 20px;" class="line">        <span style="color: #3e999f;" class="title">access_log</span> <span style="color: #f5871f;" class="built_in">off</span>;</span><span style="height: 20px;" class="line">    }</span><span style="height: 20px;" class="line">	<span style="color: #8e908c;" class="comment"># 开启 php-fpm 状态页</span></span><span style="height: 20px;" class="line">    <span style="color: #3e999f;" class="title">location</span> <span style="color: #c82829;" class="regexp">~ ^/(fpm_status)</span> {</span><span style="height: 20px;" class="line">            <span style="color: #3e999f;" class="title">fastcgi_pass</span> <span style="color: #f5871f;" class="number">127.0.0.1:9000</span>;</span><span style="height: 20px;" class="line">            <span style="color: #3e999f;" class="title">fastcgi_index</span> index.php;</span><span style="height: 20px;" class="line">            <span style="color: #3e999f;" class="title">include</span> fastcgi.conf;</span><span style="height: 20px;" class="line">    }</span><span style="height: 20px;" class="line">}</span>

?

访问测试,确保可以查看状态信息

<span style="height: 20px;" class="line">1</span><span style="height: 20px;" class="line">2</span>
<span style="height: 20px;" class="line">curl <span style="color: #718c00;" class="string">http:</span><span style="color: #8e908c;" class="comment">//127.0.0.1/nginxstatus</span></span><span style="height: 20px;" class="line">curl <span style="color: #718c00;" class="string">http:</span><span style="color: #8e908c;" class="comment">//127.0.0.1/fpm_status.php</span></span>

1.2 配置检测脚本和 userparameter

我配置了 agent 主动发送数据到 server 的 active 模式

首先看目录结构

<span style="height: 20px;" class="line">1</span><span style="height: 20px;" class="line">2</span>3456789
<span style="height: 20px;" class="line"># tree /etc/zabbix/</span><span style="height: 20px;" class="line">/etc/zabbix/</span><span style="height: 20px;" class="line">├── scripts</span><span style="height: 20px;" class="line">│?? ├── check_nginx_status.<span style="color: #8959a8;" class="keyword">sh</span></span><span style="height: 20px;" class="line">│?? └── check_phpfpm.<span style="color: #8959a8;" class="keyword">sh</span></span><span style="height: 20px;" class="line">├── zabbix_agentd.<span style="color: #8959a8;" class="keyword">conf</span></span><span style="height: 20px;" class="line">└── zabbix_agentd.<span style="color: #f5871f;" class="literal">d</span></span><span style="height: 20px;" class="line">    ├── userparameter_nginx.<span style="color: #8959a8;" class="keyword">conf</span></span><span style="height: 20px;" class="line">    └── userparameter_phpfpm.<span style="color: #8959a8;" class="keyword">conf</span></span>

?

下面分别对应每个文件

  • userparameter_nginx.conf
<span style="height: 20px;" class="line">1</span><span style="height: 20px;" class="line">2</span>34567
<span style="height: 20px;" class="line">UserParameter=nginx<span class="class">.accepts</span>,/etc/zabbix/scripts/check_nginx_status<span class="class">.sh</span> accepts</span><span style="height: 20px;" class="line">UserParameter=nginx<span class="class">.handled</span>,/etc/zabbix/scripts/check_nginx_status<span class="class">.sh</span> handled</span><span style="height: 20px;" class="line">UserParameter=nginx<span class="class">.requests</span>,/etc/zabbix/scripts/check_nginx_status<span class="class">.sh</span> requests</span><span style="height: 20px;" class="line">UserParameter=nginx<span class="class">.connections</span><span class="class">.active</span>,/etc/zabbix/scripts/check_nginx_status<span class="class">.sh</span> active</span><span style="height: 20px;" class="line">UserParameter=nginx<span class="class">.connections</span><span class="class">.reading</span>,/etc/zabbix/scripts/check_nginx_status<span class="class">.sh</span> reading</span><span style="height: 20px;" class="line">UserParameter=nginx<span class="class">.connections</span><span class="class">.writing</span>,/etc/zabbix/scripts/check_nginx_status<span class="class">.sh</span> writing</span><span style="height: 20px;" class="line">UserParameter=nginx<span class="class">.connections</span><span class="class">.waiting</span>,/etc/zabbix/scripts/check_nginx_status<span class="class">.sh</span> waiting</span>
  • userparameter_phpfpm.conf
<span style="height: 20px;" class="line">1</span><span style="height: 20px;" class="line">2</span>3456789101112
<span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.pool</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> pool</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.process</span><span class="class">.manager</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> process_manager</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.start</span><span class="class">.since</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> start_since</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.accepted</span><span class="class">.conn</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> accepted_conn</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.listen</span><span class="class">.queue</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> listen_queue</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.max</span><span class="class">.listen</span><span class="class">.queue</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> max_listen_queue</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.listen</span><span class="class">.queue</span><span class="class">.len</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> listen_queue_len</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.idle</span><span class="class">.processes</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> idle_processes</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.active</span><span class="class">.processes</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> active_processes</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.total</span><span class="class">.processes</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> total_processes</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.max</span><span class="class">.active</span><span class="class">.processes</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> max_active_processes</span><span style="height: 20px;" class="line">UserParameter=phpfpm<span class="class">.status</span><span class="class">.max</span><span class="class">.children</span><span class="class">.reached</span>,/etc/zabbix/scripts/check_phpfpm<span class="class">.sh</span> max_children_reached</span>
  • check_nginx_status.sh
<span style="height: 20px;" class="line">1</span><span style="height: 20px;" class="line">2</span>3456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
<span style="height: 20px;" class="line"><span class="shebang">#!/bin/bash</span></span><span style="height: 20px;" class="line"><span style="color: #f5871f;" class="built_in">source</span> /etc/bashrc >/dev/null <span style="color: #f5871f;" class="number">2</span>>&<span style="color: #f5871f;" class="number">1</span></span><span style="height: 20px;" class="line"><span style="color: #f5871f;" class="built_in">source</span> /etc/profile  >/dev/null <span style="color: #f5871f;" class="number">2</span>>&<span style="color: #f5871f;" class="number">1</span></span><span style="height: 20px;" class="line">nginxstatus=http://<span style="color: #f5871f;" class="number">127.0</span>.<span style="color: #f5871f;" class="number">0.1</span>/nginxstatus</span><span style="height: 20px;" class="line"><span style="color: #8e908c;" class="comment"># Functions to return nginx stats</span></span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">function</span> checkavailable {</span><span style="height: 20px;" class="line">    code=$(curl -o /dev/null <span class="operator">-s</span> -w %{http_code} <span style="color: #c82829;" class="variable">${nginxstatus}</span>)</span><span style="height: 20px;" class="line">    <span style="color: #8959a8;" class="keyword">if</span> [ <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">${code}</span>"</span> == <span style="color: #718c00;" class="string">"200"</span> ]</span><span style="height: 20px;" class="line">    <span style="color: #8959a8;" class="keyword">then</span></span><span style="height: 20px;" class="line">        <span style="color: #f5871f;" class="built_in">return</span> <span style="color: #f5871f;" class="number">1</span></span><span style="height: 20px;" class="line">    <span style="color: #8959a8;" class="keyword">else</span></span><span style="height: 20px;" class="line">        <span style="color: #f5871f;" class="built_in">echo</span>  <span style="color: #f5871f;" class="number">0</span></span><span style="height: 20px;" class="line">    <span style="color: #8959a8;" class="keyword">fi</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">function</span> active {</span><span style="height: 20px;" class="line">    checkavailable|| curl <span class="operator">-s</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">${nginxstatus}</span>"</span> | grep <span style="color: #718c00;" class="string">'Active'</span> | awk <span style="color: #718c00;" class="string">'{print $3}'</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">function</span> reading {</span><span style="height: 20px;" class="line">    checkavailable|| curl <span class="operator">-s</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">${nginxstatus}</span>"</span> | grep <span style="color: #718c00;" class="string">'Reading'</span> | awk <span style="color: #718c00;" class="string">'{print $2}'</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">function</span> writing {</span><span style="height: 20px;" class="line">    checkavailable|| curl <span class="operator">-s</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">${nginxstatus}</span>"</span> | grep <span style="color: #718c00;" class="string">'Writing'</span> | awk <span style="color: #718c00;" class="string">'{print $4}'</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">function</span> waiting {</span><span style="height: 20px;" class="line">    checkavailable|| curl <span class="operator">-s</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">${nginxstatus}</span>"</span> | grep <span style="color: #718c00;" class="string">'Waiting'</span> | awk <span style="color: #718c00;" class="string">'{print $6}'</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">function</span> accepts {</span><span style="height: 20px;" class="line">    checkavailable|| curl <span class="operator">-s</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">${nginxstatus}</span>"</span> | awk NR==<span style="color: #f5871f;" class="number">3</span> | awk <span style="color: #718c00;" class="string">'{print $1}'</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">function</span> handled {</span><span style="height: 20px;" class="line">    checkavailable|| curl <span class="operator">-s</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">${nginxstatus}</span>"</span> | awk NR==<span style="color: #f5871f;" class="number">3</span> | awk <span style="color: #718c00;" class="string">'{print $2}'</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">function</span> requests {</span><span style="height: 20px;" class="line">    checkavailable|| curl <span class="operator">-s</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">${nginxstatus}</span>"</span> | awk NR==<span style="color: #f5871f;" class="number">3</span> | awk <span style="color: #718c00;" class="string">'{print $3}'</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">case</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">$1</span>"</span> <span style="color: #8959a8;" class="keyword">in</span></span><span style="height: 20px;" class="line">    active)</span><span style="height: 20px;" class="line">        active</span><span style="height: 20px;" class="line">        ;;</span><span style="height: 20px;" class="line">    reading)</span><span style="height: 20px;" class="line">        reading</span><span style="height: 20px;" class="line">        ;;</span><span style="height: 20px;" class="line">    writing)</span><span style="height: 20px;" class="line">        writing</span><span style="height: 20px;" class="line">        ;;</span><span style="height: 20px;" class="line">    waiting)</span><span style="height: 20px;" class="line">        waiting</span><span style="height: 20px;" class="line">        ;;</span><span style="height: 20px;" class="line">    accepts)</span><span style="height: 20px;" class="line">        accepts</span><span style="height: 20px;" class="line">        ;;</span><span style="height: 20px;" class="line">    handled)</span><span style="height: 20px;" class="line">        handled</span><span style="height: 20px;" class="line">        ;;</span><span style="height: 20px;" class="line">    requests)</span><span style="height: 20px;" class="line">        requests</span><span style="height: 20px;" class="line">        ;;</span><span style="height: 20px;" class="line">    *)</span><span style="height: 20px;" class="line">        <span style="color: #f5871f;" class="built_in">echo</span> <span style="color: #718c00;" class="string">"Usage: <span style="color: #c82829;" class="variable">$0</span> {active |reading |writing |waiting |accepts |handled |requests }"</span></span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">esac</span></span>
  • check_phpfpm.sh
<span style="height: 20px;" class="line">1</span><span style="height: 20px;" class="line">2</span>3456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
<span style="height: 20px;" class="line"><span class="shebang">#!/bin/bash</span></span><span style="height: 20px;" class="line"><span style="color: #f5871f;" class="built_in">source</span> /etc/bashrc >/dev/null <span style="color: #f5871f;" class="number">2</span>>&<span style="color: #f5871f;" class="number">1</span></span><span style="height: 20px;" class="line"><span style="color: #f5871f;" class="built_in">source</span> /etc/profile  >/dev/null <span style="color: #f5871f;" class="number">2</span>>&<span style="color: #f5871f;" class="number">1</span></span><span style="height: 20px;" class="line">LOG_FILE=/var/<span style="color: #f5871f;" class="built_in">log</span>/zabbix/phpfpmstatus.log</span><span style="height: 20px;" class="line">curl http://<span style="color: #f5871f;" class="number">127.0</span>.<span style="color: #f5871f;" class="number">0.1</span>/fpm_status.php ><span style="color: #c82829;" class="variable">${LOG_FILE}</span> <span style="color: #f5871f;" class="number">2</span>>&<span style="color: #f5871f;" class="number">1</span></span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">pool</span></span>(){</span><span style="height: 20px;" class="line">     awk <span style="color: #718c00;" class="string">'/pool/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">process_manager</span></span>() {</span><span style="height: 20px;" class="line">     awk <span style="color: #718c00;" class="string">'/process manager/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">start_since</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^start since:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">accepted_conn</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^accepted conn:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">listen_queue</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^listen queue:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">max_listen_queue</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^max listen queue:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">listen_queue_len</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^listen queue len:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">idle_processes</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^idle processes:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">active_processes</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^active processes:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">total_processes</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^total processes:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">max_active_processes</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^max active processes:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #4271ae;" class="function"><span style="color: #3e999f;" class="title">max_children_reached</span></span>(){</span><span style="height: 20px;" class="line">    awk <span style="color: #718c00;" class="string">'/^max children reached:/ {print $NF}'</span> <span style="color: #c82829;" class="variable">${LOG_FILE}</span></span><span style="height: 20px;" class="line">}</span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">case</span> <span style="color: #718c00;" class="string">"<span style="color: #c82829;" class="variable">$1</span>"</span> <span style="color: #8959a8;" class="keyword">in</span></span><span style="height: 20px;" class="line">pool)</span><span style="height: 20px;" class="line">    pool</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">process_manager)</span><span style="height: 20px;" class="line">    process_manager</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">start_since)</span><span style="height: 20px;" class="line">    start_since</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">accepted_conn)</span><span style="height: 20px;" class="line">    accepted_conn</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">listen_queue)</span><span style="height: 20px;" class="line">    listen_queue</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">max_listen_queue)</span><span style="height: 20px;" class="line">    max_listen_queue</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">listen_queue_len)</span><span style="height: 20px;" class="line">    listen_queue_len</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">idle_processes)</span><span style="height: 20px;" class="line">    idle_processes</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">active_processes)</span><span style="height: 20px;" class="line">    active_processes</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">total_processes)</span><span style="height: 20px;" class="line">    total_processes</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">max_active_processes)</span><span style="height: 20px;" class="line">    max_active_processes</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">max_children_reached)</span><span style="height: 20px;" class="line">    max_children_reached</span><span style="height: 20px;" class="line">    ;;</span><span style="height: 20px;" class="line">*)</span><span style="height: 20px;" class="line">    <span style="color: #f5871f;" class="built_in">echo</span> <span style="color: #718c00;" class="string">"Usage: <span style="color: #c82829;" class="variable">$0</span> {pool|process_manager|start_since|accepted_conn|listen_queue|max_listen_queue|listen_queue_len|idle_processes|active_processes|total_processes|max_active_processes|max_children_reached}"</span></span><span style="height: 20px;" class="line"><span style="color: #8959a8;" class="keyword">esac</span></span>

以上全部配置完成之后重启 agent 即可

1.3 添加模板,调用

松爷的书里提供了大量的模板,如果不想自己重写生成模板,直接拿着这个模板进行根据自身的环境修改即可

  • nginx 的模板
  • php-fpm 的模板

最后呈现出来的效果如下图(zatree中)
zabbix-nginx-phpfpm.jpg

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP's Current Status: A Look at Web Development TrendsPHP's Current Status: A Look at Web Development TrendsApr 13, 2025 am 12:20 AM

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP vs. Other Languages: A ComparisonPHP vs. Other Languages: A ComparisonApr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP vs. Python: Core Features and FunctionalityPHP vs. Python: Core Features and FunctionalityApr 13, 2025 am 12:16 AM

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

PHP: A Key Language for Web DevelopmentPHP: A Key Language for Web DevelopmentApr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP: The Foundation of Many WebsitesPHP: The Foundation of Many WebsitesApr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

Beyond the Hype: Assessing PHP's Role TodayBeyond the Hype: Assessing PHP's Role TodayApr 12, 2025 am 12:17 AM

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

What are Weak References in PHP and when are they useful?What are Weak References in PHP and when are they useful?Apr 12, 2025 am 12:13 AM

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

Explain the __invoke magic method in PHP.Explain the __invoke magic method in PHP.Apr 12, 2025 am 12:07 AM

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.