The Log Monitor program integrates logs into Log Central. Log Monitor does the following:
A number of predefined mappings of log formats are provided with Log Monitor. For information on how to start Log Monitor using a predefined mapping, refer to Chapter 8, "Starting and Stopping Log Central." This chapter describes how to construct mappings for additional log files that you want to monitor. Consult Appendix A, "Message Format," for information about the Log Central log message format.
There are two ways to pass a mapping to Log Monitor when it is started:
This chapter describes the configuration file options. Passing the options on the command line, and the syntax used in starting Log Monitor, are discussed in Chapter 8, "Starting and Stopping Log Central."
A Log Monitor configuration file is simply a list of up to 20 different Log Monitor filters, each on a separate line. Each filter consists of a list of Log Monitor options.
Filters can be used to specify which messages to drop. For example, if you use the Alternatively, you can use the Log Monitor tests each incoming message against each filter sequentially. A log message that fails to be selected by one filter in the configuration file may be selected by one of the other filters. A log message is forwarded by the Log Monitor to the Log Central database if it is selected by at least one of the filters in the configuration file.
You may want to use multiple filters to provide different mappings for different message types.
If you use a configuration file to instruct Log Monitor how to map incoming log messages, the name of the configuration file is passed to Log Monitor in the Table 4-1 summarizes the options that are available for defining a mapping in a configuration file.
You can specify how the value for an option is determined in two ways: by literal value and by format. The methods can be mixed.
To specify the option by literal value, follow the option with the specific value. For example:
If you specify both a literal value and a format, the literal must start with the characters To specify the value by format, use format symbols to extract the value from the application log message. Examples appear in Table 4-2 under The following is an example of a command used to start Log Monitor with options in a configuration file.
The configuration file is named Each line pertains to one filter or mapping for the The separator specification following the When you use the If the following is the incoming message:
Specifying 1
2
3
4
Specifying 1
2
3
Separators at the beginning of a message are ignored. For example, the fields would be exactly the same as the previous table if the incoming message were:
The The pattern may simply be a string. For example, if you use:
then any message in which to specify such a range.
The Table 4-3 lists the metacharacters you can use with the
Here are examples of metacharacter usage with Log Monitor Configuration File Options
-p
pattern option in a filter, a log message that satisfy this filter is then forwarded by Log Monitor. If this is the only filter in the file, any message not matching the pattern specified by the -p
option will be discarded.
-x
option to specify particular messages that you do not want selected. To select which message to ignore, the -x
option also uses a pattern to determine a match. Using patterns with the -x
and -p
options is discussed below under "Using the -p and -x Options."
-f
option when it is started.
Specifying Option Values
-u KONG
-b "This is the message body."
-m "Major function"
-d 1234%V
, which is explained in Table 4-2.
%C
and %V
.
Example of Using Log Monitor with a Configuration File
log_monitor -f
forward_options
-i /home/demo/demo.mul_fld -t 0forward_options
. The contents of forward_options
are:
-S |! -o %F8 -p sony -b %F12 -T %F10
-S |! -I %F6 -u %F7 -b %F11 -x error
-S |! -m %F3%V=%C30S| -n %F8%F10 -b %F11 -D %F2/home/demo/demo.mul_fld
log file. Log Monitor works on these filters sequentially. Log Monitor picks one message, applies the three filters one after the other, then moves to the next message in the input file.
-S
option indicates that either |
or !
is considered to be a separator. Whichever one the parser encounters signals the start of a new field. For an explanation of the -S
option, refer to "Multiple Separators with the -S Option."
Multiple Separators with the -S Option
-S
option, you can specify multiple separator characters. The following example shows how fields are numbered in such situations.
abcd^xys^b|bbbb^
-S^
| for the separator results in the following.
abcd
xys
b
bbbb
-S^
for the separator results in the following.
abcd
xys
b|bbbb
|abcd^xys^b|bbbb^
Using the -p and -x Options
-p
option specifies a pattern that is used to select messages for forwarding. If a message does not match the pattern, it is not selected for forwarding by that filter.
-p su:
su:
occurs will be selected. You can also use metacharacters to select a range of values. For example, if you want to select messages with a year value from 97 to 99, you could use:
9[7-9]
-x
option specifies a pattern that is used to select messages to be discarded. If a message matches the pattern, it is not selected by that filter. (However, that message might still be selected for forwarding by another filter if you are using multiple filters in the same configuration file.)
-p
and -x
options.
-x
and -p
:
[aeiou]
[^a-zA-Z0-9]
-x [a-zA-Z][a-zA-Z]*$
-p (?*)
-x %gobbledegook$
gobbledegook
.
If the length of a string-valued field in the input file goes beyond its maximum, the value is truncated. For example, if an input message contains the user ID Administrator
, it would be truncated to Administ
.
The maximum lengths of the fields are the following.
Subsystem Name |
8 |
User ID |
8 |
Hostname |
20 |
Function name |
40 |
Transaction Key |
21 |
Timestamp |
20 |
Message Body |
2000 |
When specifying the date by format, use the date format detailed in Table 4-4.
This section gives an example of filtering a system log. The following file contains messages from the UNIX system log (/var/log/syslog
):
May 15 11:06:02 eclipse vmunix: psig: "EM_client" signal 15 was
masked, put back.
May 16 13:51:11 eclipse lpd[8951]: /usr/spool/lpd/lpd-log: No such
file or directory
May 17 10:38:12 eclipse su: 'su webuild' failed for emilie on
/dev/ttyp4
May 17 13:54:28 eclipse vmunix: NFS write error: on host iseult
remote file system full
May 17 13:54:37 eclipse last message repeated 13 times
May 17 14:40:42 eclipse lpd[9290]: /usr/spool/lpd/lpd-log: No such
file or directory
May 17 17:08:09 eclipse su: 'su root' succeeded for emilie on
/dev/ttyp0
Our configuration file (conf_file
) contains the following lines:
-M LM_VERBOSE -D "%F1%V %F2%V %F3%f%h %d %T" -S " " -m NFS -d 123
-o %F4 -p "write error" -u emilie -n %F5 -b %F6-
-D "%F1%V %F2%V %F3%f%h %d %T" -S " " -m AUTH -d 124 -o %F4 -p su:
-u emilie -n %F5 -b %F6-
-D "%F1%V %F2%V %F3%f%h %d %T" -S " " -m PRINT -d 125 -o %F4 -p lpd
-u emilie -n %F5 -b %F6-
To filter the UNIX system log, run the following command:
log_monitor -i/var/log/syslog
-f /home/emilie/conf_file
(For log_monitor
command options, refer to Appendix 8, "Starting and Stopping Log Central.")
This produces the following Log Central messages:
|N|May 16 13:51:11
1998|PRINT|125|eclipse|11593|emilie|lpd[8951]:|0|1!/usr/spool/lpd
/lpd-log: No such file or directory
|N|May 17 10:38:12 1998|AUTH|124|eclipse|11593|emilie|su:|0|1!'su
webuild' failed for emilie on /dev/ttyp4
|V|May 17 13:54:28
1998|NFS|123|eclipse|11593|emilie|vmunix:|0|1!NFS write error: on
host iseult remote file system full
|N|May 17 14:40:42
1998|PRINT|125|eclipse|11593|emilie|lpd[9290]:|0|1!/usr/spool/lpd
/lpd-log: No such file or directory
|N|May 17 17:08:09 1998|AUTH|124|eclipse|11593|emilie|su:|0|1!'su
root' succeeded for emilie on /dev/ttyp0
The following table shows how the mapping in the second line in conf_file
produced the second Log Central message shown in the preceding. Two generated lines of output (the second and fifth messages in the preceding) were produced as a result of that mapping.
Note:
There must be separators between the date format specifiers with %f
; the same separator should appear in the value specified for -D
. This is why %V
is used in the first part of the specification to fill in the corresponding separators between the fields generated by Log Monitor.
Where fields are specified, the field numbers are calculated by using the separator specified with the -S
option, which is a blank in the preceding example (the second line in conf_file
).
To specify the date format, precede the data format with %f
.
If the input file contains lines like the following:
May 15 11:06:02 eclipse vmunix: psig: "EM_client" signal 15 was masked, put back.
May 16 13:51:11 eclipse lpd[8951]: /usr/spool/lpd/lpd-log: No such file or directory
To map these dates, you could use the following:
-D "%F1%V %F2%V %F3%f%h %d %T" -S " "
If the input file contains a line like the following:
eclipse|su:|12/12/99 09:20|'su root' succeeded for emilie on /dev/ttyp0
To map the date, you could use the following:
-D %F3%f"%D %H:%M" -S|
The following rules are applied for converting the input specification into the internal format:
The following examples illustrate these rules. Assume that the current date is
Tue Sep 22 12:19:47 PDT 1998
.
Input Line in Template Date
______________________________________________________________
Tue %a Sep 22 12:19:47 PDT 1998
Mon %a Sep 28 12:19:47 PDT 1998
Fri %a Sep 26 12:19:47 PDT 1998
September %B Sep 1 12:19:47 PDT 1998
January %B Jan 1 12:19:47 PST 1999
December %B Dec 1 12:19:47 PST 1998
Sep Tue %b %a Sep 1 12:19:47 PDT 1998
Jan Sat %b %a Jan 2 12:19:47 PST 1999
Dec Tue %b %a Dec 1 12:19:47 PST 1998
Jan Fri 2003 %b %a %Y Jan 3 12:19:47 PST 2003
Fri 9 %a %H Sep 26 09:00:00 PDT 1998
Feb 10:30 %b %H:%S Feb 1 10:00:30 PST 1999
10:30 %H:%M Sep 23 10:30:00 PDT 1998
13:30 %H:%M Sep 22 13:30:00 PDT 1998