Ad Widget

Collapse

Zabbix JavaScript doesn't work on s390x

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tim_p
    Junior Member
    • Oct 2021
    • 9

    #1

    Zabbix JavaScript doesn't work on s390x

    I have tried using the JavaScript preprocessing action many times on s390x and it always ends with a failure stating "invalid bytecode". No matter how simple the script is, meaning nothing more than a simple one line that returns a string, it always fails. The strange part is that when you use the Test option on an item it always works in the UI and the output is correct. However, as soon as I attempt to use it at runtime it always fails.

    My setup is a zabbix server (v5.4.5) running on x86. The error is happening on a zabix proxy (v5.4.5) running on s390x. The code is running as a docker container using sqlite3, https://hub.docker.com/r/zabbix/zabbix-proxy-sqlite3. I have used previous versions of 5.4 and upgraded last week to 5.4.5 in hopes that would help fix things. It did not.

    It appears that the duktape JavaScript engine does not work at all on s390x, although it doesn't explain why it runs fine in test mode.

    Another strange thing is that the error seems to fluctuate between 2 messages that I have attached here. No code change or anything, it just spits out different errors randomly for the same operation.





    I am also attaching the output from the test of this same script in the UI where it works every time with no error.




    I will also mention that when I look at the log of the proxy container I can see that it randomly crashes with no explanation quite frequently.

    Code:
    145:20211004:150923.661 proxy #4 started [trapper #3]
    171:20211004:150923.667 proxy #30 started [availability manager #1]
    150:20211004:150923.754 proxy #9 started [preprocessing worker #2]
    151:20211004:151008.882 Got signal [signal:11(SIGSEGV),reason:1,refaddr:0x2aaa7e52000]. Crashing ...
    151:20211004:151008.882 ====== Fatal information: ======
    151:20211004:151008.882 program counter not available for this architecture
    151:20211004:151008.882 === Registers: ===
    151:20211004:151008.882 register dump not available for this architecture
    151:20211004:151008.882 === Backtrace: ===
    151:20211004:151008.883 23: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(zbx_backtrace+0x58) [0x2aa33392c80]
    151:20211004:151008.883 22: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(zbx_log_fatal_info+0xd8) [0x2aa33392ef8]
    151:20211004:151008.883 21: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(+0x213ad0) [0x2aa33393ad0]
    151:20211004:151008.883 20: [0x3ffdfc7bc10]
    151:20211004:151008.883 19: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(+0xe8622) [0x2aa33268622]
    151:20211004:151008.883 18: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(+0xece08) [0x2aa3326ce08]
    151:20211004:151008.883 17: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(+0xed072) [0x2aa3326d072]
    151:20211004:151008.883 16: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(duk_push_lstring+0xf2) [0x2aa33244022]
    151:20211004:151008.883 15: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(+0xb0e82) [0x2aa33230e82]
    151:20211004:151008.883 14: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(+0xb32c0) [0x2aa332332c0]
    151:20211004:151008.883 13: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(duk_load_function+0xaa) [0x2aa3323391a]
    151:20211004:151008.883 12: /usr/sbin/zabbix_proxy: preprocessing worker #3 started(zbx_es_execute+0x224) [0x2aa33229b84]
    ....

    Attached Files
    Last edited by tim_p; 05-10-2021, 15:30.
  • tim_p
    Junior Member
    • Oct 2021
    • 9

    #2
    It appears I was right about there being an issue with the javascript engine as it has now been fixed here: https://github.com/zabbix/zabbix/com...014f749749981f

    Comment

    • tim_p
      Junior Member
      • Oct 2021
      • 9

      #3
      After running with the latest code with the bug fix above I no longer get the invalid bytecode errors and the crashes. That part is good. However, I can now get no useful data back from the Javascript calls. What worked above in the testing phase no longer works on the new version with the new duktape version.

      Refer to the image above from the test where you could see that the string I expected to be returned was there. Now when I run the same test I get only some string with a bunch of "[object Object],[object Object],[object Object],[object Object],..." values.

      How did this break now? Is this a problem on the zabbix side or with the new version of duktape that is used now?

      Click image for larger version

Name:	zabbix-error.jpg
Views:	250
Size:	74.7 KB
ID:	433104

      Comment

      • tim_p
        Junior Member
        • Oct 2021
        • 9

        #4
        This appears to be strictly an issue with dealing with JSON data. I was able to use
        Code:
        JSON.parse(value)
        and parse the data with no issue as I mentioned above. Is there something different that needs to be done now in order to parse JSON data?

        Comment

        • tim_p
          Junior Member
          • Oct 2021
          • 9

          #5
          Ok, never mind the latest issue. It looks like there was still some debug code causing this from when I was chasing the initial problem for weeks. Everything looks good now on s390x when using Javascript preprocessing using the fix above. The code in not in an actual versioned release yet but I built the proxy from a branch that did contain the fix and confirmed everything.

          Issue resolved.

          Comment

          Working...