Post by Pramod SuryawanshiDear members,
Is there a way to get the ems stats (number of particular event in specific
time
Post by Pramod Suryawanshiframe) based on ssid and/or event number.
Example -
SSID : TANDEM.EMS.01, Event Number : 512 occurred X number of times between
time
Post by Pramod Suryawanshiframe dd-mm hh:min to dd-mm hh:min
You have a lot of flexibility in scanning EMS logs if you read them directly.
Reading and deblocking is easy,
all the work is in filtering and displaying the events.
Below are a some snippets from an EMS reader.
A physical record from the EMS logfile can contain multiple logical records
concatenated together, you have to iterate thru the buffer after each read..
zems_val_ssid_def ssid;
zems_ddl_msg_buffer_def ems_buf;
short *pemsbuff; /* for multiple events/record */
erc = FILE_OPEN_(logfilename, logfilename_len, &logfile,
ZSYS_VAL_OPENACC_READONLY,
ZSYS_VAL_OPENEXCL_SHARED);
short process_logfile(void)
{
int32_t done;
for (done = 0; done == 0; )
{
/* from FILE_GETINFOBYNAME_() on the EMS logfile */
read_len = fi.maxreclen;
READX(logfile, (char *)&ems_buf, read_len, &read_len);
FILE_GETINFO_(logfile, &erc);
if (erc != 0)
{
FILE_CLOSE_(logfile);
return(erc);
}
logfile_reads++;
erc = process_events(read_len);
if (erc)
{
break;
}
} /* for */
return(0);
}
short process_events(int32_t bytes_in_buff)
{
pemsbuff = (short *)&ems_buf; /* point to the start of the buffer */
while (bytes_in_buff > 0)
{
msglen = 0;
ems_err = SSGETTKN(pemsbuff, ZSPI_TKN_BUFLEN, (char *)&msglen);
ems_err = SSGETTKN(pemsbuff, ZSPI_TKN_SSID, (char *)&ssid);
ems_err = SSGETTKN(pemsbuff, ZEMS_TKN_EVENTNUMBER,
(char *)&eventnumber);
ems_err = SSGETTKN(pemsbuff, ZEMS_TKN_PROC_DESC, senderid);
if (ems_err)
{
ems_err = SSGETTKN(pemsbuff, ZEMS_TKN_CRTPID, senderid);
}
else
{
flags.process_descr = 1;
}
ems_err = SSGETTKN(pemsbuff, ZEMS_TKN_SYSTEM, (char *)&sysnum);
ems_err = SSGETTKN(pemsbuff, ZEMS_TKN_LOGTIME,
(char *)&ems_logtime);
/* apply filters that don't need the message text */
/* Time, SSID, Eventnumber, process, etc */
/* if you want the displayable text for an event */
ems_err = EMSTEXT((short *)pemsbuff,
(char *)&ems_msg_text,
maxlinelen,
maxlines,
(short*)&actual_len,
/* (short*)&header_key */ ,
0,
0);
/* apply filters that do need the message text */
/* display, count, total by SSID, etc the filtered event */
/* check to see if there are more events in this buffer */
bytes_in_buff = bytes_in_buff - msglen;
/* point to the next logical record */
pemsbuff = &pemsbuff[msglen/2];
} /* while */