EMS Manual

Retrieving Event Messages Programmatically
EMS Manual426909-005
4-4
Changing the Environment
Changing the Environment
Your management application can dynamically control its distributor environment—the
source (or sources) of event messages, the log file position, and the filter and its
parameters—by using the distributor’s subsystem programmatic interface (SPI). To
control the distributor environment, use the ADD, ALTER, DELETE, and REPLACE
commands described in Section 17, Distributor Commands and Responses.
Filters and Filter Parameters
This command message example uses the non-object-oriented interface, which uses a
maximum of one filter per distributor. For distributors that require multiple filters, the
alternative object-oriented ADD, DELETE, or REPLACE command messages let you
add or delete filters or replace the current filter or return to the default filter (pass all
event messages). These commands also let you pass parameters to a filter when you
load it or change the parameter values the current filter is using.
To load a filter, pass the distributor the name of the file containing the compiled filter
specification. Use the token ZEMS^TKN^FILTERFILE to specify the file name.
For example, to construct the appropriate command message to load a filter stored in a
file called FCRIT and send it to the distributor using the WRITEREAD procedure (the
distributor will contain only this filter):
! Initialize buffer for distributor CONTROL command message
IF (error := SSINIT(spibuffer,
ZEMS^VAL^BUFLEN,
ZEMS^VAL^SSID,
ZSPI^VAL^CMDHDR,
ZEMS^CMD^CONTROL)) THEN ...
! Get external file name to use as token value
sbuf ':=' ["FCRIT", 0];
CALL FNAMEEXPAND(sbuf, filter^file^name,
my^file^defaults);
! Place token with token value in spibuffer
IF (error := SSPUTTKN(spibuffer,
ZEMS^TKN^FILTERFILE,
filter^file^name)) THEN ...
! Determine how many bytes of spibuffer have been used
spi^error := SSGETTKN(spibuffer,
ZSPI^TKN^USEDLEN,
buffer^length);
! Handle any error from SPI procedure
IF spi^error <> ZSPI^ERR^OK THEN ...
! And send the command message
CALL WRITEREAD(fnum,
spibuffer,
buffer^length,