监视 - 检查过程是否存在并在消耗X内存时杀死
我在某些主机上运行了“某些程序”,并且希望有和没有“某些程序”运行的主机检查单程检查,当内存使用量超过阈值时,这会杀死某些程序。
以下检查作品,但是在未运行某些程序MONIT的主机上,在/var/log/monit.log中持续日志“未运行”。
check process someprocess
matching "someprocess"
if memory usage > 2% for 1 cycle then exec "/usr/bin/kill someprocess"
我还想包括“如果存在”,但请继续遇到Monit Systax错误,我不确定我是否有一个以上的语句。
有人知道我是否可以做到这一点,所以请与:
if exists AND memory usage > 2% for 1 cycle then exec "/usr/bin/kill someprocess"
I have 'someprocess' running on some hosts, and want a single monit check for hosts with and without 'someprocess' running, which kills someprocess when memory usage exceeds a threshold.
Below check works, but on hosts not running someprocess monit continually logs "process is not running" in /var/log/monit.log.
check process someprocess
matching "someprocess"
if memory usage > 2% for 1 cycle then exec "/usr/bin/kill someprocess"
I want to also include 'if exists' but keep getting monit systax errors, Im not sure I can have more than one if statement.
Does anyone know if I can do this, so have something along the lines of:
if exists AND memory usage > 2% for 1 cycle then exec "/usr/bin/kill someprocess"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以添加其他测试并在应用程序不可用的情况下禁用监视,以防止使用消息浮动日志。
如果5个监视器周期无法使用该应用程序,则将禁用检查。要再次启用监视,请使用“ Monit Monitor SomeProcess”。
请参阅 https://mmonit.com/monit.com/monit/documentation/monit.html.html#existence - 检验
You can add an additional test and disable the monitoring if the application is not available, to prevent floating the logs with messages.
This will disable the check, if the application is not available for 5 monitor cycles. To enable the monitoring again, use "monit monitor someprocess".
See https://mmonit.com/monit/documentation/monit.html#EXISTENCE-TESTS