Skip to content
Luke Cyca edited this page Nov 24, 2013 · 12 revisions

PyZabbix

PyZabbix is a Python module for working with the Zabbix API.

Requirements

  • Tested against Zabbix 1.8 through 2.2

Getting Started

Install PyZabbix using pip:

$ pip install pyzabbix

You can now import and use pyzabbix like so:

from pyzabbix import ZabbixAPI

zapi = ZabbixAPI("http://zabbixserver.example.com")
zapi.login("zabbix user", "zabbix pass")
print "Connected to Zabbix API Version %s" % zapi.api_version()

for h in zapi.host.get(extendoutput=True):
    print h['hostid']

Refer to the Zabbix API Documentation and the PyZabbix Examples for more information.

Customizing the HTTP request

PyZabbix uses the requests library for http. You can customize the request parameters by providing a configured requests Session object to PyZabbix.

This is useful for:

  • Customizing headers
  • Enabling HTTP authentication
  • Enabling Keep-Alive
  • Disabling SSL certificate verification
from pyzabbix import ZabbixAPI
from requests import Session

s = Session()

# Enable HTTP auth
s.auth = ("http user", "http password")

# Disable SSL certificate verification
s.verify = False

zapi = ZabbixAPI("http://zabbixserver.example.com", s)

License

LGPL 2.1 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html

Zabbix API Python Library.

Original Ruby Library is Copyright (C) 2009 Andrew Nelson nelsonab(at)red-tux(dot)net

Original Python Library is Copyright (C) 2009 Brett Lentz brett.lentz(at)gmail(dot)com

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Clone this wiki locally