Directives


A MAP file can also contain a DEFINE or a REQUIRE directive.

DEFINE directive

A DEFINE directive is a line beginning with the DEFINE keyword, as shown in the following illustration:

DEFINE the_define "define value" <new line>

When such a statement is made, each subsequent statement in which a value is represented by #the_define (the first ' # ' character is required), is replaced by "define value," excluding the space characters before the end of line.

A comment line is a line in which the first non-space character is a #, a ! , or a % character. Comment lines and empty lines are ignored.

 REQUIRE directive

User-defined Perl files can be included in the .map file by using the REQUIRE directive, instead of using the MapFunctionsName parameter, as follows:
REQUIRE <perl_module>

In general, <perl_module> is a Perl module or script containing functions accessible from within the .map file. The location must be either the Perl standard library directory or the installationDirectory\pw\server\lib\perl directory. Subdirectories are allowed with the standard Perl " :: " notation. For example, the following figure is an extract from the mcsyslogd.map file.

mcsyslogd.map file excerpt (part 1 of 2)

REQUIRE MA::MapUtil
# ... lines are missing
CLASS SYSLOG_BASE $complete equals
   logfile = $LOGFILE

mcsyslogd.map file excerpt (part 2 of 2)

   source = "Syslog"
   mc_incident_time = DateSyslog2Epoch ($complete[1])

DateSyslog2Epoch is defined in installationDirectory\pw\server\lib\perl\MA\MapUtil.pm.

Multiple REQUIRE statements are allowed within the same .map file.

Following the object-oriented Perl methods, the first argument of each user-defined call is a reference to the MA::Map object. The INPUT_VARIABLES of the MAP file can be found in the {specific_event} key of the MA::Map object, as illustrated in the following figure:

Map call

sub DateSyslog2Epoch
   {
     my MA::Map $map = shift;
     my $str = shift;
# See MapUtil.pm for the rest of source.
#
# INPUT_VARIABLES could accessed as (for instance):
# my $ivars = $map->{specific_event};
# foreach my $iv (keys %$ivars)
# {
# # Do something with $iv and $ivars > {$iv}

In the preceding figure, DateSyslog2Epoch has been called with the single argument, $complete[1]. The adapter automatically adds the MA::Map object to the beginning of function arguments so that the first shift inside the implementation of DateSyslog2Epoch returns the MAP object while the second shift returns the string corresponding to $complete[1]. For more information, see the installationDirectory\pw\server\lib\perl\MA\Map.pm file.

Warning

Note

The function that $complete performs in the LogFile, Perl EventLog for Windows, and SNMP adapter mappings is performed by $data for the IP adapters. (See references to the $data variable in IP Adapter parsers.) $data is provided automatically. However, you cannot rename it.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC ProactiveNet 9.6