EMS Manual

Example of Reporting Events
EMS Manual426909-005
B-9
The C Source File
/*
* Send the event. Note 0 read count
*/
if (WRITEREADX(coll_filenum, (char *)event_buf, size, 0))
DEBUG();
FILE_CLOSE_(coll_filenum); /* close the collector */
} /* end too_long */
#pragma PAGE "main program code"
/*
* This procedure represents a subsystem doing work.
* It generates an event for an exceptional condition.
*/
int main(void)
{
long long start_io, end_io;
long io_calls = 0;
char in_fname[] = "$RECEIVE ";
short count_read, error;
long long io_time;
bool bQuit = false;
short msg_length;
startup_msg_type my_startup_msg;
/* Get startup message */
if (error = get_startup_msg(&my_startup_msg, &msg_length))
DEBUG();
/* Launch an alternate collector process */
paramList.program_name = "$SYSTEM.SYSTEM.EMSACOLL";
paramList.program_name_len = sizeof("$SYSTEM.SYSTEM.EMSACOLL") - 1;
paramList.name_options = ZSYS_VAL_PCREATOPT_NAMEINCALL;
paramList.process_name = "$ACOL";
paramList.process_name_len = sizeof("$ACOL") - 1;
if (error = PROCESS_LAUNCH_( &paramList,
&errorDetail,
&outputList, sizeof(outputList),
&outputListLen))
DEBUG();
/*
* Open the EMS Collector and send it the startup message
*/
if (error = (FILE_OPEN_(outputList.u_z_data.z_procname,
outputList.z_procname_len, &coll_filenum)))
{
printf (" Unsuccessful open of the collector \n");
DEBUG();
}
if (WRITEX(coll_filenum, (char *) &my_startup_msg, msg_length))
DEBUG();
FILE_CLOSE_(coll_filenum); /* close the collector */
start_io = JULIANTIMESTAMP();
while (bQuit == false)
{
scanf ("%s", in_msg);
end_io = JULIANTIMESTAMP();
io_calls = io_calls + 1;
/* Generate event if more than 10 seconds since last input */
io_time = end_io - start_io;
if (io_time > 10000000)