Ad Widget

Collapse

Zabbix API and Proxy - doesn't work as expected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vitalii Bendyna
    Junior Member
    • Jan 2019
    • 8

    #1

    Zabbix API and Proxy - doesn't work as expected

    Zabbix v.4.2.1

    Hello!
    I'm trying to automate routine work, so I decided to use API.
    My installation: 1 Zabbix server and 2 Zabbix proxies (active).
    I'm going to monitor a lot of websites, and all these checks must be done from Proxy #2. And for each website will be separate host attached to Proxy #2. So:
    1. I've created a template with 1 web scenario, which will use User Macro
    2. I've written a script for adding host to Zabbix.

    When I run a script, everything works, new host with correct macro appears in Zabbix Server, BUT it doesn't won't to be attached to proxy. It appears like I've added it directly to server.
    Please see my json that is sent to the server for creating new host:

    Code:
    {  
       "jsonrpc":"2.0",
       "method":"host.create",
       "params":{  
          "host":"Domain-example.com",
          "interfaces":[  
             {  
                "type":1,
                "main":1,
                "useip":1,
                "ip":"127.0.0.1",
                "dns":"",
                "port":"10050"
             }
          ],
          "groups":[  
             {  
                "groupid":"17"
             }
          ],
          "templates":[  
             {  
                "templateid":"10586"
             }
          ],
          "macros":[  
             {  
                "macro":"{$REAL_DOMAIN_NAME}",
                "value":"example.com"
             }
          ]
       },
       "proxy_hostid":"10583",
       "auth":"some auth",
       "id":1
    }
    It attaches to correct group, template (IDs are getting above in the same script). But it doesn't want to be monitored by proxy. ID of Proxy is correct, as it is received by request in the same script.

    Please see attached image - on it you'll find the result of the script.

    P.S. ID of proxy is correct: When I open "Administration -> Proxies -> click on my proxy" - it shows me this URL: https://some-zabbix.url/zabbix.php?a...&proxyid=10583


    Much appreciated for your help
    Click image for larger version

Name:	Screen Shot 2019-05-29 at 6.18.32 PM.png
Views:	1132
Size:	59.4 KB
ID:	379757
  • Vitalii Bendyna
    Junior Member
    • Jan 2019
    • 8

    #2
    Found issue.
    Parameter "proxy_hostid" must be located in "params" array. Outside of it parameter is omitted by the server without any error or notification.

    Zabbix developers, could you please add notifications when any parameter from API is omitted by the system?

    Thanks all for your attention.

    Comment

    Working...