Ad Widget

Collapse

Discovery items are created but without values

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dicko
    Junior Member
    • Dec 2021
    • 8

    #1

    Discovery items are created but without values

    Server version 4.4.10
    Agent version 4.4.10

    On the Zabbix server I created a template with a discovery rule:
    1. Create a Template "Template test" and add that to the "Templates" group.
    2. For this template create a Discovery rule "Discover assets" of type "Zabbix agent" and key "assets.discovery".
    3. Create an Item prototype with name "Assets of {#ITEMNAME}" of type "Agent trapper", key "assets[{#ITEMNAME}]" of information type "numeric(unsigned)".
    4. Create a host "Test" in group "Templates", with the correct IP address and port and link this host to "Template test".
    For the agent I added to zabbix_agentd.conf:
    Code:
    UserParameter=assets.discovery,pwsh -NoProfile -ExecutionPolicy Bypass -File "C:\path\to\file.ps1"
    (pwsh is PowerShell 7)

    The PowerShell script:
    1. Outputs a JSON:
      [
      {"{#ITEMNAME}": "client1"},
      {"{#ITEMNAME}": "client2"}
      ]
    2. Creates a UTF8 text file file.txt containing:
      MYHOSTNAME assets[client1] 123123123
      MYHOSTNAME assets[client2] 456456456
    3. Calls zabbix_sender to send this text file to the server:
      Code:
      zabbix_sender -vv -z xxx.xxx.xxx.xxx -i C:\path\to\file.txt
    As seen from the agent log the JSON is sent:

    1944:20220117:162431.318 EXECUTE_STR() command:'pwsh -NoProfile -ExecutionPolicy Bypass -File "C:\path\to\file.ps1"' len:387 cmd_result:'[
    {
    "{#ITEMN'
    1944:20220117:162431.319 Sending back [[
    {
    "{#ITEMNAME}": "client1"
    },
    {
    "{#ITEMNAME}": "client2"
    }
    ]]


    The items are indeed created in Zabbix.

    When I execute
    Code:
    zabbix_sender -vv -z xxx.xxx.xxx.xxx -i C:\path\to\file.txt
    as a stand-alone line in Powershell, this is the output:

    zabbix_sender.exe [8208]: DEBUG: answer [{"response":"success","info":"processed: 0; failed: 9; total: 9; seconds spent: 0.000065"}]
    Response from "xxx.xxx.xxx.xxx:10051": "processed: 0; failed: 9; total: 9; seconds spent: 0.000065"
    sent: 9; skipped: 0; total: 9


    What am I doing wrong?

    Any help is appreciated.
    Last edited by Dicko; 17-01-2022, 18:46.
  • Answer selected by Dicko at 18-01-2022, 10:00.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    I think OP states here already, that even when executing manually, sender is failing... ("When I execute... as a stand-alone line in Powershell, this is the output")
    Verify, that item keys and hostnames match in input file and what was created. In this example case it must be "Test" as hostname. Verify, that your ports are open from host to server.

    Comment


    • Dicko
      Dicko commented
      Editing a comment
      cyber, you fixed my problem!

      This is kind of embarassing, but I mixed up some terms. Your answer made me realise what I did wrong.
      As the Zabbix agent is installed on a Windows machine and the term "hostname" on Windows is the name of the machine I thought I needed to use that.
      Also because in the zabbix_agentd.conf the option Hostname is used, and for that we normally use the Windows hoastname ...

      So in the line...
      MYHOSTNAME assets[client1] 123123123
      ...I used the wrong name.

      As soon as I used the Zabbix hostname, everything went right.

      Thanks!
      Last edited by Dicko; 18-01-2022, 11:16.
  • ISiroshtan
    Senior Member
    • Nov 2019
    • 324

    #2
    Hi Mate.

    Do you run a PS script that sends data for discovery process and immediate pushes the data for items that should be discovered? With no internal delay between this 2 steps? I have a feeling that your script might execute faster then Zabbix processes incoming JSON and as a result data is sent via sender before items exist.

    Could you split your script into manual steps and perform them manually with some delay between them just to prove me right or wrong.

    Comment


    • Dicko
      Dicko commented
      Editing a comment
      Hi ISorishtan,

      Thanks for replying so quickly.

      Yesterday I created the items and just now executed "zabbix_sender -vv -z xxx.xxx.xxx.xxx -i C:\path\to\file.txt"
      So enough time between creating items and sending the values.
      Alas the response is the same ...

      Kind regards, Dick
      Last edited by Dicko; 18-01-2022, 09:26.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #3
    I think OP states here already, that even when executing manually, sender is failing... ("When I execute... as a stand-alone line in Powershell, this is the output")
    Verify, that item keys and hostnames match in input file and what was created. In this example case it must be "Test" as hostname. Verify, that your ports are open from host to server.

    Comment


    • Dicko
      Dicko commented
      Editing a comment
      cyber, you fixed my problem!

      This is kind of embarassing, but I mixed up some terms. Your answer made me realise what I did wrong.
      As the Zabbix agent is installed on a Windows machine and the term "hostname" on Windows is the name of the machine I thought I needed to use that.
      Also because in the zabbix_agentd.conf the option Hostname is used, and for that we normally use the Windows hoastname ...

      So in the line...
      MYHOSTNAME assets[client1] 123123123
      ...I used the wrong name.

      As soon as I used the Zabbix hostname, everything went right.

      Thanks!
      Last edited by Dicko; 18-01-2022, 11:16.
Working...