Ad Widget

Collapse

Discovery - Braces in Value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Clontarf[X]
    Member
    • Jan 2017
    • 80

    #1

    Discovery - Braces in Value

    Hi All,

    I am doing a discovery of GUIDs which contain braces {}. While the JSON is valid (RFC 4627), it seems Zabbix doesn't agree (I receive invalid JSON error). Here is an example of JSON output when the script is run interactively on the zabbix app server as root;

    ./script.action <host> path/<host>/share
    Code:
    {
            "data":[
                    {"{#DIRECTORY}":"{049FA6AE-39F5-4E80-B7E0-BA6155C87C1D}"},
                    {"{#DIRECTORY}":"{FF71860A-DEAE-4325-BA62-276D59309ED4}"}
            ]
    }
    Am I correct in assuming that Zabbix is treating the {GUID} as a macro when attempting to "populate" the items? My guess is when it attempts the discovery, it tries to evaluate the contents of {GUID} as a value, instead of treating it as a literal string value.

    These are the the two keys I have tried with the same error;

    // Using macros to do templated discovery
    script.action[{HOST.HOST},path/{HOST.HOST}/share]

    // Statically defining parameters
    script.action[host,path/host/share]
  • glebs.ivanovskis
    Senior Member
    • Jul 2015
    • 237

    #2
    Try to make an ordinary item (with data type text) instead of LLD rule and make sure that Zabbix receives data in a way you expect. Empty results is a common issue for scripts due to various permission stuff, and empty result for LLD rule can cause "invalid JSON" errors.

    Comment

    • Clontarf[X]
      Member
      • Jan 2017
      • 80

      #3
      Thanks for your reply The zabbix user is granted sudo NOPASSWD access, so zabbix should be able to execute properly. I don't believe it's a permissions issue. Indeed if I switch to the zabbix user and execute it returns as expected;

      [root@host externalscripts]# su - zabbix
      -bash-4.2$ perl -w script.action host path
      {
      "data":[
      {"{#DIRECTORY}":"folder.name"}
      ]
      }

      Comment

      • Clontarf[X]
        Member
        • Jan 2017
        • 80

        #4
        I've also just tested in Zabbix 3.0.1 and it works as expected.

        This perhaps is a JSON parsing bug for Zabbix 2.4?

        Comment

        • glebs.ivanovskis
          Senior Member
          • Jul 2015
          • 237

          #5
          Which minor version of 2.4 was it? ChangeLog search gave me that: ZBX-8913, ZBX-8926, ZBX-9959.

          Comment

          Working...