首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Monit on apache server :为什么monit在/var/ log /monit上记录“'apache‘error --未知资源ID:[5]”

Monit on apache server :为什么monit在/var/ log /monit上记录“'apache‘error --未知资源ID:[5]”
EN

Stack Overflow用户
提问于 2019-03-18 18:11:01
回答 1查看 957关注 0票数 2

我们正在使用Monit监控多台服务器。我们使用的是版本5.25.1。有些是专用的apache服务器。监控正常。但是monit (/var/ log /monit)的log如下:

代码语言:javascript
复制
[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 .conf如下所示:

代码语言:javascript
复制
###############################################################################
## 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 --未知资源ID: 5’。

有人知道这是怎么回事吗?

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-18 21:14:21

我也有同样的问题..

mmonit说loadavg只用于“检查系统”。它曾经适用于apache,但现在不是了..

“loadavg语句只能在"check system”上下文中使用(load average is system property,not process')。请删除以下语句并重新加载monit。“

因此,通过在以下内容的第一行添加#来禁用此行:

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

然后重启monit

service monit restart

您将不再收到appache错误。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55218933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档