pyzabbix


Namepyzabbix JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttp://github.com/lukecyca/pyzabbix
SummaryZabbix API Python interface
upload_time2023-04-08 13:53:03
maintainer
docs_urlNone
authorLuke Cyca
requires_python>=3.6
licenseLGPL
keywords zabbix monitoring api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyZabbix

**PyZabbix** is a Python module for working with the [Zabbix API](https://www.zabbix.com/documentation/current/manual/api/reference).

[![CI](https://github.com/lukecyca/pyzabbix/actions/workflows/ci.yml/badge.svg)](https://github.com/lukecyca/pyzabbix/actions/workflows/ci.yml)
[![PyPI Package Version](https://img.shields.io/pypi/v/pyzabbix.svg)](https://pypi.org/project/pyzabbix/)
[![PyPI Python Versions](https://img.shields.io/pypi/pyversions/pyzabbix.svg)](https://pypi.org/project/pyzabbix/)

## Requirements

- Tested against Zabbix 4.0 LTS, 5.0 LTS, 6.0 LTS and 6.4.

## Documentation

### Getting Started

Install PyZabbix using pip:

```bash
$ pip install pyzabbix
```

You can now import and use pyzabbix like so:

```python
from pyzabbix import ZabbixAPI

zapi = ZabbixAPI("http://zabbixserver.example.com")
zapi.login("zabbix user", "zabbix pass")
# You can also authenticate using an API token instead of user/pass with Zabbix >= 5.4
# zapi.login(api_token='xxxxx')
print("Connected to Zabbix API Version %s" % zapi.api_version())

for h in zapi.host.get(output="extend"):
    print(h['hostid'])
```

Refer to the [Zabbix API Documentation](https://www.zabbix.com/documentation/current/manual/api/reference) and the [PyZabbix Examples](https://github.com/lukecyca/pyzabbix/tree/master/examples) for more information.

### Customizing the HTTP request

PyZabbix uses the [requests](https://requests.readthedocs.io/en/master/) library for HTTP. You can customize the request parameters by configuring the [requests Session](https://requests.readthedocs.io/en/master/user/advanced/#session-objects) object used by PyZabbix.

This is useful for:

- Customizing headers
- Enabling HTTP authentication
- Enabling Keep-Alive
- Disabling SSL certificate verification

```python
from pyzabbix import ZabbixAPI

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

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

# Disable SSL certificate verification
zapi.session.verify = False

# Specify a timeout (in seconds)
zapi.timeout = 5.1

# Login (in case of HTTP Auth, only the username is needed, the password, if passed, will be ignored)
zapi.login("http user", "http password")

# You can also authenticate using an API token instead of user/pass with Zabbix >= 5.4
# zapi.login(api_token='xxxxx')
```

### Enabling debug logging

If you need to debug some issue with the Zabbix API, you can enable the output of logging, pyzabbix already uses the default python logging facility but by default, it logs to "Null", you can change this behavior on your program, here's an example:

```python
import sys
import logging
from pyzabbix import ZabbixAPI

stream = logging.StreamHandler(sys.stdout)
stream.setLevel(logging.DEBUG)
log = logging.getLogger('pyzabbix')
log.addHandler(stream)
log.setLevel(logging.DEBUG)


zapi = ZabbixAPI("http://zabbixserver.example.com")
zapi.login('admin','password')

# You can also authenticate using an API token instead of user/pass with Zabbix >= 5.4
# zapi.login(api_token='xxxxx')

```

The expected output is as following:

```
Sending: {
    "params": {
        "password": "password",
        "user": "admin"
    },
    "jsonrpc": "2.0",
    "method": "user.login",
    "id": 2
}
Response Code: 200
Response Body: {
    "jsonrpc": "2.0",
    "result": ".................",
    "id": 2
}
>>>
```

## Development

To develop this project, start by reading the `Makefile` to have a basic understanding of the possible tasks.

Install the project and the dependencies in a virtual environment:

```sh
make install
source .venv/bin/activate
```

### Releases

To release a new version, first bump the version number in `setup.py` by hand and run the release target:

```sh
make release
```

Finally, push the release commit and tag to publish them to Pypi:

```sh
git push --follow-tags
```

## 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

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/lukecyca/pyzabbix",
    "name": "pyzabbix",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "zabbix monitoring api",
    "author": "Luke Cyca",
    "author_email": "me@lukecyca.com",
    "download_url": "https://files.pythonhosted.org/packages/24/7a/7a7400ca882a0d75ab0a2d78ee53287357cdf66d32aad592b05852273a43/pyzabbix-1.3.0.tar.gz",
    "platform": null,
    "description": "# PyZabbix\n\n**PyZabbix** is a Python module for working with the [Zabbix API](https://www.zabbix.com/documentation/current/manual/api/reference).\n\n[![CI](https://github.com/lukecyca/pyzabbix/actions/workflows/ci.yml/badge.svg)](https://github.com/lukecyca/pyzabbix/actions/workflows/ci.yml)\n[![PyPI Package Version](https://img.shields.io/pypi/v/pyzabbix.svg)](https://pypi.org/project/pyzabbix/)\n[![PyPI Python Versions](https://img.shields.io/pypi/pyversions/pyzabbix.svg)](https://pypi.org/project/pyzabbix/)\n\n## Requirements\n\n- Tested against Zabbix 4.0 LTS, 5.0 LTS, 6.0 LTS and 6.4.\n\n## Documentation\n\n### Getting Started\n\nInstall PyZabbix using pip:\n\n```bash\n$ pip install pyzabbix\n```\n\nYou can now import and use pyzabbix like so:\n\n```python\nfrom pyzabbix import ZabbixAPI\n\nzapi = ZabbixAPI(\"http://zabbixserver.example.com\")\nzapi.login(\"zabbix user\", \"zabbix pass\")\n# You can also authenticate using an API token instead of user/pass with Zabbix >= 5.4\n# zapi.login(api_token='xxxxx')\nprint(\"Connected to Zabbix API Version %s\" % zapi.api_version())\n\nfor h in zapi.host.get(output=\"extend\"):\n    print(h['hostid'])\n```\n\nRefer to the [Zabbix API Documentation](https://www.zabbix.com/documentation/current/manual/api/reference) and the [PyZabbix Examples](https://github.com/lukecyca/pyzabbix/tree/master/examples) for more information.\n\n### Customizing the HTTP request\n\nPyZabbix uses the [requests](https://requests.readthedocs.io/en/master/) library for HTTP. You can customize the request parameters by configuring the [requests Session](https://requests.readthedocs.io/en/master/user/advanced/#session-objects) object used by PyZabbix.\n\nThis is useful for:\n\n- Customizing headers\n- Enabling HTTP authentication\n- Enabling Keep-Alive\n- Disabling SSL certificate verification\n\n```python\nfrom pyzabbix import ZabbixAPI\n\nzapi = ZabbixAPI(\"http://zabbixserver.example.com\")\n\n# Enable HTTP auth\nzapi.session.auth = (\"http user\", \"http password\")\n\n# Disable SSL certificate verification\nzapi.session.verify = False\n\n# Specify a timeout (in seconds)\nzapi.timeout = 5.1\n\n# Login (in case of HTTP Auth, only the username is needed, the password, if passed, will be ignored)\nzapi.login(\"http user\", \"http password\")\n\n# You can also authenticate using an API token instead of user/pass with Zabbix >= 5.4\n# zapi.login(api_token='xxxxx')\n```\n\n### Enabling debug logging\n\nIf you need to debug some issue with the Zabbix API, you can enable the output of logging, pyzabbix already uses the default python logging facility but by default, it logs to \"Null\", you can change this behavior on your program, here's an example:\n\n```python\nimport sys\nimport logging\nfrom pyzabbix import ZabbixAPI\n\nstream = logging.StreamHandler(sys.stdout)\nstream.setLevel(logging.DEBUG)\nlog = logging.getLogger('pyzabbix')\nlog.addHandler(stream)\nlog.setLevel(logging.DEBUG)\n\n\nzapi = ZabbixAPI(\"http://zabbixserver.example.com\")\nzapi.login('admin','password')\n\n# You can also authenticate using an API token instead of user/pass with Zabbix >= 5.4\n# zapi.login(api_token='xxxxx')\n\n```\n\nThe expected output is as following:\n\n```\nSending: {\n    \"params\": {\n        \"password\": \"password\",\n        \"user\": \"admin\"\n    },\n    \"jsonrpc\": \"2.0\",\n    \"method\": \"user.login\",\n    \"id\": 2\n}\nResponse Code: 200\nResponse Body: {\n    \"jsonrpc\": \"2.0\",\n    \"result\": \".................\",\n    \"id\": 2\n}\n>>>\n```\n\n## Development\n\nTo develop this project, start by reading the `Makefile` to have a basic understanding of the possible tasks.\n\nInstall the project and the dependencies in a virtual environment:\n\n```sh\nmake install\nsource .venv/bin/activate\n```\n\n### Releases\n\nTo release a new version, first bump the version number in `setup.py` by hand and run the release target:\n\n```sh\nmake release\n```\n\nFinally, push the release commit and tag to publish them to Pypi:\n\n```sh\ngit push --follow-tags\n```\n\n## License\n\nLGPL 2.1 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html\n\nZabbix API Python Library.\n\nOriginal Ruby Library is Copyright (C) 2009 Andrew Nelson nelsonab(at)red-tux(dot)net\n\nOriginal Python Library is Copyright (C) 2009 Brett Lentz brett.lentz(at)gmail(dot)com\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this library; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
    "bugtrack_url": null,
    "license": "LGPL",
    "summary": "Zabbix API Python interface",
    "version": "1.3.0",
    "split_keywords": [
        "zabbix",
        "monitoring",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "31cf491b087008474136ca38fa6888350945a0274b5589360fc5c709ae8976bc",
                "md5": "5d08cffc265934bdc834d408ac7db77f",
                "sha256": "7af6f9e88ca39ad67f6041079b3c23b3e9031deef008396e7f98f242dd1fdd7f"
            },
            "downloads": -1,
            "filename": "pyzabbix-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5d08cffc265934bdc834d408ac7db77f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6915,
            "upload_time": "2023-04-08T13:53:02",
            "upload_time_iso_8601": "2023-04-08T13:53:02.016299Z",
            "url": "https://files.pythonhosted.org/packages/31/cf/491b087008474136ca38fa6888350945a0274b5589360fc5c709ae8976bc/pyzabbix-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "247a7a7400ca882a0d75ab0a2d78ee53287357cdf66d32aad592b05852273a43",
                "md5": "42cb927c9c636186dc66a1eb09d035f3",
                "sha256": "11a5ad9f3631b7c663c346129f00f935948de51a7eadff95b53272723b0339ff"
            },
            "downloads": -1,
            "filename": "pyzabbix-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "42cb927c9c636186dc66a1eb09d035f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7267,
            "upload_time": "2023-04-08T13:53:03",
            "upload_time_iso_8601": "2023-04-08T13:53:03.682190Z",
            "url": "https://files.pythonhosted.org/packages/24/7a/7a7400ca882a0d75ab0a2d78ee53287357cdf66d32aad592b05852273a43/pyzabbix-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-08 13:53:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "lukecyca",
    "github_project": "pyzabbix",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyzabbix"
}
        
Elapsed time: 0.13277s