Search code examples
apacheservermonit

Monit on apache server : why monit log " 'apache' error -- unknown resource ID: [5]" on /var/log/monit


We are monitoring several servers with Monit. We are using the version 5.25.1. Some are dedicated apache servers. The monitoring is ok. But the log of monit (/var/log/monit) is like this :

[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]

The configuration file /etc/monit.conf is like this :

###############################################################################
## 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:[email protected]: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: [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] not on { instance }

# receive all alerts
# set alert [email protected] only on { timeout }  # receive just service-
#                                                # timeout alert
#

mail-format {
      from: [email protected]
   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/*

On ui monit, everything is ok. and the monitoring is 100% useful. We can stop, restart the service like we want.

So I don't understand the sentence 'error : 'apache' error -- unknown resource ID: [5]' we found on the log of monit.

Anyone has an idea about it ?

Thanks for your help.


Solution

  • I had the same problem..

    mmonit said that loadavg is for "check system" only. it used to work for apache but not anymore..

    "The loadavg statement can be used in "check system" context only (load average is system property, not process'). Please remove the following statement and reload monit"

    so disable this line by adding # on the first of:

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

    then restart monit

    service monit restart

    You will no longer receive the appache error.