【问题标题】:Monit on apache server : why monit log " 'apache' error -- unknown resource ID: [5]" on /var/log/monit在 apache 服务器上监控:为什么在 /var/log/monit 上监控日志“'apache' 错误 -- 未知资源 ID:[5]”
【发布时间】:2019-08-08 16:16:06
【问题描述】:

我们正在使用 Monit 监控多台服务器。我们使用的是 5.25.1 版本。 有些是专用的 apache 服务器。监控没问题。 但是monit的日志(/var/log/monit)是这样的:

[CET Mar 18 03:12:03] info     : Starting Monit 5.25.1 daemon with http interface at [0.0.0.0]:3353
[CET Mar 18 03:12:03] info     : Monit start delay set to 180s
[CET Mar 18 03:15:03] info     : 'xxxxx.localhost' Monit 5.25.1 started
[CET Mar 18 03:15:03] error    : 'apache' error -- unknown resource ID: [5]
[CET Mar 18 03:16:08] error    : 'apache' error -- unknown resource ID: [5]
[CET Mar 18 03:17:08] error    : 'apache' error -- unknown resource ID: [5]
[CET Mar 18 03:18:08] error    : 'apache' error -- unknown resource ID: [5]

配置文件/etc/monit.conf是这样的:

###############################################################################
## Monit control file
###############################################################################

###############################################################################
## Global section
###############################################################################
##
## Start Monit in the background (run as a daemon):
# 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 daemon 60
      with start delay 180

### 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 list of mail servers for alert delivery. Multiple servers may be
## specified using a comma separator. 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 localhost

## 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 maximal queue
## size 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 http://mmonit.com/).
#
# set mmonit http://monit:monit@192.168.1.10:8080/collector
#
#
## Monit by default uses the following alert mail format:
##
##
## 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: monit@foo.bar }
#
#
## 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 fake@mail.com not on { instance }

# receive all alerts
# set alert manager@foo.bar only on { timeout }  # receive just service-
#                                                # timeout alert
#

mail-format {
      from: xxxxxxx@monit.localhost
   subject: $SERVICE => $EVENT
   message:
DESCRIPTION : $DESCRIPTION
ACTION      : $ACTION
DATE        : $DATE
HOST        : $HOST

Sorry for the spam.
Monit
}


## Monit has an embedded web server which can be used to view status of
## services monitored and manage services from a web interface. See the
## Monit Wiki if you want to enable SSL for the web server.
#
set httpd port 3353 and
use address 0.0.0.0
allow yyyyy:zzzz

###############################################################################
## SeSTART rvices
###############################################################################
##
## 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 xxxxxx.localhost
    if loadavg (1min) > 8 for 5 cycles then alert
    if loadavg (5min) > 4 for 5 cycles then alert
    if memory usage > 75% for 5 cycles then alert
    if cpu usage (user) > 70% for 5 cycles then alert
    if cpu usage (system) > 50% for 5 cycles then alert
    if cpu usage (wait) > 50% for 5 cycles then alert

check process apache with pidfile /var/run/httpd/httpd.pid
    group www
    start program = "/etc/init.d/httpd start" with timeout 60 seconds
    stop program  = "/etc/init.d/httpd stop"
    if failed host localhost port 80 then restart
    if cpu > 60% for 2 cycles then alert
    if cpu > 80% for 5 cycles then restart
    if loadavg(5min) greater than 10 for 8 cycles then restart
    if 3 restarts within 5 cycles then timeout    
###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
#  include /etc/monit.d/*
#
#

# Include all files from /etc/monit.d/
include /etc/monit.d/*

在 ui monit 上,一切正常。并且监控是100%有用的。我们可以随意停止、重启服务。

所以我不明白我们在monit的日志上找到的句子'error : 'apache' error -- unknown resource ID: [5]'。

有人知道吗?

感谢您的帮助。

【问题讨论】:

    标签: apache server monit


    【解决方案1】:

    我有同样的问题..

    mmoni 说 loadavg 仅用于“检查系统”。它曾经适用于 apache,但现在不再适用了..

    “loadavg 语句只能在“检查系统”上下文中使用(平均负载是系统属性,而不是进程')。请删除以下语句并重新加载监视器”

    所以通过在第一个添加#来禁用此行:

    # if loadavg(5min) greater than 10 for 8 cycles then restart

    然后重启监控

    service monit restart

    您将不再收到 appache 错误。

    【讨论】:

    • 完美!它现在可以正常工作而没有日志。感谢您的建议 Abderrahmane。
    • 太棒了!我很高兴能在这方面为您提供帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多