AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[monit](server)

Martin Hope
Alasdair
Asked: 2021-03-11 14:03:26 +0800 CST

如何在给定 PID 编号的情况下找到进程的 PID 文件?

  • 0

我正在尝试使用 Monit 来监视并在进程停止运行时发送有关进程的电子邮件警报,但我需要该进程的 PID 文件的位置。我可以使用htoporps命令找到 PID 编号,我认为从那里找到 PID 文件非常简单,但是在搜索 Google 和 StackExchange 之后,我没有找到任何可以回答我的问题的东西。

我知道这个线程:How to find the .pid file for a given process但发现它没有帮助。刚才给出的答案提到了 PID 文件的通常位置,它适用于 Redhat/CentOS 风格的系统。我正在使用 Ubuntu,并希望得到更具体的答案。给定PID号,是否没有返回PID文件路径的命令?

谢谢!

ubuntu monitoring process daemon monit
  • 1 个回答
  • 771 Views
Martin Hope
JellicleCat
Asked: 2021-01-05 14:54:14 +0800 CST

监控“找不到文件系统”

  • 1

我发现 monit 无法有效地监控文件系统。我添加了一个/etc/monit.d/disk.cnf包含以下内容的文件:

check device disk1 with path /dev/root
  if space usage > 85% then exec "/bin/custom-alert"

...当我monit reload,监控日志告诉我:

[PST Jan  4 14:48:39] error    : 'disk1' filesystem doesn't exist
[PST Jan  4 14:48:39] info     : 'disk1' trying to restart

好的,所以我cat /proc/cmdline学习了root=/dev/sda,然后在我的文件中替换/dev/root为。然后监控日志告诉我:/dev/sdadisk.cnf

[PST Jan  4 14:46:35] error    : Device /dev/sda not found in /etc/mtab
[PST Jan  4 14:46:35] error    : 'disk1' unable to read filesystem /dev/sda state

实际上,/etc/mtab引用/dev/root而不是/dev/sda.

/dev/root当我指定或在这台机器上时,为什么无法监控访问文件系统/dev/sda?


更多信息:df -h输出以下内容:

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       173G  146G   26G  85% /
devtmpfs         32G     0   32G   0% /dev
tmpfs            32G     0   32G   0% /dev/shm
tmpfs            32G  3.2G   29G  11% /run
tmpfs            32G     0   32G   0% /sys/fs/cgroup
tmpfs           6.3G     0  6.3G   0% /run/user/1000
monit
  • 1 个回答
  • 251 Views
Martin Hope
BitFreak
Asked: 2020-09-22 16:08:29 +0800 CST

为什么monit抱怨无法读取pid文件?

  • 0

我刚开始监视并且对 pid 文件有疑问:我已将以下内容添加到我的 /etc/monit/monitrc 中:

cat /etc/monit/monitrc
set daemon 30
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue
      basedir /var/lib/monit/events # set the base directory where events will be stored
      slots 100                     # optionally limit the queue size

check ping.sh
    with path "/path/to/ping.sh"
    every "44 * * * *"
    #if status != 0 then alert

我得到了以下内容/var/log/monit.log:

[UTC Sep 21 22:44:09] error    : Error reading pid from file '/path/to/ping.sh'
[UTC Sep 21 22:44:09] error    : 'ping.sh' process is not running
[UTC Sep 21 22:44:09] info     : 'ping.sh' trying to restart

尽管:

ls -l /path/to/ping.sh
-rwxrwxr-x 1 root root 1045 Sep 21 20:08 /path/to/ping.sh

在脚本内部,pid 存储在 /var/run/ping.pid 中:

#!/bin/bash
pidfile="/var/run/ping.pid"
# Get the pid of the currently running script
ps ax | grep $0 | grep $SHELL | awk '{print $1}'>$pidfile

pid 文件在脚本底部被删除:

rm $pid文件

为什么会出现错误:Error reading pid from file '/path/to/ping.sh'?

只是为了透明:我也在 [email protected] 邮件列表上发布了同样的问题,但它似乎不是很活跃。我将同步两个线程之间的任何回复!

pid monit
  • 1 个回答
  • 340 Views
Martin Hope
le_top
Asked: 2020-09-05 03:04:31 +0800 CST

使用“monit” - 如何检测来自 http 进程的空回复(apache2)

  • 0

我想监视来自我的 apache2 进程的空回复,因为我遇到了类似于“ Apache 给出空回复”的问题。

我正在使用monit来监控我的流程,所以我会坚持下去!

我在 debian 上的“/etc/monit/conf.d”目录中有文件“apache2”:

check process apache2 with pidfile /var/run/apache2/apache2.pid
    start program = "/etc/init.d/apache2 start"
    stop program  = "/etc/init.d/apache2 stop"
    if cpu > 60% for 2 cycles then alert
    if cpu > 80% for 5 cycles then alert
    if children > 25 then restart
    if failed host example.com port 80 protocol http # example.com replaces the actual site in this example.
#       and request "/"    # ??? Needed
#       and size <10      # ??? such an option does not exist?
#       with size <10      # ??? such an option does not exist?
       with timeout 20 seconds
       then restart
    group server

如果尝试添加大小约束,但我没有成功。是否可以检查回复的大小,如果可以,如何修改上述配置?

注意:此监视器正在检查端口 80 - SSL 由代理确保,端口 80 不可公开访问。服务器的hosts文件有“example.com”指向本地IP。

monitoring httpd apache2 monit
  • 1 个回答
  • 141 Views
Martin Hope
ibyte
Asked: 2020-07-24 10:10:03 +0800 CST

用monit重启apache

  • 2

我试图找出我的服务器上的一些问题,我的 CPU 每隔一天就达到 100% 的利用率。这会导致我所有的网站和 http 服务都失败。

当我的 cpu 在 10 个周期内达到 100% 时,如何配置 monit 以重新启动 httpd 服务?

我还是 linux 和 centos 的新手。学习我的方法,我已经尝试研究了一段时间,但我找不到正确的答案。

感谢您的关注

更新

感谢您的答复。当 CPU 以 100% 运行时,我运行了 top 命令,我可以看到用户没有人在 httpd 服务上使用所有这些。我有一些使用 php 脚本的应用程序,但它们的错误日志看起来都很好。

我怀疑某个特定的 wordpress 主题由于更新网站时出现循环而导致此错误。这个特定的网站还向我显示了一个环回测试失败错误,而同一台服务器上的所有其他 wordpress 网站都运行良好。

因此,在找出罪魁祸首之前,我只想在 CPU 利用率达到 95% 并持续 10 个周期时重新启动服务 httpd。

我希望这足以让有人给我一个解决方案。

apache-2.4 centos7 monit
  • 3 个回答
  • 611 Views
Martin Hope
DevOps
Asked: 2020-07-22 00:34:38 +0800 CST

Monit 在升级后报告证书自签名问题

  • 0

在更新到 Monit 的最后一个二进制版本后,Monit 报告了一个关于

SSL server certificate verification error: self signed certificate in certificate chain
monit
  • 1 个回答
  • 34 Views
Martin Hope
svprdga
Asked: 2020-06-14 02:32:32 +0800 CST

无法访问监控 Web 界面

  • 0

我刚刚在我的服务器上安装了 Monit。我想访问 Web 界面来管理它,但无法访问 Web。

该机器是AWS中的一个实例,端口是开放的。我尝试了很多配置:

set httpd port 2812
    use address localhost  
    allow localhost        
    allow admin:monit  

set httpd port 2812
    use address [instance-public-ip]  
    allow [instance-public-ip]        
    allow admin:monit

set httpd port 2812
    use address [instance-private-ip]  
    allow [instance-private-ip]        
    allow admin:monit 

不适用于上述任何一项。如果我使用内部 IP 监控状态,则输出为:

系统 'ip-172-[...]' 状态 OK
监控状态 监控模式
在重新启动时处于活动状态 平均负载
[0.00] [0.00] [0.00] cpu 0.5%us 0.4%sy 0.0%wa 内存使用量 143.1 MB [14.6 %] 交换使用率 0 B [0.0%] 正常运行时间 1d 23h 25m 启动时间
Thu, 11 Jun 2020 10:59:14 数据收集 2020 年 6 月 13 日星期六 10:24:17

我知道我一定做错了什么或错过了什么。任何帮助将不胜感激。

monitoring monit
  • 1 个回答
  • 164 Views
Martin Hope
Heino Rötten
Asked: 2019-10-30 08:41:21 +0800 CST

为什么在检查程序返回退出代码0时监控日志错误和状态失败

  • 0

问题 1

我想用 monit 版本 5.25.1 监控一个无头运行的 LibreOffice-Process。

这是我对这种方法的监控配置:

cat /etc/monit/conf.d/libreoffice


check program lo-check-8101 with path "/bin/bash /opt/libreoffice/chkloproc.sh TestLOPort8101 8101"
        with timeout 10 seconds
        if status != 0 then exec "/bin/bash /opt/libreoffice/loproc_is_down.sh"
        if status = 0 then exec "/bin/bash /opt/libreoffice/loproc_is_up.sh"

此 LibreOffice 实例正在侦听端口 8101。

如果一切正常,检查脚本将返回 0,如果该 LibreOffice 实例出现错误,则返回 101。我正在通过发送 HTML、请求 TEXT 并检查响应来测试这个正在运行的 LibreOffice 进程的文本转换。

动作脚本 (loproc_is_down.sh / loproc_is_up.sh) 正在添加/删除一个 iptables 规则,以向正在运行的 haproxy 发出状态,该 haproxy 正在端口检查 LibreOffice 实例 / 进程......如果这听起来有点复杂,对不起,但这不是我想在这里谈论的问题。

问题是,我不明白为什么 monit 会记录以下条目:

重启后监控日志

[CET Oct 29 16:58:18] info     : Starting Monit 5.25.1 daemon with http interface at [localhost]:2812
[CET Oct 29 16:58:18] info     : Monit start delay set to 10s
[CET Oct 29 16:58:28] info     : 'host1' Monit 5.25.1 started
[CET Oct 29 16:58:58] error    : 'lo-check-8101' status failed (0) -- no output
[CET Oct 29 16:58:58] info     : 'lo-check-8101' exec: '/bin/bash /opt/libreoffice/loproc_is_up.sh'
[CET Oct 29 16:59:28] error    : 'lo-check-8101' status failed (0) -- no output

...以及“监控状态”中的以下状态屏幕:

monit status
Monit 5.25.1 uptime: 0m

Program 'lo-check-8101'
  status                       Status failed
  monitoring status            Monitored
  monitoring mode              active
  on reboot                    start
  last exit value              0
  last output                  -
  data collected               Tue, 29 Oct 2019 16:58:58

System 'host1'
  status                       OK
  monitoring status            Monitored
  monitoring mode              active
  on reboot                    start
  load average                 [0.03] [0.02] [0.01]
  cpu                          0.6%us 0.6%sy 0.0%wa
  memory usage                 543.9 MB [7.8%]
  swap usage                   0 B [0.0%]
  uptime                       20d 1h 11m
  boot time                    Wed, 09 Oct 2019 16:47:51
  data collected               Tue, 29 Oct 2019 16:58:58

在我看来,检查脚本返回退出值 0 但状态被报告/解释为“状态失败”。

我不明白,为什么 monit 在其日志文件中报告“错误:... status failed (0)”。

除了解释给定检查脚本程序的最后一个退出代码之外,状态还意味着什么?


问题 2

还有另一个来自monit的反应,我无法理解,也许有人可以向我解释一下?

当我试图通过停止它来伪造一个损坏的 LibreOffice 进程时,monit 确实在一个周期后识别出这一点,并且正在启动想要/配置的操作脚本“loproc_is_down.sh”并将最后一个退出代码正确报告为 101,但使用日志-线

“信息:状态成功(101)”

第一个循环,然后再用

“错误:状态失败(101)”

伪造失败的监控日志

[CET Oct 29 17:14:28] info     : 'lo-check-8101' status succeeded (101) -- Error: Existing listener not found. Unable start listener by parameters. Aborting.
[CET Oct 29 17:14:28] error    : 'lo-check-8101' status failed (101) -- Error: Existing listener not found. Unable start listener by parameters. Aborting.
[CET Oct 29 17:14:28] info     : 'lo-check-8101' exec: '/bin/bash /opt/libreoffice/loproc_is_down.sh'
[CET Oct 29 17:14:58] error    : 'lo-check-8101' status failed (101) -- Error: Existing listener not found. Unable start listener by parameters. Aborting.
[CET Oct 29 17:15:28] error    : 'lo-check-8101' status failed (101) -- Error: Existing listener not found. Unable start listener by parameters. Aborting.

相反的是再次启动 LibreOffice 进程时:

服务再次运行时监控日志

[CET Oct 29 17:15:58] error    : 'lo-check-8101' status failed (0) -- no output
[CET Oct 29 17:15:58] info     : 'lo-check-8101' exec: '/bin/bash /opt/libreoffice/loproc_is_up.sh'
[CET Oct 29 17:15:58] info     : 'lo-check-8101' status succeeded (0) -- no output
[CET Oct 29 17:16:28] error    : 'lo-check-8101' status failed (0) -- no output
[CET Oct 29 17:16:58] error    : 'lo-check-8101' status failed (0) -- no output

看起来monit运行该检查脚本,它返回退出代码0并启动动作脚本“loproc_is_up.sh”并使用“状态成功(0)”报告它

...但在接下来的周期中再次记录“错误:状态失败(0)”。

我不理解monit概念/文档中“状态”的含义......有人可以向我解释吗?

感谢您阅读这篇长文,希望能帮助我回答。

monit
  • 2 个回答
  • 1450 Views
Martin Hope
ychaouche
Asked: 2019-08-20 06:03:02 +0800 CST

monitrc 中的语法错误

  • 0

我一定在我的 monitrc 文件中做傻事,但找不到它。如果有人想看看,这里是 monit -t 的结果

root@app-server[192.168.100.83] ~ # monit -t
/etc/monit/monitrc:308: syntax error ''
root@app-server[192.168.100.83] ~ #

第 308 行是文件的最后一行

root@app-server[192.168.100.83] ~ # nl -ba /etc/monit/monitrc | tail
   298  ###############################################################################
   299  ## Includes
   300  ###############################################################################
   301  ##
   302  ## It is possible to include additional configuration parts from other files or
   303  ## directories.
   304  #
   305     include /etc/monit/conf.d/*
   306     include /etc/monit/conf-enabled/*
   307  #
root@app-server[192.168.100.83] ~ #

这是monitrc,没有所有评论

root@app-server[192.168.100.83] ~ # removeblanks /etc/monit/monitrc
  set daemon 120            # check services at 2-minute intervals
  set logfile /var/log/monit.log
  set idfile /var/lib/monit/id
  set statefile /var/lib/monit/state
SET MAILSERVER 10.10.10.19  USERNAME [email protected] PASSWORD "xxx" WITH TIMEOUT 30 SECONDS
  set eventqueue
      basedir /var/lib/monit/events # set the base directory where events will be stored
      slots 100                     # optionally limit the queue size
SET ALERT [email protected]
SET HTTPD PORT 8001 ALLOW monit:monit
   include /etc/monit/conf.d/*
   include /etc/monit/conf-enabled/*
root@app-server[192.168.100.83] ~ #

这是 monitrc 逐字记录(已删除密码)

root@app-server[192.168.100.83] ~ # cat /etc/monit/monitrc
###############################################################################
## 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):
#
  set daemon 120            # check services at 2-minute 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 logfile /var/log/monit.log
#
#
## 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
#
## 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 idfile /var/lib/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/lib/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
#
#

SET MAILSERVER 10.10.10.19  USERNAME [email protected] PASSWORD "xxx" 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/lib/monit/events # 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
## ":", "?", "@".
#
# set mmonit http://monit:[email protected]:8080/collector
#     # and register without credentials     # Don't register credentials
#
#
## Monit by default uses the following format for alerts if the the mail-format
## statement is missing::
## --8<--
## set mail-format {
##   from:    Monit <monit@$HOST>
##   subject: monit alert --  $EVENT $SERVICE
##   message: $EVENT Service $SERVICE
##                 Date:        $DATE
##                 Action:      $ACTION
##                 Host:        $HOST
##                 Description: $DESCRIPTION
##
##            Your faithful employee,
##            Monit
## }
## --8<--
##
## You can override this message format or parts of it, such as subject
## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
## are expanded at runtime. For example, to override the sender, use:
#
# set mail-format { from: [email protected] }
#
#
## You can set alert recipients whom will receive alerts if/when a
## service defined in this file has errors. Alerts may be restricted on
## events by using a filter as in the second example below.
#
# set alert [email protected]                       # receive all alerts
#
## Do not alert when Monit starts, stops or performs a user initiated action.
## This filter is recommended to avoid getting alerts for trivial cases.
#
# set alert [email protected] not on { instance, action }
#
#

SET ALERT [email protected]

## Monit has an embedded HTTP interface which can be used to view status of
## services monitored and manage services from a web interface. The HTTP
## interface is also required if you want to issue Monit commands from the
## command line, such as 'monit status' or 'monit restart service' The reason
## for this is that the Monit client uses the HTTP interface to send these
## commands to a running Monit daemon. See the Monit Wiki if you want to
## enable SSL for the HTTP interface.
#
# set httpd port 2812 and
#     use address localhost  # only accept connection from localhost
#     allow localhost        # allow localhost to connect to the server and
#     allow admin:monit      # require user 'admin' with password 'monit'
#

SET HTTPD PORT 8001 ALLOW monit:monit


###############################################################################
## Services
###############################################################################
##
## Check general system resources such as load average, cpu and memory
## usage. Each test specifies a resource, conditions and the action to be
## performed should a test fail.
#
#  check system $HOST
#    if loadavg (1min) > 4 then alert
#    if loadavg (5min) > 2 then alert
#    if cpu usage > 95% for 10 cycles then alert
#    if memory usage > 75% then alert
#    if swap usage > 25% then alert
#
#
## Check if a file exists, checksum, permissions, uid and gid. In addition
## to alert recipients in the global section, customized alert can be sent to
## additional recipients by specifying a local alert handler. The service may
## be grouped using the GROUP option. More than one group can be specified by
## repeating the 'group name' statement.
#
#  check file apache_bin with path /usr/local/apache/bin/httpd
#    if failed checksum and
#       expect the sum 8f7f419955cefa0b33a2ba316cba3659 then unmonitor
#    if failed permission 755 then unmonitor
#    if failed uid root then unmonitor
#    if failed gid root then unmonitor
#    alert [email protected] on {
#           checksum, permission, uid, gid, unmonitor
#        } with the mail-format { subject: Alarm! }
#    group server
#
#
## Check that a process is running, in this case Apache, and that it respond
## to HTTP and HTTPS requests. Check its resource usage such as cpu and memory,
## and number of children. If the process is not running, Monit will restart
## it by default. In case the service is restarted very often and the
## problem remains, it is possible to disable monitoring using the TIMEOUT
## statement. This service depends on another service (apache_bin) which
## is defined above.
#
#  check process apache with pidfile /usr/local/apache/logs/httpd.pid
#    start program = "/etc/init.d/httpd start" with timeout 60 seconds
#    stop program  = "/etc/init.d/httpd stop"
#    if cpu > 60% for 2 cycles then alert
#    if cpu > 80% for 5 cycles then restart
#    if totalmem > 200.0 MB for 5 cycles then restart
#    if children > 250 then restart
#    if loadavg(5min) greater than 10 for 8 cycles then stop
#    if failed host www.tildeslash.com port 80 protocol http
#       and request "/somefile.html"
#    then restart
#    if failed port 443 protocol https with timeout 15 seconds then restart
#    if 3 restarts within 5 cycles then unmonitor
#    depends on apache_bin
#    group server
#
#
## Check filesystem permissions, uid, gid, space and inode usage. Other services,
## such as databases, may depend on this resource and an automatically graceful
## stop may be cascaded to them before the filesystem will become full and data
## lost.
#
#  check filesystem datafs with path /dev/sdb1
#    start program  = "/bin/mount /data"
#    stop program  = "/bin/umount /data"
#    if failed permission 660 then unmonitor
#    if failed uid root then unmonitor
#    if failed gid disk then unmonitor
#    if space usage > 80% for 5 times within 15 cycles then alert
#    if space usage > 99% then stop
#    if inode usage > 30000 then alert
#    if inode usage > 99% then stop
#    group server
#
#
## Check a file's timestamp. In this example, we test if a file is older
## than 15 minutes and assume something is wrong if its not updated. Also,
## if the file size exceed a given limit, execute a script
#
#  check file database with path /data/mydatabase.db
#    if failed permission 700 then alert
#    if failed uid data then alert
#    if failed gid data then alert
#    if timestamp > 15 minutes then alert
#    if size > 100 MB then exec "/my/cleanup/script" as uid dba and gid dba
#
#
## Check directory permission, uid and gid.  An event is triggered if the
## directory does not belong to the user with uid 0 and gid 0.  In addition,
## the permissions have to match the octal description of 755 (see chmod(1)).
#
#  check directory bin with path /bin
#    if failed permission 755 then unmonitor
#    if failed uid 0 then unmonitor
#    if failed gid 0 then unmonitor
#
#
## Check a remote host availability by issuing a ping test and check the
## content of a response from a web server. Up to three pings are sent and
## connection to a port and an application level network check is performed.
#
#  check host myserver with address 192.168.1.1
#    if failed ping then alert
#    if failed port 3306 protocol mysql with timeout 15 seconds then alert
#    if failed port 80 protocol http
#       and request /some/path with content = "a string"
#    then alert
#
#
## Check a network link status (up/down), link capacity changes, saturation
## and bandwidth usage.
#
#  check network public with interface eth0
#    if failed link then alert
#    if changed link then alert
#    if saturation > 90% then alert
#    if download > 10 MB/s then alert
#    if total uploaded > 1 GB in last hour then alert
#
#
## Check custom program status output.
#
#  check program myscript with path /usr/local/bin/myscript.sh
#    if status != 0 then alert
#
#
###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
   include /etc/monit/conf.d/*
   include /etc/monit/conf-enabled/*
#
root@app-server[192.168.100.83] ~ # 

更新

看来问题出在台词上

# 包括 /etc/monit/conf.d/* # 包括 /etc/monit/conf-enabled/*

一旦它们被注释掉,monit -t 检查就会通过。

这是 /etc/monit/conf.d/infomaniak 的内容,该目录中唯一的文件:

root@app-server[192.168.100.83] ~ # cat /etc/monit/conf.d/infomaniak
check process infomaniak pidfile /var/run/infomniak.pid
      start   = "/etc/init.d/infomaniak start"
      stop    = "/etc/init.d/infomaniak stop"
      restart = "/etc/init.d/infomaniak restart"

      if failed
         host audio-mon.eprs.dz
         port 8000
         protocol HTTP
         with timeout 60 seconds
      then
        alert
        restart
root@app-server[192.168.100.83] ~ #
monit
  • 1 个回答
  • 3304 Views
Martin Hope
Adilp
Asked: 2019-05-07 11:59:27 +0800 CST

监控只执行一次

  • 0

Monit 当前正在执行一次。我可以在日志文件中看到它每个周期都会检查一次,但是,当我重新加载 monit 时,执行只会发生一次。

check host somehost with address example.com
# every "* 8-19 * * 1-5"
 if failed
    port 443
    protocol https
    and certificate valid > 1095 days
 then exec "/var/local/bin/mtCert.sh"
monit
  • 1 个回答
  • 282 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve