Creating a host

Now, let's move on to creating a host using the API. Let's set our JSON variable:

$ json='{"jsonrpc":"2.0","method":"host.create","params":{"host":"API created host","interfaces":[{"type":1,"main":1,"useip":1,"ip":"127.0.0.2","dns":"","port":"10050"}],"groups":[{"groupid":"2"}],"templates":[{"templateid":"10186"}]},"auth": "df83119ab78bbeb2065049412309f9b4","id":1}' 

In the default Zabbix database, the group ID of 2 should correspond to the Linux servers group, and the template ID of 10104 should correspond to the Template ICMP Ping template. If the IDs are different on your system, change them in this JSON string. Run the curl command now, and the host should be created successfully:

{"jsonrpc":"2.0","result":{"hostids":["10277"]},"id":1} 

As part of the response, we also got the ID of the new host. Feel free to verify in the frontend that this host has been created.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.123.120