1

I am using IBM provided sample program amqsevt to monitor MQ event queues and parse the messages. But I notice that by default the event creation time is represented in GMT time. I would like to get it converted to System local time. Is there a way to accomplish this?

**** Message #1 (120 Bytes) on Queue SYSTEM.ADMIN.CHANNEL.EVENT ****
Event Type                       : Channel Event [46]
Reason                           : Channel Stopped By User [2279]
Event created                    : 2018/09/04 20:17:39.48 GMT
Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
sijo0703
  • 557
  • 1
  • 8
  • 33
  • 1
    I would suggest altering and recompiling the sample program to have it output the date in the format you like. Note that in a blog post by Mark Taylor on the subjects of events he posted a modified version that can output in JSON format, this same version is now include in the 9.1.0.0 version, it may be a easier format to feed into a monitoring tool. – JoshMc Sep 06 '18 at 21:42

1 Answers1

2

The source for the sample can be found on Linux with MQ installed in /opt/mqm at /opt/mqm/samp/amqsevta.c.

In the MQMD (Message Descriptor) of every message there is a PutDate and PutTime field that is always stored in GMT and are each simple 8 digit strings for example:

  • PutDate: 20180904 (YYYYMMDD)
  • PutTime: 20173948 (HHMMSSSS)

In the sample program it just converts that to the displayed format of 2018/09/04 20:17:39.48 and appends GMT to the end since it knows this is always in GMT.

  /**********************************************************/
  /* Timestamp is read from the MQMD - it is always in GMT  */
  /* regardless of local timezone. Do not want to try to    */
  /* convert it, because this machine may be a client in a  */
  /* different timezone than the server generating the      */
  /* event. So stick to GMT (or UCT if you prefer).         */
  /**********************************************************/
  sprintf(valbuf,"%4.4s/%2.2s/%2.2s %2.2s:%2.2s:%2.2s.%2.2s GMT",
     &pMsgDesc->PutDate[0],
     &pMsgDesc->PutDate[4],
     &pMsgDesc->PutDate[6],
     &pMsgDesc->PutTime[0],
     &pMsgDesc->PutTime[2],
     &pMsgDesc->PutTime[4],
     &pMsgDesc->PutTime[6]);
  printLine(offset,"Event created",valbuf);

It looks like you could use the c function strptime to parse the string into a epoch time stamp and then print that in your local time zone.

JoshMc
  • 10,239
  • 2
  • 19
  • 38