API by example
As it's always easier to understand things when you see a working example, I have added a simple example that you can use to create hosts, link them to a template and add them to the correct group.
Getting ready
For this recipe, we only need our Zabbix server with the super administrators account that was created at the installation. We need to install the Zabbix agent on the Zabbix server. There is no need to change any of the parameters just make sure that the Zabbix server is monitored by Zabbix. Once it is working, remove the Zabbix server host from the list of hosts in Zabbix as we will add it again by making use of the API.
How to do it...
- Log into your Zabbix server.
- Install the EPEL repository as we need
pip
on our machine installed:yum install http://fedora.cu.be/epel/6/i386/epel-release-6-8.noarch.rpm
- Install
python
andpython-pip
on your Zabbix server as follows:yum install python python-pip
- Install the third-party tool PyZabbix as follows:
pip install pyzabbix...