Ad Widget

Collapse

Why Zabbix tell JSON is invalid?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AndreykaKopeyka
    Junior Member
    • Aug 2018
    • 4

    #1

    Why Zabbix tell JSON is invalid?

    Hi!
    I was use this script, which build JSON with all certificate file:
    #!/bin/bash

    JSON="{ "data":["

    for CERTS_DIR in /home/ubuntu/ops-vpn-keys;do

    certs=`ls $CERTS_DIR/keys | grep crt`
    if [[ -n ${certs} ]]; then
    for CRT in ${certs}; do
    JSON=${JSON}"{ "{#CERTIFICATE}":"${CERTS_DIR}/keys/${CRT}"},"
    done
    fi

    done
    JSON=${JSON}"]}"
    echo ${JSON} | sed '$s/,]}$/]}/'

    Unforthunatley Zabbix don't undestand JSON which generated by this script and msg me: "zabbix value should be a json object"

    Any suggestion?
  • finalbeta
    Junior Member
    • Sep 2015
    • 9

    #2
    It's hard to tell if that will create a valid JSON. Write the output to a temp file to start with and compare it to the examples at https://www.zabbix.com/documentation...evel_discovery

    Comment

    • daniel.velinov
      Junior Member
      • Jan 2019
      • 2

      #3
      I have a similar problem. It is weird that my auto-discovery rule works only for one of four servers I have applied it to, and the settings and json output format is the same on all of them.

      On the working host:
      [root@tracing1ch ~]# zabbix_agentd -t traces.folder.discovery
      traces.folder.discovery [t|{
      "data":[

      {
      "{#DIR.NAME}":"/mnt/traces/httpxml-dmi"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-internal"},
      {
      "{#DIR.NAME}":"/mnt/traces/sigtran-internal"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-public"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-partner"},
      {
      "{#DIR.NAME}":"/mnt/traces/sigtran-public"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-ocs"}
      ]
      }]

      The item rule also works
      [root@tracing1ch ~]# zabbix_agentd -t traces.folder.check["/mnt/traces/diameter-public"]
      traces.folder.check[/mnt/traces/diameter-public] [t|1]


      On the problematic host I get "Value should be a JSON object", but the output of the autodiscovery rule and the item key works as expected
      [root@tracing2ch ~]# zabbix_agentd -t traces.folder.discovery
      traces.folder.discovery [t|{
      "data":[

      {
      "{#DIR.NAME}":"/mnt/traces/sigtran-internal"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-public"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-public-tcp"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-internal"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-ocs"},
      {
      "{#DIR.NAME}":"/mnt/traces/sigtran-public"},
      {
      "{#DIR.NAME}":"/mnt/traces/diameter-partner"}
      ]
      }]

      [root@tracing2ch ~]# zabbix_agentd -t traces.folder.check["/mnt/traces/diameter-public"]
      traces.folder.check[/mnt/traces/diameter-public] [t|1]


      As you can see both servers provide valid JSON output files, and both can resolve the item keys to a value, however on the Zabbix server, only tracing1ch server can discover the items, and tracing2ch fails with "Value should be a JSON object"
      Can you assist please

      Comment

      • daniel.velinov
        Junior Member
        • Jan 2019
        • 2

        #4
        I found the issue. In my case SELINUX had to be disabled on the problematic hosts. That resolved my issue, so feel free to try that on your end

        Comment

        Working...