event_query()
Return a list of events in the PATROL Event Manager (PEM) repository that match specified filter criteria.
Syntax
[stop-time],[status],[type],[node],[origin],
[pattern],[IDrange],[class],[severity])
Parameters
Parameter | Definition |
maxcount | string that is the maximum number of events that will be returned in the event query Specifying "" (null string) causes maxcount to default to 100. |
delimiter | string that is used to separate each event in the list of events returned by the event query*Valid Values*
|
format | format string used to present each event entry*Default*
For details, see Specifying the event_query() Output Format . |
FILTER: | |
start-time | time endpoint that specifies the oldest event timestamp that is valid for the event query*Valid Values*
The variables have the following values: |
stop-time | time endpoint that specifies the most recent event timestamp that is valid for the event query Valid Values
The variables have the following values: |
status | event statuses to be matched for the event query. Valid Values
|
type | event types to be matched for the event query *Valid Values*
|
node | computer system name to be matched by the event query. Because events in the Agent's repository all apply to the local node, the node argument is ignored. Valid Values
|
origin | application instance or class name that is valid for the event query Valid Values
|
description | character string within the event description field that is valid for the event query*Valid Values*
|
IDrange | string that defines the range of PATROL event IDs that are valid for the event query *Valid Values* x event ID x |
class | event class that is valid for the event query *Valid Values*
|
severity | lowest event severity that is valid for the event archival *Valid Values*
|
Description
The event_query() function returns a list of up to maxcount events found in the PATROL Agent PATROL Event Manager repository that matched the filter criteria. The returned list is formatted as specified by format .
The event_query() function returns the NULL string if no events were found in the event repository that match the filter criteria.
Matching Strings in Event Queries
Several methods may be used to specify string matches for event queries.
Substring Match
For the description and class fields, the specified query string will match if it is contained in the corresponding field of the event. For example, query string "App"would match "RegApp", "UpdAppState", "WorstApp", etc.
Note
Including a wildcard character means that the match will be treated as a wildcard match, and thus any unmatched characters must be accounted for by wildcards. So for example, while either "App" or "App" will match"UpdAppState", the query strings "App*" or "*App" will not.
Object Match
When specifying and exact object name, subordinate objects will also be matched. This applies to the origin field. The origin field does not perform other sorts of substring matches. For example, query string "APPLICATION" would match"APPLICATION","APPLICATION.Instance","APPLICATION.Instance.Parameter", etc. However "APPL" will match none of these, because the entire name of the parent object is not provided.
Wildcard Match
The description, class, and origin fields allow matches based on simple wildcards using the wildcard character "". This character will match 0 or more characters of any kind in determining the match. When performing a wildcard match, wildcards must account for all characters that are not found in the correspoding event field. For example, "*App" will match "UpdAppState", but"App*" or "*App" will not.
Note
Wildcard matches are retained for compatibility reasons, but may become deprecated at some time in the future. BMC Software recommends using the more powerful and flexible regular expression matches instead.
Regular Expression Match
The description, class, and origin fields allow matching by regular expressions. To indicate that a regular expression is being used, the search string is surrounded by "/" characters.
To negate a regular expression, that is, to return items that do not match the regular expression, the search string is surrounded by "/" characters and preceded by the character "^".
Specifying More than One String to Match
The description, class, and origin fields may supply more than one string to be matched. Fields that match any of the of the supplied strings will be included with the query set. To separate the strings, use an escaped newline character, "\n".
Specifying the event_query() Output Format
The event_query() function format parameter is similar to the specification string used for the standard C library printf() function. The format parameter can contain alphanumeric characters for use as titles and field names, and string literals for spacing, tabbing, and carriage control.
PATROL macro variables within the format parameter identify the fields that the event_query() function returns. The following table describes the macro variables available to the event_query() function.
event_query() Function Macro Variables
PEM Macro | Definition |
---|---|
%{EV_ACK_TEXT} | text string from the acknowledge command of this event catalog and class |
%{EV_ARG1} | PATROL Event Manager first dynamic argument |
%{EV_ARG2} | PATROL Event Manager second dynamic argument |
%{EV_ARGS} | character string that presents the event arguments separated by tab characters ( \t ) |
%{EV_CATALOG} | name of the PATROL event catalog to which the event belongs |
%{EV_CLASS_NAME} | name of the PATROL event class within the PATROL event catalog to which the event belongs |
%{EV_CTG_DESC} | text string from the description of this event catalog and class |
%{EV_DESC} | text string description that was produced for the event |
%{EV_DIARY} | text string that was entered into the diary for the event |
%{EV_ESCL_TEXT} | text string from the escalation command of this event catalog and class |
%{EV_EXPECTANCY} | life expectancy and disposition of the event. Valid Values |
%{EV_EXPERT_ADVICE} | text string from the expert advice of this event catalog and class |
%{EV_HANDLER} | user ID of the person who performed the last acknowledge, close, or delete action on the event |
%{EV_ID} | sequential integer identifier assigned by the PATROL Event Manager upon receipt of the event |
%{EV_NAME} | name of the event within the PATROL event class |
%{EV_NODE} | host name that produced the event |
%{EV_NOTIFY_TEXT} | text string from the notification command of this event catalog and class |
%{EV_NSEVERITY} | numeric severity of the event. Event severity is predefined for all event classes in the STANDARD catalog |
%{EV_ORIGIN} | application instance or class that produced the event. |
%{EV_OWNER} | user ID that owns the event *Default* |
%{EV_SNMP_SUPPORT} | text string from the SNMP support of this event catalog and class *Valid Values* |
%{EV_STATUS} | event status *Valid Values* |
%{EV_TIME} | time stamp indicating the system clock time at the moment the event was produced |
%{EV_TYPE} | event type *Valid Values* |
Example
The following is an example of the event_query() function:
event_query(
"100", # return a maximum of 100 events
"\n\n", # use two newline characters to separate each event
# return ID, type, and description
"event id: %{EV_ID}\nevent type: %{EV_TYPE}\nevent
description: %{EV_DESC}\n",
# filter definition starts here:
"", # any start time
"", # any stop time
"O", # only OPEN status
"A,W", # only ALARM and WARNING types
"", # any node
"", # any origin
"", # match any description text
"-/-", # match any event ID
"", # match any event class
"" # match any event severity
)
. "\n"
);