• 欢迎访问db1024网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏db1024吧

在Ubuntu上安装Monit来监控服务器和环境

网络资源 Liam 1年前 (2019-04-27) 366次浏览 10个评论 扫描二维码
文章目录[隐藏]

说明:相信很多人都遇到过 “502错误”、 “2002数据库无法连接” “ERR_NAME_NOT_RESOLVED” 等问题吧,一般来说是Apache HttpdNginxPHPMySQL等软件崩溃或者不稳定出现了相关问题。这时候我们可以利用Monit来监控服务器和环境,当出现意外的时候还可以自动实现重启。

安装

1、更新软件源缓存

apt update 

2、安装Monit

apt install monit -y 

升级

1、关闭monint

service monit stop 

2、安装html2text以自动解析最细版本:

apt install html2text -y 

3、自动更新

MONITVER=$(wget -q https://mmonit.com/monit/dist/binary/ -O - | html2text | grep DIR | tail -n 1 | tr -d / | awk '{print $2}') cd /tmp wget https://mmonit.com/monit/dist/binary/$MONITVER/monit-$MONITVER-linux-x64.tar.gz tar -xf monit-* cd monit-* sudo cp bin/monit /usr/bin/monit sudo ln -s /etc/monit/monitrc /etc/monitrc 

4、重启monint

service monit restart 

配置

1、备份原始配置

mv /etc/monit/monitrc /etc/monit/monitrc.bak 

2、创建SSL证书 ,实现HTTPS安全传输,演示用的是OpenSSL的自签,一路回车就行 :

mkdir -p /var/certs/ openssl req -new -x509 -days 365 -nodes -out /var/certs/monit.pem -keyout /var/certs/monit.pem  chmod 0700 /var/certs/monit.pem 

3、创建新配置
创建一份新的/etc/monit/monitrc文件,内容:

 set daemon 60 #check services every 60 seconds   set logfile /var/log/monit.log   set idfile /var/lib/monit/id   set statefile /var/lib/monit/state  #Event queue   set eventqueue       basedir /var/lib/monit/events # set the base directory where events will be stored       slots 100                     # optionally limit the queue size  #Mail settings  #http settings  set httpd port 52822 address 0.0.0.0  # 配置端口为adapters     ssl enable #启用 SSL     pemfile  /var/certs/monit.pem #生成的SSL地址     allow 0.0.0.0/0.0.0.0 # 允许访问的IP     allow monit.moerats.com        # 绑定的域名     allow rats:"www.moerats.com"      # 账号为rats ,密码为www.moerats.com  #allow modular structure     include /etc/monit/conf.d/*     include /etc/monit/conf-enabled/* 

4、给予权限

chmod 0700 /etc/monit/monitrc 

5、检查配置是否正确 ,运行

monit -t 

如果反馈下面的语句就是正常的:

Control file syntax OK 

6、重启服务

systemctl restart monit 

访问

当问https://yourip:52822输入用户名:rats 密码:www.moerats.com 就可以访问管理页面了。

原文地址:https://www.mf8.biz/ubuntu-install-monit/


db1024 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:在Ubuntu上安装Monit来监控服务器和环境
喜欢 (0)
关于作者:
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(10)个小伙伴在吐槽
  1. Ridiculous quest there. What happened after? Thanks!
    web hosting services2020-08-31 23:50 回复 Mac OS X | Firefox浏览器 59.0
  2. Thank you for the good writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! By the way, how can we communicate?
    black mass2020-08-31 07:26 回复 Mac OS X | Chrome 66.0.3359.181
  3. Hi all, here every person is sharing these kinds of experience, thus it's nice to read this weblog, and I used to visit this web site everyday.
    black mass2020-08-28 20:42 回复 Linux | Firefox浏览器 4E2F
  4. Hi there! I know this is kind of off topic but I was wondering which blog platform are you using for this website? I'm getting fed up of Wordpress because I've had problems with hackers and I'm looking at options for another platform. I would be great if you could point me in the direction of a good platform.
    cheap flights2020-08-26 21:09 回复 Mac OS X | Chrome 65.0.3325.181
  5. Having read this I thought it was really informative. I appreciate you finding the time and energy to put this information together. I once again find myself spending a significant amount of time both reading and leaving comments. But so what, it was still worth it!
    web hosting sites2020-08-26 04:04 回复 Linux | Firefox浏览器 60.0.1
  6. I'm extremely impressed together with your writing abilities and also with the structure on your blog. Is that this a paid theme or did you customize it your self? Either way stay up the nice high quality writing, it's uncommon to look a nice blog like this one these days.. 31muvXS cheap flights
    cheap flights2020-08-26 03:51 回复 Linux | Chrome 52.0.2777.35
  7. Greetings! Very useful advice in this particular article! It's the little changes which will make the greatest changes. Thanks for sharing! cheap flights 2CSYEon
    cheap flights2020-08-25 06:51 回复 Linux | Firefox浏览器 59.0
  8. Everything is very open with a precise description of the challenges. It was definitely informative. Your site is very useful. Many thanks for sharing! 2CSYEon cheap flights
    cheap flights2020-08-25 04:05 回复 Windows 7 | Opera 9.80
  9. Piece of writing writing is also a excitement, if you be familiar with then you can write if not it is complicated to write. cheap flights 32hvAj4
    cheap flights2020-08-24 22:43 回复 Windows 7 | 360浏览器 SE
  10. First of all I want to say excellent blog! I had a quick question which I'd like to ask if you do not mind. I was curious to find out how you center yourself and clear your head before writing. I've had trouble clearing my mind in getting my ideas out. I truly do enjoy writing but it just seems like the first 10 to 15 minutes are generally lost just trying to figure out how to begin. Any suggestions or hints? Kudos! adreamoftrains web hosting services
    adreamoftrains website hosting companies2020-08-12 11:23 回复 Linux | Safari浏览器 605.1.15