| ASSOCIATING A SEVERITY VALUE WITH AN EVENT
The following code sends an event message to the child entity of an object.
The event can be captured using a getevent command or using the notification
window in the user interface. In the second instance the event appears as
severity "indeterminate".
MCC_T_CVR mcc_send_event()
{
MCC_T_CVR status;
long *memory;
MCC_A_AES entity = { MCC_K_NULL_PTR };
MCC_T_UNSLONG partition;
MCC_T_UNSLONG code,count;
MCC_T_Descriptor *data = { MCC_K_NULL_PTR };
MCC_T_Descriptor *timestamp = { MCC_K_NULL_PTR };
MCC_T_Descriptor *username = { MCC_K_NULL_PTR };
MCC_T_Descriptor *severity = { MCC_K_NULL_PTR };
MCC_T_Descriptor *entity_instance = { MCC_K_NULL_PTR };
MCC_T_Descriptor *child_entity_instance = { MCC_K_NULL_PTR };
unsigned char instance[100] = "hardware1";
MCC_T_Unsigned16 instance_len;
unsigned char child_instance[8] = "$1$dia0:";
MCC_T_Unsigned16 child_instance_len;
MCC_T_FullName fullname_str;
MCC_T_Unsigned16 fullname_len;
MCC_T_SimpleName simplename_str;
MCC_T_Unsigned16 simplename_len;
MCC_T_CVR dns;
struct MCC_R_ILV_CONTEXT ctx;
unsigned char username_str[7] = "System";
unsigned int username_len = 6;
unsigned int data_buffer_len;
unsigned char data_buffer[128];
MCC_T_Enumeration severity_value = 4;
/*
* Create a descriptors to hold the event data
*/
status = mcc_desframe_init_alloc_list(&memory);
/*
* time descriptor
*/
if (status == MCC_S_NORMAL)
status = mcc_desframe_create_descriptor( &memory,
×tamp,
&128,
&MCC_K_DT_BIN_ABS_TIM,
0,
0,
&DSC_K_DTYPE_T);
/*
* Read the event data from constants
*/
if (status == MCC_S_NORMAL)
status = mcc_time_get_current(timestamp);
/*
* Convert a text string to type Full_Nmae
*/
instance_len = strlen (&instance);
if ( status == MCC_S_NORMAL)
status = mcc_dns_opaque_fullname(&instance,&instance_len,&fullname_str,
&fullname_len,&dns);
/* Start of Debug code */
if (status == MCC_S_NORMAL)
status = mcc_dns_fullname_string (&fullname_str,&fullname_len,&instance,
&instance_len,&dns);
/* End of Debug code */
/*
* Convert a text string to type Simple_Name
*/
child_instance_len = strlen (&child_instance);
if (status == MCC_S_NORMAL)
status = mcc_dns_opaque_simplename(&child_instance,
&child_instance_len,
&simplename_str,
&simplename_len,
&dns);
/*
* Create descriptor to hold global entity identifier
*/
if (status == MCC_S_NORMAL)
status = mcc_desframe_create_descriptor(
&memory, /* Memory Allocation List */
&entity_instance, /* Descriptor Pointer */
&fullname_len, /* Length */
&MCC_K_DT_FULL_NAME, /* Datatype */
&fullname_str, /* Identifier Value */
&MCC_K_HARDWARE_REGISTERED_NAME,/* Id */
&DSC_K_DTYPE_T); /* VMS datatype */
/*
* Create an AES structure to hold the Global entity value
*/
if (status == MCC_S_NORMAL)
status = mcc_aes_create( &entity,
&MCC_K_CLASS_HARDWARE,
entity_instance,
&MCC_K_AES_NOT_WILD);
/*
* Create descriptor to hold child entity identifier
*/
if (status == MCC_S_NORMAL)
status = mcc_desframe_create_descriptor(
&memory, /* Memory Allocation List */
&child_entity_instance, /* Descriptor Pointer */
&simplename_len, /* Length */
&MCC_K_DT_SIMPLE_NAME, /* Datatype */
&simplename_str, /* Identifier */
&MCC_K_DISK_DEVICE, /* Id */
&DSC_K_DTYPE_T); /* VMS datatype */
/*
* Use child entity identifier to create a child entity instance pair
* in the AES structure
*/
if (status == MCC_S_NORMAL)
status = mcc_aes_create( &entity,
&MCC_K_CLASS_HARDARE_DISK,
child_entity_instance,
&MCC_K_AES_NOT_WILD);
/*
* Create descriptor to hold the event attribute "severity".
*/
if (status == MCC_S_NORMAL)
status = mcc_desframe_create_descriptor(
&memory, /* Memory Allocation List */
&severity, /* Descriptor Pointer */
&4, /* Length */
&MCC_K_DT_ENUMERATION, /* Datatype */
&severity_value, /* Identifier Value */
&MCC_K_ARG_SEVERITY, /* Id */
&DSC_K_DTYPE_T); /* VMS datatype */
/*
* Create descriptor to hold the event attribute "User".
*/
if (status == MCC_S_NORMAL)
status = mcc_desframe_create_descriptor(
&memory, /* Memory Allocation List */
&username, /* Descriptor Pointer */
&username_len, /* Length */
&MCC_K_DT_LATIN1STRING, /* Datatype */
&username_str, /* Identifier Value */
&MCC_K_DISMOUNT_USER, /* Id */
&DSC_K_DTYPE_T); /* VMS datatype */
/*
* Set the event partition & event code
*/
partition = MCC_K_PRT_NOTIFICATION_EVENTS;
code = 201; /*Disk Dismounted event*/
/*
* Create the event buffer Data descriptor
*/
data_buffer_len = sizeof( data_buffer );
if (status == MCC_S_NORMAL)
status = mcc_desframe_create_descriptor( &memory,
&data,
&data_buffer_len,
&MCC_K_DT_ILV,
&data_buffer,
&code, /*EVENT_CODE*/
&DSC_K_CLASS_S);
/*
* --------------- Encode the Event Report ---------------------------------
*
* Open the ILV encoding for the Event Report
*/
if (status == MCC_S_NORMAL)
status = mcc_ilv_put_param_begin(
&ctx,
data );
/*
* Encode the Event Arguments;
*/
if (status == MCC_S_NORMAL)
status = mcc_ilv_put(&ctx,
severity,
MCC_K_NULL_PTR );
/*
* Encode the Event Arguments:
*/
if (status == MCC_S_NORMAL)
status = mcc_ilv_put(&ctx,
username,
MCC_K_NULL_PTR );
/*
* Close the Event Report
*/
if (status == MCC_S_NORMAL)
status = mcc_ilv_put_param_end( &ctx,
data );
/*
* Deliver the event
*/
if (status == MCC_S_NORMAL)
status = show_inentity(entity);
if (status == MCC_S_NORMAL)
status == mcc_event_put(entity,&partition,&code,data,timestamp);
if (status == MCC_S_NORMAL)
status = mcc_desframe_free_alloc_list(&memory);
return (status);
}
The code which reads in this event is copied from mcc_example_getevent.c and
remains unmodified with respect to collecting the event ie; the mcc_event_get
call and creating the event report - "build_event_report"
When an event is received at the command line interface the following event
report is created :
MCC> getevent hardware * disk * any event
%DEBUG-I-DYNIMGSET, setting image MCC_HARDWARE_AM
%DEBUG-I-DYNMODSET, setting module MCC_HARDWARE_GETEVENT
DBG> go
HARDWARE LOCAL_NS:.hardware1 DISK $1$dia0
AT 20-APR-1994 09:21:21 Any Event
Event Received
Event: DISMOUNT
Disk has been dismounted by user "System"
Severity = Warning
MCC>
When this event is received at the notification window the event is given the
severity level "indeterminate" although the argument "Severity = Warning" is
displayed when the event message is expanded.
The MSL definition for the Getevent directive has not been modified. The MSL
definition for the event is given below :
...
TYPE
PerceivedSeverity = 1005 (
Indeterminate = 0,
Critical = 1,
Major = 2,
Minor = 3,
Warning = 4,
Clear = 5
);
...
EVENT DISMOUNT = 201 :
DISPLAY = TRUE,
SYMBOL = EVT_DISK_DISMOUNTED,
TEXT = "Disk has been dismounted by user !<User>"
ARGUMENT Severity = 5 : PerceivedSeverity
DISPLAY = TRUE,
SYMBOL = ARG_SEVERITY
END ARGUMENT Severity;
ARGUMENT User = 202 : Latin1String
DISPLAY = FALSE,
SYMBOL = DISMOUNT_USER
END ARGUMENT User;
END EVENT DISMOUNT;
How can I make the event appear to have the severity "Warning" in the
notification services window ?
Thanks.
- LEH
|