monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom log file


From: Marco Ermini
Subject: Re: Custom log file
Date: Fri, 27 May 2005 23:56:50 +0200

Sorry for taking for than 5 days :-)

This is the patch to apply... it should apply on the CVS version of
Monit. It should work well, but testers are very welcomed.

This is a very brief summary of what it does.

1) It does not affect the actual log file. Code is in place to
customize the actual log too, and it should be quite simply to apply
it. But actually it is a separate file. This is because it logs
_specific_ things (i.e. it does not care about Monit specific errors,
i.e. missing log file, cannot open the log file, assert violations,
etc). Look at it as the difference between Apache's error log and
access log: the Monit's own log is the Apache error log, the customlog
is the access log. The purpose is to have a log which you can parse
cleanly with KPI programs, HP OpenView etc. so no "trash" must go in
it.

2) if you specify the customlog file, you activate it.

set customlogfile /var/log/custommonit.log

from now then every service has its own customlog (if you don't
specify it, default values applies).


3) to specify a format:

set customlog format "{%d/%m/%Y, %T}t, %a, %s, %m, %y(%Y)"
(this is the default).

Possible values are:

- %% = the % character
- %a = alarm id
- %d = event description (as from Event_get_description())
- %g = service group name (if any, or "no group" instead)
- %m = custom message specified in the service (see it later)
- %M = event message (i.e. the message which usually appears in the
normal Monit log)
- %n = service name (from the monitrc)
- %s = severity (see later)
- %S = status ("failed" or "passed")
- %t = standard Monit time format
- %y = service type (don't remeber now, please try yourself :-P)
- %Y = type of check ("Device", "Directory", "File", "Process", "Host")

If a character is nor recognized it is simply printed.

A special handling could be done for the date. If you specify the the
"{}t" token, everything which you put between the {} if formatted like
in the strftime() function (exactly the same as it works in Apache,
same syntax).

The "severity" is a special things which I needed. You can choose a
level of severity for your failing service between normal, warning,
minor, major, critical, fatal. When a service becomes failing, in the
customlog file is printed the severity you choose; when the service
becomes responsive again, the "Normal" severity is forcefully printed;
if you defined a timeout, when the service timeouts the "Fatal"
severity is forcefully printed.

Remember that the customlog follows the same rule of the "normal" log
in which when the service becomes responsive again, no more "Normal"
events are printed (in fact the "Normal" should be used to clear the
event with HP OpenView).

the syntax to specify a customlogger is:

customlogger [string] [ALARMID alarmnumber] [SEVERITY severitystring]

every parameter is optional. Defaults are: "Monit Alarm", "auto", "Warning".

An example of usage:

check host localweb with address 127.0.0.1
    start "/Library/Apache2/bin/apachectl -k start"
    stop  "/Library/Apache2/bin/apachectl -k stop"
    if failed port 80 proto http request "/" then restart
    if 5 restart within 5 cycles then timeout
    customlogger "webserver at port 80" alarmid auto severity major

The alarmid may be "auto" (or zero, is the same as auto) which means
that you let Monit auto-assign an alarm id number. In any case if you
assign the same number to two or more services, it will silently
re-assign a new unique alarm id number.

This should be all... happy hacking. Hope it finds its way in the
Monit project. It is now correctly working for me.


Bye bye!!!
-- 
Marco Ermini
http://www.markoer.org
Dubium sapientiae initium. (Descartes)
address@hidden # mount -t life -o ro /dev/dna /genetic/research
<< This message is for the designated recipient only and may contain
privileged or confidential information. If you have received it in
error, please notify the sender immediately and delete the original.
Any other use of the email by you is prohibited. >>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]