Communicating with Zabbix from REXX



IBM's Command List programming language & Restructured Extended Executor

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 come and go, but JCL stays forever.

These users thanked the author sergeyken for the post:
AllardK (Sat Mar 27, 2021 1:36 pm)
User avatar
sergeyken
 
Posts: 153
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 3 times
Been thanked: 13 times

Re: Communicating with Zabbix from REXX

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

AllardK wrote:here is my code-snippet:

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
. . . .
 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 come and go, but JCL stays forever.
User avatar
sergeyken
 
Posts: 153
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 3 times
Been thanked: 13 times

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

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
enrico-sorichetti
Global moderator
 
Posts: 2957
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 159 times

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:



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:

 Warning: Message from 192.168.2.248 is shorter than expected 26 bytes. Message ignored
 
AllardK
 
Posts: 15
Joined: Tue Apr 28, 2020 4:27 pm
Has thanked: 5 times
Been thanked: 0 time

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:

r = ZOS4
4
04  04
00000100
output = ZBXD    ZOS4
 
AllardK
 
Posts: 15
Joined: Tue Apr 28, 2020 4:27 pm
Has thanked: 5 times
Been thanked: 0 time

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
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
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
enrico-sorichetti
Global moderator
 
Posts: 2957
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 159 times

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.
willy jensen
 
Posts: 334
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 44 times

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:

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
AllardK
 
Posts: 15
Joined: Tue Apr 28, 2020 4:27 pm
Has thanked: 5 times
Been thanked: 0 time

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


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

+ 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

These users thanked the author enrico-sorichetti for the post:
AllardK (Sat Mar 27, 2021 1:37 pm)
enrico-sorichetti
Global moderator
 
Posts: 2957
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 159 times

Re: Communicating with Zabbix from REXX

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

Various thoughts...

In your code:
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:
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

These users thanked the author Pedro for the post:
AllardK (Sat Mar 27, 2021 1:38 pm)
User avatar
Pedro
 
Posts: 631
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 45 times

PreviousNext

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post