如何使用Monit搭建监控系统?
发布时间:2023-04-01 12:20:39
monit是一款功能强大的系统状态、进程、文件、目录和设备的监控软件,它可以自动重启那些已经挂掉的程序,非常适合监控系统关键的进程和资源,那么如何使用Monit搭建监控系统?小编带来了Monit教程,希望对你有帮助!
修改monitrc文件
在conf文件夹下
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file and a complete list of statements and
## options, please have a look in the Monit manual.
##
##
###############################################################################
## Global section
###############################################################################
##
## Start Monit in the background (run as a daemon):
# 1.间隔30秒检查服务
set daemon 30 # check services at 30 seconds intervals
# with start delay 240 # optional: delay the first check by 4-minutes (by
# # default Monit check immediately after Monit start)
#
#
## Set syslog logging. If you want to log to a standalone log file instead,
## specify the full path to the log file
#
# set log syslog
# 2.设置日志地址
set log /root/monit/logs
#
#
## Set the location of the Monit lock file which stores the process id of the
## running Monit instance. By default this file is stored in $HOME/.monit.pid
#
# set pidfile /var/run/monit.pid
# 3.设置monit的启动端口
set pidfile /root/monit/var/monit.pid
#
## Set the location of the Monit id file which stores the unique id for the
## Monit instance. The id is generated and stored on first Monit start. By
## default the file is placed in $HOME/.monit.id.
#
# set idfile /var/.monit.id
#
## Set the location of the Monit state file which saves monitoring states
## on each cycle. By default the file is placed in $HOME/.monit.state. If
## the state file is stored on a persistent filesystem, Monit will recover
## the monitoring state across reboots. If it is on temporary filesystem, the
## state will be lost on reboot which may be convenient in some situations.
#
# set statefile /var/.monit.state
# 4.设置monit状态地址
set statefile /root/monit/var/monit.state
#
## Set limits for various tests. The following example shows the default values:
##
# set limits {
# programOutput: 512 B, # check program's output truncate limit
# sendExpectBuffer: 256 B, # limit for send/expect protocol test
# fileContentBuffer: 512 B, # limit for file content test
# httpContentBuffer: 1 MB, # limit for HTTP content test
# networkTimeout: 5 seconds # timeout for network I/O
# programTimeout: 300 seconds # timeout for check program
# stopTimeout: 30 seconds # timeout for service stop
# startTimeout: 30 seconds # timeout for service start
# restartTimeout: 30 seconds # timeout for service restart
# }
## Set global SSL options (just most common options showed, see manual for
## full list).
#
# set ssl {
# verify : enable, # verify SSL certificates (disabled by default but STRONGLY RECOMMENDED)
# selfsigned : allow # allow self signed SSL certificates (reject by default)
# }
#
#
## Set the list of mAIl servers for alert delivery. Multiple servers may be
## specified using a comma separator. If the first mAIl server fAIls, Monit
# will use the second mAIl server in the list and so on. By default Monit uses
# port 25 - it is possible to override this with the PORT option.
#
# set mAIlserver mAIl.bar.baz, # primary mAIlserver
# backup.bar.baz port 10025, # backup mAIlserver on port 10025
# localhost # fallback relay
#
#
# 5.设置邮箱地址
set mAIlserver "163.com"
username "social-touch.com" password "not"
using tlsv1
with TIMEOUT 30 SECONDS
## By default Monit will drop alert events if no mAIl servers are avAIlable.
## If you want to keep the alerts for later delivery retry, you can use the
## EVENTQUEUE statement. The base directory where undelivered alerts will be
## stored is specified by the BASEDIR option. You can limit the queue size
## by using the SLOTS option (if omitted, the queue is limited by space
## avAIlable in the back end filesystem).
#
# set eventqueue
# basedir /var/monit # set the base directory where events will be stored
# slots 100 # optionally limit the queue size
#
#
## Send status and events to M/Monit (for more informations about M/Monit
## see https://mmonit.com/). By default Monit registers credentials with
## M/Monit so M/Monit can smoothly communicate back to Monit and you don't
## have to register Monit credentials manually in M/Monit. It is possible to
## disable credential registration using the commented out option below.
## Though, if safety is a concern we recommend instead using https when
## communicating with M/Monit and send credentials encrypted. The password
## should be URL encoded if it contAIns URL-significant characters like
## ":", "?", "@". Default timeout is 5 seconds, you can customize it by
## adding the timeout option.
#
# set mmonit http://monit:monit@192.168.1.10:8080/collector
# # with timeout 30 seconds # Default timeout is 5 seconds
# # and register without credentials # Don't register credentials
#
#
## Monit by default uses the following format for alerts if the mAIl-format
## statement is missing::
## --8<--
## set mAIl-format {
## from: Monit
例子2:
# cis-ua
check process cis-ua with pidfile /data/cis/cis-ua/UserAnalysisServerV2.pid
start program = "/data/cis/cis-ua/startUserAnalysisServer.sh"
stop program = "/data/cis/cis-ua/stopUserAnalysisServer.sh"
if fAIled host mad133 port 10084
with timeout 75 seconds
then restart
group cis-ua
启动和关闭
写了几个常用的脚本,放在monit根目录下,即和bin同级的目录
start.sh(启动)
pwd=$(cd `dirname $0`; pwd)
$pwd/bin/monit -c $pwd/conf/monitrc
kill.sh(关闭)
#bin/monit -c /data/server/monit/conf/monitrc quit
kill -9 `ps -ef | grep monit/bin/monit | grep -v "grep" | awk '{print $2}' `
restart.sh(重启)
kill -9 `ps -ef | grep monit/bin/monit | grep -v "grep" | awk '{print $2}' `
sleep 3
pwd=$(cd `dirname $0`; pwd)
$pwd/bin/monit -c $pwd/conf/monitrc
macdown提供Mac软件教程,欢迎关注本站!


猜你喜欢
- Pages文稿是苹果为苹果用户设计多平台协同编辑的文字处理软件,而Pages文稿默认保存的文件格式只有MacOS能开启。如果需要将文档共享给
- 这篇文章主要介绍了WinXP、Win7系统打开文件夹选项图文教程,本文还给出了文件夹选项不见了的解决方法,需要的朋友可以参考下windows
- 或许有些朋友刚接触到Excel,并不太会使用Excel里面的功能,而数字计算乘法是在Excel中较为常用的,这个具体该如何操作实现呢?下面是
- wps是专门用来处理各种数据。里面的图表作用强大,能够让枯燥乏味的数据一下子变得富有生机。那么大家知道WPS的柱形图怎样做吗?下面小编为大家
- Windows Mac Web
- PowerPoint 软件的整体版面给人一种“中间简易,周围复杂”的感觉。学习软件的最好方式就是用鼠标随意地单击其中的按钮,虽然随即弹出的对
- 在我们平时使用Win7电脑进行学习、工作的时候,总是难免会有需要中途离开的时候,关机再重启太过麻烦,而电脑里面又有一些比较重要的资料,怕被别
- 很多的小伙伴们虽然使用了很久的电脑但是却不知道win7本地连接在哪里,今天小编就为大家带来了win7电脑本地连接打开方法!一起来看看吧。wi
- 启动Windows防火墙提示0x8007042c该怎么解决?Windows防火墙启动失败的原因很多,今天我们从三个方面来解决出现这个问题的方
- 英雄联盟lol是当前最热门的推塔类游戏之一了,很多小伙伴应该都在玩吧。但是你知道在lol游戏里面怎么截图吗?弄到五杀如何快速的保存下来吗?英
- 搜狗输入法是目前比较流行的输入法之一,但用的人多了,问题也就随之而来,搜狗输入法有时出现sgtool.exe应用程序错误是怎么回事呢?如何解
- 我们在生活和工作中都经常会使用到电脑,电脑使用的时间长了就会出现各种问题,比如蓝屏问题。如果我们碰到蓝屏错误代码0xc0000359的时候该
- 我们在使用计算机的时候,如果我们安装的是无限鼠标的话,可能有些小伙伴们就会遇到无线鼠标卡顿不流畅的情况。对于这个问题小编觉得可能是我们的鼠标
- 403 Forbidden是什么意思?有用户在打开网页的时候,电脑显示“403 Forbidden”,这是什么意思?电脑遇到这种情况该如何解
- 一、使用系统自带的方式更新驱动1、我的电脑右键如图所示进入设备管理器。2、进入设备管理器中看到黄色的感叹号,说明驱动没有安装或者安装的不正确
- ADDRESS函数用于按照给定的行号和列标,建立文本类型的单元格地址。其语法如下:ADDRESS(row_num,column_num,ab
- 在家工作、学习时间长了,各类文档也多了,如何快速文档中的某个特定字词、语句呢?Windows 10自带的索引无法搜索文本中的文字,那么有没有
- 怎么给显卡安装散热器?由用户想给自己的显卡更换一个散热器,但是不清楚该如何安装,下面给大家介绍下显卡散热器的主要安装步骤。安装步骤:注:本教
- 为了提高我们的工作效率,我们在编辑文档的时候,可以通过替换功能来实现批量设置字体的效果,下面就让小编告诉你 如何在wps文字中批量设置字体的
- MAC手势密码解锁怎么设置?mac每次开机都要输入开机密码,对于很多人来说有时候容易忘记密码,假设如同手机一样支持手势解锁图案解锁那就容易多