博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Monit的配置使用
阅读量:6978 次
发布时间:2019-06-27

本文共 2795 字,大约阅读时间需要 9 分钟。

hot3.png

安装

Ubuntu:sudo apt-get/aptitude install monitCentOS:yum install monitFedora:dnf install monitSuse:yast2 -i monitArch:pacman -S monitGentoo:emerge monit

 

以下操作在

Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.16.0-30-generic x86_64)

 

操作

monit -t #配置文件检测 monit #启动monit daemon monit -c /etc/monit/monitrc #启动monit daemon时指定配置文件 monit reload #当更新了配置文件需要重载 monit status #查看所有服务状态 monit status mysql #查看mysql服务状态 monit stop all #停止所有服务 monit stop mysql #查看mysql服务状态 monit start all #启动所有服务 monit start mysql #启动mysql服务 monit -V #查看版本

 

启动

monitmonit -V # 查看版本This is Monit version 5.6Copyright (C) 2001-2013 Tildeslash Ltd. All Rights Reserved.

 

配置

ls -lh /etc/monit/monitrc.d/|awk '{print $9}'|grep -v ^$

#该路径下有部分服务的监控配置,可参考使用

acpidapache2atcronmdadmmemcachedmysqlnginxopenntpdopenssh-serverpdns-recursorpostfixrsyslogsmartmontoolssnmpd

#

# Monit默认2分钟(120秒)检查下服务并把检查结果写入log中,log默认写入/var/log/monit.log中,以上内容均可以在配置文件中修改(set daemon 120)	#cat /etc/monit/conf.d/servicesset daemon 60 #设置检测时间为60秒set logfile /var/log/monit.log #monit日志set mailserver smtp.163.com port 25 #设置邮件服务器username "xxxxxx" password "xxxxxxxx" #设置邮件user/pwset alert xx@xx.cn with reminder on 1 cycle#1个周期内状态变化发送alert邮件到指定的邮箱,可设置多个set mail-format {from: xxxxxx@163.comsubject: [$SERVICE] $EVENTmessage:[$SERVICE] $EVENTDate: $DATEAction: $ACTIONHost: $HOSTDescription: $DESCRIPTIONYour faithful employee,Monit }set httpd port 2812    use address 0.0.0.0   # only accept connection from localhost    allow 0.0.0.0/0.0.0.0        # allow localhost to connect to the server and    allow admin:monit      # require user 'admin' with password 'monit'check process apache with pidfile /run/apache2/apache2.pid    start program = "/etc/init.d/apache2 start" with timeout 60 seconds    stop program  = "/etc/init.d/apache2 stop"    if failed host 192.168.28.134 port 80 protocol http then restartcheck process sshd with pidfile /var/run/sshd.pid   start program  "/etc/init.d/ssh start"   stop program  "/etc/init.d/ssh stop"   if failed port 22 protocol ssh then restart   if 5 restarts within 5 cycles then timeoutcheck process mysql with pidfile /run/mysqld/mysqld.pid   start program = "/etc/init.d/mysql start"   stop program = "/etc/init.d/mysql stop"   if failed host 127.0.0.1 port 3306 protocol mysql then alert#check filesystem rootfs with path /data#   if space usage > 80% for 3 times within 3 cycles then alert#check filesystem rootfs with path /data#   if inode usage > 80% for 3 times within 3 cycles then alert#check system 192.168.28.134#   if loadavg (1min) > 4 then alert#   if loadavg (5min) > 2 then alert#   if memory usage > 75% then alert#   if cpu usage (user) > 70% then alert#   if cpu usage (system) > 30% then alert#   if cpu usage(wait) > 20% then alert

如果你想更加深入的学习monit,请点击:

 

转载于:https://my.oschina.net/HeAlvin/blog/918177

你可能感兴趣的文章
matlab练习程序(高斯牛顿法最优化)
查看>>
【Python】keras卷积神经网络识别mnist
查看>>
DX11 preprocessor && Dynamic shader linkage
查看>>
手机网站的几点注意
查看>>
XSS跨站脚本攻击
查看>>
paramiko的使用
查看>>
tomcat的startup.bat闪退问题解决
查看>>
你不怕他离职吗?
查看>>
使用Linux进行缓冲区溢出实验的配置记录
查看>>
JavaScript-数据引用类型对象
查看>>
mysql删除开放用户权限
查看>>
17.08.17
查看>>
枚举算法
查看>>
April Fools Contest 2018
查看>>
关于flume配置加载(二)
查看>>
delphi 字符串string转流TStream
查看>>
Lync 小技巧-51-Lync 2013-不加域-客户端-1-下载-证书-信任链
查看>>
awk数组命令经典生产实战应用拓展
查看>>
配套自测连载(二)
查看>>
linux下set和eval的使用小案例精彩解答
查看>>