Linux Monit 开源服务器监控工具

Monit是一个用于管理和监控系统的小型开源工具。monit可以监控服务器进程状态、HTTP/TCP状态码、服务器资源、文件系统变化等。可以设置邮件报警,重启进程等。

官网文档
https://mmonit.com/monit/documentation/monit.html

安装

yum install monit

常用命令

monit -t  检查配置文件
monit -c  启动monit时指定配置文件
monit reload  更新配置后重新加载
monit status  查看所有服务状态
monit status servicename  查看某个服务状态
monit stop all  停止所有服务
monit stop servicename  停止某个服务
monit start all  启动所有服务
monit start servicename  启动某个服务
monit -V  查看monit版本

全局配置Web界面

1、Monit version 5.25.1 默认监听 2812
   浏览器输入http://localhost:2812登录网页版查看实时状态
2、对web界面的访问是通过SSL加密的
3、使用monit/admin账号密码登陆

配置文件

cat /etc/monit.conf
set daemon  30              # check services at 30 seconds intervals
set log syslog
set httpd port 2812 and
    allow localhost        # allow localhost to connect to the server and
    allow 192.168.0.0/255.0.0.0
    allow 192.17.0.0/255.255.0.0
    allow monit:admin      # require user 'monit' with password 'admin'

check process zabbix-agent with pidfile "/var/run/zabbix_agented.pid"
        start program = "/etc/init.d/zabbix-agent start"
        stop program = "/etc/init.d/zabbix-agent stop"
check process dnsmasq with pidfile "/var/run/dnsmasqe.pid"
        start program = "/etc/init.d/dnsmasq start"
        stop  program = "/etc/init.d/dnsmasq stop"

# 匹配进程名 
#check process flask MATCHING gunicorn 
# 配置服务启动和重启命令 
#start program = "/usr/bin/sudo service mongod start" 
#restart program = "/usr/bin/sudo service mongod restart" 
# 如果端口27017无法访问则认为服务失败,发报警邮件并重启服务 
#if failed port 27017 type tcp then alert 
#if failed port 27017 type tcp then restart 
# 如果在三个周期内重启了3次,则不再监控 # 
#if 3 restarts within 3 cycles then unmonitor

其他更多功能可查看官方文档。

参考https://blog.csdn.net/qin_weilong/article/details/90639769

      https://www.cnblogs.com/zzhaolei/p/11068041.html

posted @ 2020-08-14 15:51  __Yoon  阅读(779)  评论(0编辑  收藏  举报