January 2019
Intermediate to advanced
798 pages
20h 33m
English
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} ...Read now
Unlock full access