Ad Widget

Collapse

Zabbix Sender sends JSON without Doublequotes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Deluxe
    Junior Member
    • Jan 2020
    • 2

    #1

    Zabbix Sender sends JSON without Doublequotes

    Hi,

    i am having a nasty problem and i was not able to find out why.

    So here is my situation:

    I am doing that on Powershell 5 because i need some information about my AD.

    So i am creating a variable with some informations about the AD.

    $i = Get-ADUser -Filter * useraccountcontrol | Select-Object Surname,GivenName,userAccountControl | Sort-Object -Property GivenName

    Output:

    Surname GivenName userAccountControl
    ------------ ---------------- --------------------------
    User1 BLABLA 1234
    User2 BLABLA 5678

    You get the idea.

    Then i Convert it to an JSON:

    $i = $i | ConvertTo-Json -Compress

    Output is and correct JSON Format:
    [{"Surname":"User1","GivenName":"BLABLA","userAc cou ntControl":1234},{"Surname":"User2","GivenName":"B LABLA","userAccountControl":5678}]

    Now i would like to send it in that format to the Zabbix Server via the Zabbix_Sender.exe

    C:\zabbix\zabbix_sender.exe -s Domain -c C:\zabbix\zabbix_agentd.conf -k ad.user -o $i

    Zabbix recieves:

    [{Surname:User1,GivenName:BLABLA,userAccountControl :1234},{Surname:User2,GivenName:BLABLA,userAccount Control:5678}]

    Thats no JSON anymore. And Zabbix cannot interprate that and i don't know why.
    Am I doing something wrong?

    Please help me i am getting rather desperate.

    Many Thanks
    Tom
    Last edited by Deluxe; 07-02-2020, 15:25.
  • dimir
    Zabbix developer
    • Apr 2011
    • 1080

    #2
    Not a windows user, but judging by documentation you could try
    Code:
    $i = $i | ConvertTo-Json -Compress -EscapeHandling EscapeHtml
    and then the sender command.

    Comment


    • Deluxe
      Deluxe commented
      Editing a comment
      Hi,

      thanks. But that doesnt work on Powershell 5. And Powershell 6 and 7 don't support the Active Directory Module on Windows Server 2016.
      Thank's anyway!
  • dimir
    Zabbix developer
    • Apr 2011
    • 1080

    #3
    Another wild hint, double-quote the $i:
    Code:
    C:\zabbix\zabbix_sender.exe -s Domain -c C:\zabbix\zabbix_agentd.conf -k ad.user -o "$i"

    Comment


    • Deluxe
      Deluxe commented
      Editing a comment
      Creates the same output. I tried almost anything.
      Is that a but of the Sender.exe or of Powershell or anything else? I don't understand that behavior.
  • dimir
    Zabbix developer
    • Apr 2011
    • 1080

    #4
    Can you show full output containing prompts to see which command-line parser (cmd.exe, PowerShell) you use in every command?
    Here's possibly useful link, it shows how escaping works in PowerShell: http://www.rlmueller.net/PowerShellEscape.htm

    Comment


    • Deluxe
      Deluxe commented
      Editing a comment
      I solved the Problem by adding an additional " so that the JSON looks like that:

      [{""Surname"":""User1"",""GivenName"":"2BLABLA"","" userAc cou ntControl"":1234},{""Surname"":""User2"",""GivenNa me"":""B LABLA"",""userAccountControl"":5678}]

      Now the Server gets the right values.

      Thank you for your help!
  • BlizzardTech-Adam
    Junior Member
    • Dec 2021
    • 6

    #5
    Hey, I'm having this issue... I need to send json over to the zabbix server so I can use preprocessing to obtain the info I need in zabbix.... it just keeps stripping the output of "

    Comment

    Working...