ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » api exit like amqsaxe in more readable format - resolved

Post new topic  Reply to topic
 api exit like amqsaxe in more readable format - resolved « View previous topic :: View next topic » 
Author Message
vasilev
PostPosted: Fri Mar 01, 2024 3:45 am    Post subject: api exit like amqsaxe in more readable format - resolved Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
Location: Germany

Hello,
there is a lot information about API Exits and amqsaxe.
I dont find info how to use only the information that is interesting for us - like messagedata, application connected - not in HEX format.
there is mqtracingexit for Instana , that perhaps is doing this, i dont think somebody will provide the source


This is part of the amqsaxe:

Code:
fprintf(fp, "MQPUT\n");
  fprintf(fp, TITLE_FORMAT, "BEFORE", buffer1, buffer2);

  if (pExitUserArea->Options & OPTIONS_DUMP_PARMS_BEFORE)
    DumpParms( fp, pExitParms );

  if (pExitUserArea->Options & OPTIONS_DUMP_CONTEXT_BEFORE)
    DumpContext( fp, pExitContext );

  fprint_hex(fp, "Hconn", pHconn);
  fprint_hex(fp, "Hobj" , pHobj);
  fprintf(fp, "  MsgDesc       : %s\n", strptr(ppMsgDesc,     "0x%p",   buffer1));
  DumpHex(fp, *ppMsgDesc, mdSize);
  fprintf(fp, "  PutMsgOpts    : %s\n", strptr(ppPutMsgOpts,  "0x%p",   buffer1));
  DumpHex(fp, *ppPutMsgOpts, pmoSize);



it is providing such output:

Code:
  BufferLength  : -1116373500
  Buffer        : 0x0x7ffdbd757df8
          0x7ffdbd75a950:    74657374 6D657373 616765             testmessage
 AFTER                     2024-03-01  12:41:26          1709293286.579304
  MsgDesc       : 0x0x7ffdbd757e10
          0x7ffdbd758620:    4D442020 01000000 00000000 08000000  MD  ............
          0x7ffdbd758630:    FFFFFFFF 00000000 22020000 00000000  ........".......
          0x7ffdbd758640:    4D515354 52202020 FFFFFFFF 02000000  MQSTR   ........
          0x7ffdbd758650:    414D5120 564D5141 50502020 20202020  AMQ VMQAPP
          0x7ffdbd758660:    DCBEE165 01260040 00000000 00000000  ...e.&.@........
          0x7ffdbd758670:    00000000 00000000 00000000 00000000  ................
          0x7ffdbd758680:    00000000 00000000 00000000 00000000  ................
          0x7ffdbd758690:    00000000 00000000 00000000 00000000  ................
          0x7ffdbd7586a0:    00000000 00000000 00000000 00000000  ................
          0x7ffdbd7586b0:    00000000 00000000 00000000 00000000  ................
          0x7ffdbd7586c0:    00000000 00000000 00000000 00000000  ................
          0x7ffdbd7586d0:    00000000 00000000 00000000 00000000  ................
          0x7ffdbd7586e0:    00000000 6D716D20 20202020 20202020  ....mqm
          0x7ffdbd7586f0:    03393939 00000000 00000000 00000000  .999............
          0x7ffdbd758700:    00000000 00000000 00000000 00000006  ................
          0x7ffdbd758710:    20202020 20202020 20202020 20202020
          0x7ffdbd758720:    20202020 20202020 20202020 20202020
          0x7ffdbd758730:    06000000 616D7173 70757420 20202020  ....amqsput
          0x7ffdbd758740:    20202020 20202020 20202020 20202020
          0x7ffdbd758750:    32303234 30333031 31313431 32363537  2024030111412657



Is there any information how to remove all this hex data and return only the readable data on one line ?

like:

2024-03-01 12:41:26 amqsput testmessage

I have started from here (not sure if it is correct), it is writing without hex output:

Code:
for (i = 0; (i < 16) && (index < DataLength); i++)
      {
        if ((i % 4) == 0) pd++;

      /*  *pd++ = HEX[ *p / 16 ];
        *pd++ = HEX[ *p % 16 ]; */
        *pa++ = isprint(*p) ? *p : '#';

        index++;
        p++;
      }


But still - it is writing on different lines. Idea is to return on one line as a variable not to print it on many lines.

Code:
MsgDesc       : 0x0x7f09500762d0
          0x7f0950076a50:                                         MD  ############
          0x7f0950076a60:                                         ########"#######
          0x7f0950076a70:                                         MQPCF   ########
          0x7f0950076a80:                                         AMQ VMQAPP
          0x7f0950076a90:                                         k##e###@########
          0x7f0950076aa0:                                         ################
          0x7f0950076ab0:                                         ####SYSTEM.BROKE
          0x7f0950076ac0:                                         R.INTER.BROKER.C
          0x7f0950076ad0:                                         OMMUNICATIONS


I think it will be good for all to have some more clear output for the api exits.

thank you
_________________
Regards
V.Vasilev


Last edited by vasilev on Sun Mar 03, 2024 11:58 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
vasilev
PostPosted: Fri Mar 01, 2024 6:25 am    Post subject: Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
Location: Germany

I have experimented with :

char outStr[sizeof(DataLength)];
memcpy(outStr,StringBuffer,sizeof(StringBuffer));
}
fprintf(fp, "%s", outStr);

also tried with return outStr and char * instead of void, but seems something i am missing.

Code:
MQPUT
 BEFORE                    2024-03-01  15:22:17          1709302937.933184
           Hconn: (0x7ffed4baea9c) 0x1400006
            Hobj: (0x7ffed4baea98) 0x2
  MsgDesc       :
....               �  PutMsgOpts    : 0x0x7ffed4baea88
................   W  BufferLength  : -725947772
  Message        :
testdata
 AFTER                     2


I have ? symbols, perhaps because of the lenght. not sure how to prevent this
_________________
Regards
V.Vasilev
Back to top
View user's profile Send private message Visit poster's website
bruce2359
PostPosted: Fri Mar 01, 2024 11:48 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9400
Location: US: west coast, almost. Otherwise, enroute.

I'd strongly suggest leaving the exit in its original and unmodified state, and then write a stand alone app or batch script to read the resulting file excluding what you don't want to see.

In the header info, you are provided with the the buffer address, buffer length, and message content in the usual hex dump format.

0x7ffdbd758620 displays bytes 20-2F displacement of your message
0x7ffdbd758630 displays bytes 30-3f displacement of your message
and so on

Quote:
BufferLength : -1116373500
Buffer : 0x0x7ffdbd757df8
0x7ffdbd75a950: 74657374 6D657373 616765 testmessage
AFTER 2024-03-01 12:41:26 1709293286.579304
MsgDesc : 0x0x7ffdbd757e10
0x7ffdbd758620: 4D442020 01000000 00000000 08000000 MD ............
0x7ffdbd758630: FFFFFFFF 00000000 22020000 00000000 ........".......
0x7ffdbd758640: 4D515354 52202020 FFFFFFFF 02000000 MQSTR ........

_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
vasilev
PostPosted: Fri Mar 01, 2024 1:54 pm    Post subject: Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
Location: Germany

I have created another char * function , returning char that concatenate with strcat the buffer .
the idea behind this is to print each exit in json text and put the content to MQ, that is why only the real text is needed so it can be added to the array.

but still getting some ?? and .... chars, not sure if it is possible to trim only the real text.
_________________
Regards
V.Vasilev
Back to top
View user's profile Send private message Visit poster's website
hughson
PostPosted: Sat Mar 02, 2024 7:10 pm    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1916
Location: Bay of Plenty, New Zealand

What is it you are trying to achieve with this exit? Are you trying to produce some sort of MQ API tracing? Have you considered using Application Activity Trace rather than using an API Exit?

Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
vasilev
PostPosted: Sat Mar 02, 2024 10:34 pm    Post subject: Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
Location: Germany

hello Morag,

yes, and some sort of message tracking, here i want to limit the string of a message body to 500 chars because i guess if it is not limited it will be a big load and traffic. and another thing is to not write ..... when there is no char, but only the char.

i wanted to use the other way because the solution will be in java if i am not wrong but it is not supported for z/os :

https://www.ibm.com/docs/en/ibm-mq/9.3?topic=network-application-activity-trace

the idea to make json in the end with all structure that i get is because it is easy to be parsed.
_________________
Regards
V.Vasilev
Back to top
View user's profile Send private message Visit poster's website
hughson
PostPosted: Sat Mar 02, 2024 11:22 pm    Post subject: Reply with quote

Padawan

Joined: 09 May 2013
Posts: 1916
Location: Bay of Plenty, New Zealand

vasilev wrote:
i wanted to use the other way because the solution will be in java if i am not wrong but it is not supported for z/os :

https://www.ibm.com/docs/en/ibm-mq/9.3?topic=network-application-activity-trace


I hear you say that you want a solution that will work on z/OS, and that is why you cannot use Application Activity Trace, but the API Exit you were mentioning at the start of this thread is also not available on z/OS.

What is your plan for z/OS?

vasilev wrote:
...and some sort of message tracking ...

Are you actually making changes to your message data then? Not just writing out trace?

Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
vasilev
PostPosted: Sun Mar 03, 2024 1:09 am    Post subject: Reply with quote

Acolyte

Joined: 31 Oct 2014
Posts: 58
Location: Germany

Morag, thanks.

I have read your pdf instruction, also found an idea of how to output the trace to JSON - with amqsevt (same I am using for monitoring) and this is what I need.
_________________
Regards
V.Vasilev
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » api exit like amqsaxe in more readable format - resolved
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.