在 Ubuntu 服务器上运行 Monit 5.4。当我使用 时monit reload,它似乎会重新启动受监控的服务(在这种情况下为 Tomcat 7)。这是预期的行为吗?文档说:
reload - 重新初始化正在运行的 Monit 守护进程,守护进程将重新读取其配置,关闭并重新打开日志文件。
我希望它不会重新启动任何服务,而只会重新加载它的配置,这样我就可以更改电子邮件警报和其他内容。
这是输出 monit status
The Monit daemon 5.4 uptime: 15h 0m
Process 'tomcat7'
status Running
monitoring status Monitored
pid 38842
parent pid 1
uptime 14h 30m
children 0
memory kilobytes 3445964
memory kilobytes total 3445964
memory percent 10.4%
memory percent total 10.4%
cpu percent 14.8%
cpu percent total 14.8%
port response time 0.018s to localhost:80 [HTTP via TCP]
data collected Tue, 17 …Run Code Online (Sandbox Code Playgroud) 我需要监控在我的网络服务器上运行的几个进程。出于某种原因,清漆目前每天或每两天崩溃一次。我正在使用 monit 据称自动重新启动清漆,但它不起作用。这是我的 Varnish 的 monit.conf 条目。
check process varnish with pidfile /var/run/varnish.pid
start program = "/etc/init.d/varnish start" with timeout 60 seconds
stop program = "/etc/init.d/varnish stop"
if failed host <my server ip> port 80 protocol http
and request "/blank.html" then restart
if 3 restarts within 5 cycles then timeout
group server
Run Code Online (Sandbox Code Playgroud)
日志文件显示,在varnish停止运行后,尝试重新启动之后都失败了。然后最终 monit 停止监视清漆。
有人对我如何解决这个问题有建议吗?或者更好的是,您能否提出其他简单的自动监控和重启崩溃进程的方法?谢谢!
每次 monit 守护程序停止或启动时,Monit 都会发送警报。这是令人讨厌且没有用的信息。
根据文档,我设置:
set alert user@mycompany.com but not on { instance }
Run Code Online (Sandbox Code Playgroud)
...应该向该电子邮件发送警报,除非它们属于定义为开始/停止的“实例”类别。
但是,我仍然收到警报。这超级烦人。显然,我一定是遗漏了什么。
我们正在运行 Monit 5.2.4
我刚刚根据monit 文档安装和配置了 monit。除 Apache 之外的所有服务都列为 Running,但 Apache 表示Not Monitored。
monit 配置中的相关行是:
check process apache with pidfile /var/run/httpd.pid
group www
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host localhost port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout
Run Code Online (Sandbox Code Playgroud)
我可以从服务器访问http://localhost/server-status和http://localhost。Monit 将 Apache 的监控模式列为active。
服务器正在运行 CentOS 5.4。
PID 文件对于父 httpd 服务器是正确的:
[server ~]$ cat /var/run/httpd.pid
2905
[server ~]$ ps auxc | …Run Code Online (Sandbox Code Playgroud) 我想让 Monit 检查 Web 应用程序的健康状况,经常运行廉价/琐碎的检查,而不那么频繁地运行昂贵/非平凡的检查(例如 1/5 分钟)。我怎样才能告诉它以比每个监视间隔更少的频率检查给定的主机?
如果服务失败几次,Monit 似乎会放弃重新启动服务,并取消对其进行监控。我在文档中找不到任何关于时间或原因的细节。
我的 Monit 配置将设置如下:
set daemon 10
set logfile /var/log/monit.log
set statefile /var/lib/monit/monit.state
set alert foo@example.com not { nonexist, action, instance }
include /etc/monit/conf.d/*
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的 Monit 规则集的示例:
check process myservice
with pidfile /var/run/myservice/myservice.pid
start program = "/home/myservice/current/start-myservice.sh"
as uid myservice and gid myservice
stop program = "/home/myservice/current/stop-myservice.sh"
as uid myservice and gid myservice
mode active
Run Code Online (Sandbox Code Playgroud)
在我的环境中,我希望它无限期地继续尝试轮询间隔。有没有办法将 monit 配置为从不停止监视服务,即使它没有成功启动?
我看到很多人将 monit 与 runit 结合使用。那不是多余的吗?使用 runit 又有什么意义呢?是不是因为它在处理服务时更可靠(因为它不依赖于 pidfiles)?
谢谢!
我正在尝试使用 monit,并使用 gmail 设置电子邮件服务器。配置文件是这样的:
set mailserver smtp.gmail.com port 587
username "someuser@gmail.com" password "password"
using tlsv1
with timeout 30 seconds
Run Code Online (Sandbox Code Playgroud)
我设置了一个警报来测试:
check file alerttest with path /.nonexistent
alert address@gmail.com with reminder on 500 cycles
Run Code Online (Sandbox Code Playgroud)
但是当我使用 monit validate 时,我得到的错误信息是这样的:
Sendmail: error receiving data from the mailserver 'smtp.gmail.com' -- Resource temporarily unavailable
Alert handler failed, retry scheduled for next cycle
'alerttest' file doesn't exist
Sendmail: error receiving data from the mailserver 'smtp.gmail.com' -- Resource temporarily unavailable
'alerttest' trying to restart
Run Code Online (Sandbox Code Playgroud)
任何人有任何想法?非常感谢
我正在一个新站点上设置 monit,在此问题中我将其称为 mywebsite.com。我已经设置了访问 monit 的 Web 界面页面的配置,但我无法连接到它。我有一个运行 iptables 的基本防火墙,我想我为 monit 开了一个洞,但我无法连接到 monit 的 Web 界面,我不知道为什么。
我还没有设置任何要监控的东西:我的 monit 配置如下所示:
## Start monit in the background (run as a daemon):
set daemon 120 # check services at 2-minute intervals
set httpd port 2812 and
use address mywebsite.com
allow localhost
allow admin:password
Run Code Online (Sandbox Code Playgroud)
我已经用这些规则重新启动了 monit。
我在我的 iptables 配置中为 monit 制定了一条规则,如下所示:
#monit interface
-A OUTPUT -p tcp --dport 2812 -j ACCEPT
-A INPUT -p tcp --dport 2812 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)
然后我将这些规则导入到/sbin/iptables-restore. 当我这样做时,我可以看到 monit 条目 …
monit ×10
monitoring ×5
linux ×4
apache-2.2 ×1
daemon ×1
gmail ×1
http ×1
iptables ×1
runit ×1
service ×1
smtp ×1
ubuntu ×1
unix ×1
varnish ×1
web-server ×1