[整理] CentOS7使用monit监控服务运行状态

1. 安装

yum -y install epel-release
yum -y install monit

2. 配置

vim /etc/monitrc

set daemon  30
set log syslog
set httpd port 2812 and
    use address 172.20.10.11
    allow 172.20.10.2
    allow admin:monit
    #with ssl {            # enable SSL/TLS and set path to server certificate
    #    pemfile: /etc/ssl/certs/monit.pem
    #}
include /etc/monit.d/*

3. 配置监控服务

a. 监控apache:
vim /etc/monit.d/apache

check  process  apache  with  pidfile  /etc/httpd/logs/httpd.pid
start  program  =  "/usr/bin/systemctl  start  httpd"
stop  program    =  "/usr/bin/systemctl  stop  httpd"

b. 监控mysql:
vim /etc/monit.d/mysql

check  process  mysql  with  pidfile  /usr/local/mysql/data/lee.pid
start  program  =  "/usr/bin/systemctl  start  mysqld"
stop  program    =  "/usr/bin/systemctl  stop  mysqld"

c. 监控ssh:
vim /etc/monit.d/ssh

check  process  ssh  with  pidfile  /run/sshd.pid
start  program  =  "/usr/bin/systemctl  start  sshd"
stop  program    =  "/usr/bin/systemctl  stop  sshd"

4. 常用语法

a. 检测配置文件语法:

monit  -t

b. 启动服务:

systemctl  start  monit

c. 停止服务:

systemctl  stop  monit

d. 重启服务:

systemctl  restart  monit

e. 查看服务运行状态:

systemctl  status  monit  -l

f. 查看错误日志:

tail  /var/log/monit.log

5. 监控页面

http://172.20.10.11:2812
posted @   哆啦梦乐园  阅读(146)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示