![]() |
![]() |
|
|
Creating Log Mappings
The following sections describe how to create log mappings:
Date Formats for the -D Option
Specifying Multiple Separators
A log mapping is a list of options. For example:
-S |! -o %F8 -p sony -b %F12
A Log Monitor uses log mappings to translate log messages into the Log Central format, which is described in Log Central Message and Message Definition Formats. Log Central provides predefined mappings for several types of log files. For descriptions of these predefined mappings, see Predefined Log Mappings. This chapter describes how to create mappings for additional types of log files.
The following table describes how the previous mapping works.
If you are going to start the Log Monitors automatically when you start Log Central with the start_messaging command, you need to:
If you are going to start the Log Monitors manually with the log_monitor command, you need to define the log mappings in the message mapping file or on the log_monitor command line. If you use the log_monitor command line, you can define only one log mapping. For information about the messaging configuration file, see Configuration Files. For information about the start_messaging and log_monitor commands, see Commands. When you define log mappings in a message mapping file or in the messaging configuration file, the Log Monitor tests an incoming log message against each mapping sequentially. To be forwarded to the Central Collector, a log message needs to be selected by only one of the mappings in the file. You can use multiple mappings to handle different types of log messages that come from the same managed resource. Most of the mapping options tell the Log Monitor how to map a field in an incoming message to a field in the resulting message. However, you can use the -p and -x options to discard messages. For example, if you use the -p option in a mapping, the Log Monitor forwards a log message only if it contains the specified pattern. If you use the -x option, the Log Monitor discards log messages that contain the specified pattern. The following table describes the mapping options.
Date Formats for the -D Option
The following table describes the date formats for the -D option.
An option value can be a literal or a format. You can mix literals and formats in the same option value. To use a literal, follow the option with the specific value. For example:
-b "This is the message body."
-m "Major function"
To use a format, use format symbols to extract the value from the incoming log message. For example:
-o %F8
To use a literal and a format, precede the literal with %V, which is a format symbol. For example:
-o %F11%Vmachine
The following table describes the format symbols.
The following rules apply for converting dates from date and time values in an incoming log message to date and time values in the Log Central log message:
The following example illustrates these rules for a current date of Tuesday September 19 12:19:47 PDT 2000. Listing 5-1 Example for Mapping Dates
Input Line in Template Date
______________________________________________________________
Tue %a Sep 19 12:19:47 PDT 2000
Mon %a Sep 18 12:19:47 PDT 2000
Fri %a Sep 15 12:19:47 PDT 2000
September %B Sep 1 12:19:47 PDT 2000
January %B Jan 1 12:19:47 PDT 2000
December %B Dec 1 12:19:47 PDT 1999
Sep Tue %b %a Sep 19 12:19:47 PDT 2000
Jan Sat %b %a Jan 1 12:19:47 PDT 2000
Dec Tue %b %a Dec 7 12:19:47 PDT 1999
Jan Fri 2003 %b %a %Y Jan 3 12:19:47 PDT 2003
Fri 9 %a %H Sep 15 09:00:00 PDT 2000
Feb 10:30 %b %H:%S Feb 1 10:00:30 PDT 2000
10:30 %H:%M Sep 19 10:30:00 PDT 2000
13:30 %H:%M Sep 19 13:30:00 PDT 2000
With the -p and -x options, you can use metacharacters to select a range of values. For example, to specify a value from 97 to 99, you can use 9[7-9]. The following table lists the metacharacters you can use with the -p and -x options.
Specifying Multiple Separators
When you use the -S option, you can specify multiple separator characters. For an incoming message of abcd^xys^b|bbbb^, Table 5-6 shows how the Log Monitor parses the message with -S ^|, and Table 5-7 shows how the Log Monitor parses the message with -S ^.
Field Number |
Contents |
---|---|
1 |
abcd |
2 |
xys |
3 |
b |
4 |
bbbb |
Field Number |
Contents |
---|---|
1 |
abcd |
2 |
xys |
3 |
b|bbbb |
The Log Monitor ignores separators at the beginning of a message. For example, the fields would be exactly the same if the incoming message was |abcd^xys^b|bbbb^. If the length of a string-valued field in an incoming message exceeds its maximum, the Log Monitor truncates the value. For example, if an incoming message contains the user ID Administrator, it would be truncated to Administ. The following table lists the maximum field lengths.
Field |
Maximum Length |
---|---|
Subsystem Name |
8 |
User ID |
8 |
Hostname |
20 |
Function name |
40 |
Entity |
21 |
Timestamp |
20 |
Message Body |
2000 |
This example filters a system log. The following listing contains messages from the UNIX system log (/var/log/syslog).
Listing 5-2 UNIX System Log
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
The following listing contains a message mapping file.
Listing 5-3 Message Mapping File
-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-
The following listing shows the result of the mapping.
Listing 5-4 Result of Mapping
|N|May 16 13:51:11 2000|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 2000|AUTH|124|eclipse|11593|emilie|su:
|0|1!'su webuild' failed for emilie on /dev/ttyp4
|V|May 17 13:54:28 2000|NFS|123|eclipse|11593|emilie|vmunix:
|0|1!NFS write error: on host iseult remote file system full
|N|May 17 14:40:42 2000|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 2000|AUTH|124|eclipse|11593|emilie|su:
|0|1!'su root' succeeded for emilie on /dev/ttyp0
The following table explains how mapping the third log message in the UNIX system log (Listing 5-2) with the second line in the message mapping file (Listing 5-3) produces the second message in the results (Listing 5-4).
![]() |
![]() |
![]() |
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|