| 副标题[/!--empirenews.page--] 《使用zabbix监控nginx和php-fpm性能》要点:本文介绍了使用zabbix监控nginx和php-fpm性能,希望对您有用。如果有疑问,可以联系我们。
 
 1.系统环境1.1 软件及其版本1.2 软件安装路径zabbix安装在/usr/local/zabbix路径下,其相关配置文件及二进制执行程序都放置其中.nginx安装在
 /usr/local/nginx下,其相关配置文件及二进制执行程序都放置其中.php安装在
 /usr/local/php下,其相关配置文件及二进制执行程序都放置其中.继续后面的操作前,请确认nginx和php-fpm的服务端口都处于监听状态.
 2.配置nginx的status2.1 确认nginx的status已编译到程序包中使用nginx -V可以查看nginx是否将模块·http_stub_status_module`编译进包中: 2.2 启用nginx的status模块
修改nginx.conf文件一般在默认主机中增加如下location即可:
 
查看nginx statusnginx配置文件修改完成以后,使用
 nginx -t测试配置文件是否有明显逻辑及语法错误,没有问题则重载配置文件. 
然后使用浏览器或者curl指令查看nginx status: 2.3 nginx status数值的含义说明php-fpm自带的有用于查询其工作状态的页面,需要进行如下 两步,以启用这一功能.3.配置php-fpm的status3.1 启用php-fpm status页面修改php-fpm.conf文件,去掉status页面的注释,并可以根据需要将其改名.操作如下: 3.2 查看php-fpm的status修改完php-fpm.conf后,使用service php-fpm reload重新加载配置文件,然后在浏览器或者使用curl指令查看php-fpm的status.操作如下: php-fpm的status可以查看汇总信息和详细信息,详细信息比汇总信息要多出每一个php-fpm进程的相关信息,同时支持多种格式输出,如xml、html和json,默认情况下分别使用如果指令即可: xamples for summary status page:http://example.com/status
 http://example.com/status?json
 http://example.com/status?html
 http://example.com/status?xml
 Example for detailed status page:
 http://example.com/status?full
 http://example.com/status?json&full
 http://example.com/status?html&full
 http://example.com/status?xml&full
 使用何种格式查看status决定了后续使用zabbix进行监控获取status数值的方式.本文以上述curl localhost/php_fpm-status的输出为例. 3.3 php-fpm status的含义4.编写status数据提取脚本在适当的位置,一般是/usr/local/zabbix/bin里准备脚本用于提取status里每个字段的数值. 4.1 nginx的status数值提取脚本此脚本为/usr/local/zabbix/bin/nginx_status.sh,其内容如下: 4.2 php-fpm status数值提取脚本php-fpm status数值提取脚本为/usr/local/zabbix/bin/php_fpm_status.sh,内容如下: 5.创建zabbix_agentd的子配置文件在/usr/local/zabbix/etc/zabbix_agentd.d/中创建关联nginx status和php-fpm status的子配置文件,创建一个,或者在已有的某配置文件中增加也可以,我这里分别为它们创建配置文件,文件名可自定义,只要确保此文件夹全部内容在zabbix_agentd.conf中包含(include)了. 5.1 userparameter_nginx.conf(编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |