2.2.1 Procedure for issuing JP1 events
To issue JP1 events:
-
Decide the types and attributes of the JP1 events you want to issue.
-
Write code that uses the JP1 event issuing function.
-
Compile the source files.
To be able to view in JP1/IM - View the user-defined event attributes that are appended to a JP1 event, you must then use JP1/IM to create the following definition files on a machine where JP1/IM - Manager is installed:
-
Definition file for extended event attributes
-
Definition file for object types
For details about how to create these definition files using JP1/IM, see the manual JP1/Integrated Management 3 - Manager Command and Definition File Reference.
- Organization of this subsection
(1) Determining the types and attributes of the JP1 events to be issued
To issue JP1 (user-defined) events, you must first decide what kinds of events to issue as JP1 events. The performance of the JP1/Base event service depends on the number of JP1 events that may be issued. Therefore, we recommend that you issue JP1 (user-defined) events only for those JP1 events that are needed by JP1/IM to perform system monitoring.
Next, you must determine the types of event attributes you wish to issue. To determine the event attributes, consider the information you need to know about an application when you monitor events with JP1/IM. Determine the event attributes of all JP1 (user-defined) events for each application in advance.
You can use the JP1 event attribute values as arguments for initiating automated actions and invoking monitor windows in JP1/IM. For details on the event attributes used in the example described below, see Appendix A. Criteria for Setting JP1 Event Attributes.
The example below uses the Windows application SAMPLE to explain issuing the startup event and the abnormal termination event. The character strings enclosed in parentheses are the names of the arguments in the JP1 event issuing function.
- Types of JP1 events
-
-
Startup event (JP1 event issued at the startup of the application)
Event ID (BaseID): 0x00000001
Message (message): Starts the SAMPLE application.
-
Abnormal termination event (JP1 event issued at the abnormal termination of the application)
Event ID (BaseID): 0x00000002
Message (message): The SAMPLE application terminated abnormally.
-
- Event attributes including extended attributes (extattrs): Startup event
-
Assign the following attributes to the startup event of the SAMPLE application.
Table 2‒2: Attributes to be assigned to the startup event Attribute type
Item
Attribute name
Description
Basic attribute
Event ID
--
0x00000001
Message
--
Starts the SAMPLE application.
Extended attributes (common attributes)
Event level
SEVERITY
Notice
User name
USER_NAME
SAMPLE_USER
Product name
PRODUCT_NAME
/COMPANY/APP1/SAMPLE_PRODUCT (product name)
Object type
OBJECT_TYPE
SAMPLE
Object name
OBJECT_NAME
SAMPLE_NAME
Root object type
ROOT_OBJECT_TYPE
ROOT_SAMPLE
Root object name
ROOT_OBJECT_NAME
ROOT_SAMPLE_NAME
Object ID
OBJECT_ID
SAMPLE_ID
Occurrence
OCCURRENCE
START
Start time
START_TIME
Start time of the SAMPLE application. The number of seconds from 00:00:00 on UTC 1970-01-01.
Platform type
PLATFORM
NT
Version information
ACTION_VERSION
0600
Extended attributes
(user-specific attributes)
SAMPLE common attribute 1
COMMON_ATTR1
NATIVE
SAMPLE common attribute 2
COMMON_ATTR2
TRUE
SAMPLE start attribute 1
START_ATTR1
SAMPLE1
SAMPLE start attribute 2
START_ATTR2
SAMPLE2
- Event attributes including extended attributes (extattrs): Abnormal termination event
-
Assign the following attributes to the abnormal termination event of the SAMPLE application.
Table 2‒3: Attributes to be assigned to the abnormal termination event Attribute type
Item
Attribute name
Description
Basic attribute
Event ID
--
0x00000002
Message
--
The SAMPLE application terminated abnormally.
Extended attributes (common attributes)
Event level
SEVERITY
Error
User name
USER_NAME
SAMPLE_USER
Product name
PRODUCT_NAME
/COMPANY/APP1/SAMPLE_PRODUCT (product name)
Object type
OBJECT_TYPE
SAMPLE
Object name
OBJECT_NAME
SAMPLE_NAME
Root object type
ROOT_OBJECT_TYPE
ROOT_SAMPLE
Root object name
ROOT_OBJECT_NAME
ROOT_SAMPLE_NAME
Object ID
OBJECT_ID
SAMPLE_ID
Occurrence
OCCURRENCE
END
End time
END_TIME
End time of the SAMPLE application. The number of seconds from 00:00:00 on UTC 1970-01-01.
Result code
RESULT_CODE
Termination code that the SAMPLE application returns when it terminates
Platform type
PLATFORM
NT
Version information
ACTION_VERSION
0600
Extended attributes(user-specific attributes)
SAMPLE common attribute 1
COMMON_ATTR1
NATIVE
SAMPLE common attribute 2
COMMON_ATTR2
TRUE
SAMPLE end attribute 1
END_ATTR1
SAMPLE1
SAMPLE end attribute 2
END_ATTR2
SAMPLE2
(2) Writing code that uses the JP1 event issuing function
The coding example for the SAMPLE application to issue the startup event is as follows:
#include <stdio.h> #include "JevApi.h" int regist_start_event() { int rc; /* Return code */ long status = 0; /* Detailed error code */ const char* server; /* Event server name */ long baseID; /* Event ID */ const char* message; /* Message */ const char* extattrs[15]; /* Array for storing extended attributes */ /* Set the destination event server name. */ server = NULL; /* Set the event ID. */ baseID = 0x00000001; /* Set the message. */ message = "Starts the SAMPLE application."; /* Set the extended attributes. */ extattrs[0] = "SEVERITY=Notice"; extattrs[1] = "USER_NAME=SAMPLE_USER"; extattrs[2] = "PRODUCT_NAME=/COMPANY/APP1/SAMPLE_ PRODUCT"; extattrs[3] = "OBJECT_TYPE=SAMPLE"; extattrs[4] = "OBJECT_NAME=SAMPLE_NAME"; extattrs[5] = "OBJECT_ROOT_TYPE=ROOT_SAMPLE"; extattrs[6] = "OBJECT_ROOT_NAME=ROOT_SAMPLE_NAME"; extattrs[7] = "OBJECT_ID=SAMPLE_ID"; extattrs[8] = "OCCURRENCE=START"; extattrs[9] = "PLATFORM=NT"; extattrs[10] = "VERSION=0600"; extattrs[11] = "COMMON_ATTR1=NATIVE"; extattrs[12] = "COMMON_ATTR2=TRUE"; extattrs[13] = "START_ATTR1=SAMPLE1"; extattrs[14] = "START_ATTR2=SAMPLE2"; /* Register the JP1 event. */ rc = JevRegistEvent(&status, server, baseID, message, extattrs, 15); if(rc < 0) { fprintf(stderr, "JevRegistEvent() failed. status = %ld\n", status); return -1; } return 0; }