Book Image

Mastering Zabbix (Second Edition)

Book Image

Mastering Zabbix (Second Edition)

Overview of this book

Table of Contents (18 chapters)
Mastering Zabbix Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Mass operations


Now it is time to see the Python Zabbix API in action. Another common use of the API facility is to automate certain operations that you can perform from the web frontend, but they may be cumbersome or prone to errors. Things such as adding many users or updating the host IP addresses after merging two different networks fall under this category. The following fragments will assume that you already have a Zabbix API handle just as shown in the previous paragraphs. In other words, from now on, it will be assumed that your code will start with something similar to the following (remember that the Zabbix URL and user credentials here are just examples! Use your own URL and credentials):

#!/usr/bin/python
from pyzabbix import ZabbixAPI
user='Admin'
pwd='password'
url = 'https://127.0.0.1/zabbix/'
zh = ZabbixAPI(url)
zh.login(user=user, password=pwd)

Redistributing hosts to proxies

We have seen in Chapter 2, Distributed Monitoring, that you can add hosts to a proxy through the proxy...