温馨提示×

Ubuntu如何监控LNMP运行状态

小樊
49
2025-08-15 10:35:08
栏目: 智能运维

在Ubuntu上监控LNMP运行状态,可通过以下方式:

一、系统自带工具

  • top/htop:实时查看CPU、内存等系统资源使用情况。
  • vmstat/iostat:监控虚拟内存、磁盘I/O等性能指标(需安装sysstat)。
  • netstat:查看网络连接和端口占用状态。

二、服务状态检查

  • Nginxsudo systemctl status nginx 或访问http://服务器IP/nginx_status(需启用ngx_http_stub_status_module)。
  • MySQLsudo systemctl status mysqlsudo mysqladmin status
  • PHP-FPMsudo systemctl status php-fpm

三、专业监控工具

  • Zabbix:企业级监控系统,支持多指标监控和告警,需安装服务器和代理。
  • Netdata:实时可视化监控,安装后通过Web界面查看系统及服务状态。
  • Prometheus + Grafana:Prometheus采集指标,Grafana提供可视化,支持自定义告警。
  • Nagios:成熟稳定的监控方案,需配置插件监控各组件。

四、日志分析

  • Nginxsudo tail -n 10 /var/log/nginx/error.log 查看错误日志。
  • MySQLsudo tail -n 10 /var/log/mysql/error.log 分析慢查询等日志。

根据需求选择工具,生产环境建议使用Zabbix、Prometheus+Grafana等专业方案实现全面监控和告警。

0