Communicating with Zabbix from REXX

IBM's Command List programming language & Restructured Extended Executor
User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Communicating with Zabbix from REXX

Postby sergeyken » Wed Mar 03, 2021 7:00 pm

AllardK wrote:from the protocol description I would come to this:

4,4 char,
5,2 binary, 0x01
6,4 binary, integer I , formatted as 32bit number, in little indian firmat
8,4 char
13, I char

where integer I is the lenth of the data-part

“Little indian firmat” - this is something new in Computer Science... :ugeek:

Looks like it has been developed in India? :mrgreen:
Javas and Pythons come and go, but JCL and SORT stay forever.

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Communicating with Zabbix from REXX

Postby sergeyken » Wed Mar 03, 2021 7:16 pm

AllardK wrote:here is my code-snippet:

Code: Select all

result = Calculate_Result(key)
  dl_out = length(result)
  dl_out_hex = D2X(dl_out)
  packet = 'ZBXD'||'01'x||dl_out_hex||'00'x||'00'x||'00'x||'00'x||result
  fc = SOCKET('SEND',accepted_socket,packet,'')


In my test the string resut = ‘ZOS4’
So the length of the data is 4

However when sending the packet the zabbix-server is giving an error “because message is shorter than expected 52 bytes”

So the problem must be in the wrong format of dl_out in the packet.

I hope you can help me solve this.


1) read carefully about the function D2X, and other conversion fonctions.
2) trace your conversions, each step, by using

Code: Select all

. . . .
 SAY dl_out
 . . . . .
 SAY dl_out_hex
 . . . .

3) think a little bit about the printed results

Since you did not do it yourself, that proves to me 100% that this is the very first program you have coded in your life, right?
Javas and Pythons come and go, but JCL and SORT stay forever.

enrico-sorichetti
Global moderator
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
Referer: www.ibmmainframes.com

Re: Communicating with Zabbix from REXX

Postby enrico-sorichetti » Wed Mar 03, 2021 8:15 pm

what disease prevents You from reading the manuals ???

a plain dumb simple google search for "REXX D2X" returned this link
https://www.ibm.com/support/knowledgece ... x/d2x.html

if You had done a bit of homework You would not have had the need to ask

it would be useful to get the most out of the questions you ask to read and meditate on

"How to ask questions the smart way"

http://catb.org/~esr/faqs/smart-questions.html

since I am in a very good mood ( just for a few seconds ) here is a snippet to meditate on

Code: Select all

r = "zOS4"
l = length(r)
say l
x = d2x(l,2)
say x x2c(x) c2x(x2c(x))
b = x2b(d2x(l,2))
say b


what You need is x2c(d2x(l,2))
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

AllardK
Posts: 17
Joined: Tue Apr 28, 2020 4:27 pm
Skillset: Beginner, COBOL, CICS, REXX, JCL
Referer: Google

Re: Communicating with Zabbix from REXX

Postby AllardK » Thu Mar 04, 2021 1:52 am

Hello Enrico,

I have read the manuals over and over, without any reSULT.
I am a relative newbee to REXX (2 years of exxperience) but I have been programming for about 40 years in COBOl, CICS,DB2.

The suggestions you have given are much appreciated, but if it would have been that simple I would’nt have asked for help on this expert forum. The suggestions don’t seem to work in REXX.

I know a little bit of REXX (maybe a little more than that) but this problem is a bit trickier than just reading the manual(which I did and gave me a lot of pleasure).

Here is my code:

Code: Select all



r = Calculate_Result(key)
  say 'r =' result
  l = length(r)
  say l
  x = D2X(l,2)
  say x X2C(x) C2X(X2C(x))
  b = X2B(D2X(l,2))
  say b
  header = 'ZBXD'
  packet = 'ZBXD'||'01'x||X2C(D2X(l,2))||'00'x||'00'x||'00'x||'00'x||r
  say 'output =' packet

  fc = SOCKET('SEND',accepted_socket,packet,'')

 


The response from the Zabbix-servers is:

Code: Select all


 Warning: Message from 192.168.2.248 is shorter than expected 26 bytes. Message ignored
 

AllardK
Posts: 17
Joined: Tue Apr 28, 2020 4:27 pm
Skillset: Beginner, COBOL, CICS, REXX, JCL
Referer: Google

Re: Communicating with Zabbix from REXX

Postby AllardK » Thu Mar 04, 2021 2:14 am

The output of the REXX program on z/OS is:

Code: Select all


r = ZOS4
4
04  04
00000100
output = ZBXD    ZOS4
 

enrico-sorichetti
Global moderator
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
Referer: www.ibmmainframes.com

Re: Communicating with Zabbix from REXX

Postby enrico-sorichetti » Thu Mar 04, 2021 2:40 am

You forgot to give back just one tiny little information ..

does the message buffer You just built conform to the sequence of instructions used
and to what You are expecting you are expecting

if NO post the displays You got so that we have something to work on
show both the char format and the hex format

if YES You are writing what You built, but unfortunately what You built is wrong

I just run a quick and dirty test using rexx on my pc
to show what the buffers should look like given Your info

the script

Code: Select all

r = "ZOS4"
l = length(r)
buff = "ZBXD" || "01"x || x2c(d2x(l,2)) || "000000"x || "00000000"x ||  r
say"******"
temp = c2x(buff)
say temp
say buff
buf0    = ""
buf1    = ""
do  i = 1 to length(temp) - 1 by 2
  buf0 = buf0 || substr(temp, i    , 1 )
  buf1 = buf1 || substr(temp, i + 1, 1 )
end
say buf0
say buf1
 


the result

Code: Select all

5A42584401040000005A4F5334
ZBXD.........ZOS4
54540000000005453
A284140000000AF34


the pc is ascii the mainframe is ebcdic,
just forget the difference in the hex representation of the chars

what counts are the binary values
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

willy jensen
Posts: 474
Joined: Thu Mar 10, 2016 5:03 pm
Skillset: assembler rexx zOS ispf racf smf
Referer: saw it in the experts foprum thought I could help here

Re: Communicating with Zabbix from REXX

Postby willy jensen » Thu Mar 04, 2021 2:43 am

Like enrico-sorichetti I would like to see what the output is from one of the other implementations - in hex. Something that works, please.
Clearly your generated text is too short so something in missing.

AllardK
Posts: 17
Joined: Tue Apr 28, 2020 4:27 pm
Skillset: Beginner, COBOL, CICS, REXX, JCL
Referer: Google

Re: Communicating with Zabbix from REXX

Postby AllardK » Fri Mar 05, 2021 10:49 pm

Hello Enrico and Willy,

first of all, I really appreciate your help.

I ran the sample test program on z/OS and got the following output:

Code: Select all


E9C2E7C4010400000000000000E9D6E2F4
ZBXD            ZOS4
ECEC000000000EDEF
92741400000009624
 

which looks good to me.

However the length field is still not in the right format foor the Zabbix-server side:

I have done some testing.

hex 01 gives datalength 1 on the side of the Zabbix-server
hex 02 gives 2
hex 03 gives 3
hex 04 gives 26
hex 05 gives 32

Still trying, reading and puzzling

Kind regards

Allard

enrico-sorichetti
Global moderator
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
Referer: www.ibmmainframes.com

Re: Communicating with Zabbix from REXX

Postby enrico-sorichetti » Sat Mar 06, 2021 2:22 am

unfortunately very little we can do on our side

I spent a bit of time researching ..
got to the zabbix manual pages with the snippets you posted
https://www.zabbix.com/documentation/cu ... er_datalen

and fortunately there was a bash snippet

Code: Select all


DATA="ZOS4"
printf -v LENGTH '%016x' "${#DATA}"
PACK=""
for (( i=14; i>=0; i-=2 )); do PACK="$PACK\\x${LENGTH:$i:2}"; done
printf "ZBXD\x01$PACK%s" "$DATA"

 


and when I run it using ZOS4 as data I got the same results as the rexx snippet I gave You

Code: Select all


+ DATA=ZOS4
+ printf -v LENGTH %016x 4
+ PACK=
+ (( i=14 ))
+ (( i>=0 ))
+ PACK='\x04'
+ (( i-=2  ))
+ (( i>=0 ))
+ PACK='\x04\x00'
+ (( i-=2  ))
+ (( i>=0 ))
+ PACK='\x04\x00\x00'
+ (( i-=2  ))
+ (( i>=0 ))
+ PACK='\x04\x00\x00\x00'
+ (( i-=2  ))
+ (( i>=0 ))
+ PACK='\x04\x00\x00\x00\x00'
+ (( i-=2  ))
+ (( i>=0 ))
+ PACK='\x04\x00\x00\x00\x00\x00'
+ (( i-=2  ))
+ (( i>=0 ))
+ PACK='\x04\x00\x00\x00\x00\x00\x00'
+ (( i-=2  ))
+ (( i>=0 ))
+ PACK='\x04\x00\x00\x00\x00\x00\x00\x00'
+ (( i-=2  ))
+ (( i>=0 ))
+ printf 'ZBXD\x01\x04\x00\x00\x00\x00\x00\x00\x00%s' ZOS4
 


as You see the last printf shows the same buffer
( it looks strange because the escape chars were lost in the code tags )

probably worth to ask on a zabbix forum
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

User avatar
Pedro
Posts: 686
Joined: Thu Jul 31, 2008 9:59 pm
Skillset: ISPF
Referer: google
Location: Silicon Valley

Re: Communicating with Zabbix from REXX

Postby Pedro » Mon Mar 08, 2021 12:41 am

Various thoughts...

In your code:

Code: Select all

say buff

I have been stymied many times because of trailing characters or blanks. And I recall that rexx strips off the trailing blanks at times.

For that reason, for problem determination, I have used:

Code: Select all

say "<"buff">"

to add delimiters so that I could 'see' the actual length. (In your later examples, it looks like you use constants, so probably not this case)

I have used several z/OS interfaces. Sometimes the length includes itself and other prefix info and sometimes the length is only the data. (it looks like yours is only data). Please verify.

The length seems to be the problem, perhaps a hex vs. octal problem.

Is there any conversion taking place? (for example, during FTP some conversion is done from ASCII to EBCDIC)
Pedro Vera


  • Similar Topics
    Replies
    Views
    Last post