要在Ubuntu上监控php-fpm的运行状态,您可以使用以下方法:
使用命令行工具:
systemctl
:查看php-fpm服务状态。systemctl status php-fpm
ps
:查看php-fpm进程。ps aux | grep php-fpm
top
或 htop
:实时查看系统进程和资源占用情况。top
或htop
使用监控工具:
monit
:一个用于管理和监视系统进程、文件、目录和设备的实用程序。
安装monit:sudo apt-get install monit
配置monit以监视php-fpm:sudo nano /etc/monit/conf.d/php-fpm.conf
在打开的文件中添加以下内容:check process php-fpm with pidfile /run/php/php7.4-fpm.pid
start program = "/etc/init.d/php7.4-fpm start"
stop program = "/etc/init.d/php7.4-fpm stop"
if failed host 127.0.0.1 port 9000 protocol http then restart
if 5 restarts within 5 cycles then timeout
保存文件并重启monit服务:sudo systemctl restart monit
glances
:一个跨平台的系统监视工具,提供了一个基于ncurses的用户界面。
安装glances:sudo apt-get install glances
运行glances:glances
使用Web服务器监控:
如果您使用的是Nginx或Apache作为Web服务器,可以通过访问它们的状态页面来查看php-fpm的运行状态。
http://your_server_ip/nginx_status
。mod_status
模块,然后访问http://your_server_ip/server-status
。这些方法可以帮助您监控php-fpm的运行状态。根据您的需求选择合适的方法。